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

purge archived only brings back archived records #14176

Merged
merged 1 commit into from
Mar 7, 2017

Conversation

kbrock
Copy link
Member

@kbrock kbrock commented Mar 3, 2017

Based upon feedback from http://talk.manageiq.org/t/vm-destroy-is-slow/2141/4

It was pointed out that we were bringing back every vm to determine if it was archived. This is slow.
Since that script was written, archived has become a virtual attribute and a scope. So we have faster means of accomplishing this request.

  • use a scope and only bring back the archived vms.
  • remove REPORT_ONLY which before turned the script into a no-op by default. Now it actually purges them by default.

Not sure if the updated_on was put into the query for performance or business reasons. I left it in there. Suggestions for us to remove this clause? It seems arbitrary. UPDATE: no, it is intentional

before after
non-delete 30 seconds 3 seconds

@chessbyte
Copy link
Member

@kbrock I thought the REPORT_ONLY was acting like a Linux standard --dry_run option. Maybe it makes sense to have that option available. /cc @Fryguy

@Fryguy
Copy link
Member

Fryguy commented Mar 3, 2017

@chessbyte You are correct. REPORT_ONLY is more or less "--dry-run" which I would like to keep for purging scripts as it allows a customer to run it and see what might change before deleting anything. In purge_metrics (which is the most fleshed out of the scripts), we call this parameter --mode, and the default there is count. The user has to opt-in to purging by changing that to purge

We should probably update all of the purge scripts at some point to a) have a common trollop based interface and b) use --dry-run instead of --mode as it's more intuitive

@Fryguy
Copy link
Member

Fryguy commented Mar 3, 2017

Not sure if the updated_on was put into the query for performance or business reasons

If you remove the clause then all archived VMs will go away which is not the intent. A user wants to know about recently archived VMs, but may want to clear out ones older than some time period (the ARCHIVE_CUTOFF)

@Fryguy
Copy link
Member

Fryguy commented Mar 3, 2017

We should probably update all of the purge scripts at some point to a) have a common trollop based interface and b) use --dry-run instead of --mode as it's more intuitive

In hindsight, I change my mind. --dry-run as an option would imply that the default action is to delete everything, which I don't want. These scripts are highly destructive and so their default mode of operation should be non-destructive and just informative. The user should be forced to opt-in via a parameter. I'm open to better parameter names.

@kbrock
Copy link
Member Author

kbrock commented Mar 4, 2017

@Fryguy Well, since the script is named purge_archived_vms.rb I had thought it would be destructive.

ok, anyway. sorry for deleting the stuff I thought was not useful. I guess I brought upon the scope creep upon myself

- use scope
- can no longer count non-archived locally
@kbrock
Copy link
Member Author

kbrock commented Mar 6, 2017

@Fryguy ok, rolled back all the code.

I just made the change to not bring back every vm and instead only bring back vms to purge.

@miq-bot
Copy link
Member

miq-bot commented Mar 6, 2017

Checked commit kbrock@f2a05b1 with ruby 2.2.6, rubocop 0.47.1, and haml-lint 0.20.0
1 file checked, 0 offenses detected
Everything looks good. 👍

@Fryguy Fryguy merged commit 745a3d9 into ManageIQ:master Mar 7, 2017
@Fryguy Fryguy added this to the Sprint 56 Ending Mar 13, 2017 milestone Mar 7, 2017
@kbrock kbrock deleted the archived_script branch March 7, 2017 20:53
@kbrock
Copy link
Member Author

kbrock commented Mar 10, 2017

NOTE: if this gets backported, ensure that Vm.all_archived no longer has the to_a - if it does, then make fix accordingly.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants