Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

jeremymv2/purge users #92

Merged
merged 10 commits into from
Mar 24, 2017
Merged

Conversation

jeremymv2
Copy link
Contributor

@jeremymv2 jeremymv2 commented Mar 14, 2017

I noticed while performing backup & restores that user deletions are not purged when using the purge option. purge was not implemented in knife-ec-backup only in ChefFS - users and user_acls are handled outside of ChefFS, in knife-ec-backup.

If we want user deletions to sync, this change adds the purge capability for users and user_acls in knife-ec-backup.

It requires #87 to be merged first to add the purge option.

end

def remote_user_list
@remote_user_list ||= remote_users.keys.map(&:to_sym)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why are we calling to_sym here since we are going to to_s them before yielding below?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You're right - the speed savings aren't there. I changed to an array of strings.

for_each_user_purge do |user|
ui.msg "Deleting user #{user} from local backup (purge is on)"
begin
File.delete("#{dest_dir}/users/#{user}.json")
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Just in case you might want ::File since we are inside Chef here.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Changed to ::File

end

def for_each_user_purge
purge_list = if opt_parser.default_argv[1] == 'backup'
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This could be problematic if this code was ever called from a different context. I'm wondering if it might be cleaner to have a users_for_purge function that could be implemented in the Backup and Restore classes (with an implementation here that raises an Unimplemented error. I don't usually like that kind of OOP indirection but it feels a bit safe than looking at argv

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I moved the implementation to each backup|restore class as well as in base where it raises an Chef::Knife::EcBase::UnImplemented error.

Signed-off-by: Jeremy J. Miller <[email protected]>
Signed-off-by: Jeremy J. Miller <[email protected]>
Signed-off-by: Jeremy J. Miller <[email protected]>
Signed-off-by: Jeremy J. Miller <[email protected]>
Signed-off-by: Jeremy J. Miller <[email protected]>
Signed-off-by: Jeremy J. Miller <[email protected]>
Signed-off-by: Jeremy J. Miller <[email protected]>
@jeremymv2 jeremymv2 force-pushed the jeremymv2/purge_users branch from e60d352 to 33d37dc Compare March 17, 2017 14:50
@jeremymv2 jeremymv2 added the bug label Mar 21, 2017
@jeremymv2
Copy link
Contributor Author

Hi @stevendanna. Thanks for the initial review. Could you take a look at the modifications I made since?

Copy link
Contributor

@stevendanna stevendanna left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This looks reasonable to me, thanks for taking this on.

@jeremymv2 jeremymv2 merged commit 728e308 into chef:master Mar 24, 2017
@jeremymv2 jeremymv2 deleted the jeremymv2/purge_users branch March 24, 2017 13:27
@tas50 tas50 added Type: Bug Does not work as expected. and removed bug labels Jul 31, 2018
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Type: Bug Does not work as expected.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants