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

[GitRepository] Broadcast delete of repo_dir #19123

Conversation

NickLaMuro
Copy link
Member

Built on top of #19122

Updates GitRepository#destroy to send FileUtils.rm_rf calls to the queue so it can be performed on all servers. The jobs should be idempotent and able to work even after the record is removed from the database.

Links

@NickLaMuro
Copy link
Member Author

@miq-bot add_label core, embedded ansible, enhancement

@Fryguy @carbonin Please review

@NickLaMuro
Copy link
Member Author

@miq-bot add_label ivanchuk/yes

@Fryguy
Copy link
Member

Fryguy commented Aug 9, 2019

I'm confused...I made a couple of comments on mobile and they are not here 😭

@NickLaMuro NickLaMuro force-pushed the git_repository_broadcast_filesystem_deletes branch from 48a1220 to 3c86f62 Compare August 10, 2019 21:00
@NickLaMuro NickLaMuro force-pushed the git_repository_broadcast_filesystem_deletes branch from 3c86f62 to b148e9d Compare August 12, 2019 15:43
@NickLaMuro NickLaMuro force-pushed the git_repository_broadcast_filesystem_deletes branch from b148e9d to 568a805 Compare August 12, 2019 17:57
@NickLaMuro
Copy link
Member Author

sync'd with master

Copy link
Member

@carbonin carbonin left a comment

Choose a reason for hiding this comment

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

Looks good to me

When a GitRepository record is deleted, broadcast the action of deleting
the filesystem info to all of the known active servers.

Since `EmbeddedAnsible` relates to a `GitRepository` record in it's
`ConfigurationScriptSource` for it's local git file system management,
the specs for it also needed to be updated so that they include running
the job that was pushed on to the queue (instead of it being deleted
right after a destroy from a callback)
@NickLaMuro NickLaMuro force-pushed the git_repository_broadcast_filesystem_deletes branch from 568a805 to db5b3c5 Compare August 12, 2019 20:59
@miq-bot
Copy link
Member

miq-bot commented Aug 12, 2019

Checked commit NickLaMuro@db5b3c5 with ruby 2.4.6, rubocop 0.69.0, haml-lint 0.20.0, and yamllint 1.10.0
3 files checked, 0 offenses detected
Everything looks fine. 🍰

@@ -383,6 +383,9 @@ def playbooks_for(repo)
expect(Notification).to receive(:create!).with(notification_args('deletion', {}))
record.delete_in_provider

# Run most recent queue item (`GitRepository#broadcast_repo_dir_delete`)
MiqQueue.get.deliver
Copy link
Member Author

Choose a reason for hiding this comment

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

I realize this is probably going to trigger @carbonin 's "this isn't a unit test" argument, but I figured removing the:

expect(git_repo_dir).to_not exist

Was a worse compromise. Mostly since while technically this is already mostly testing a lot of "Rails inner workings" when testing this method, we still want to confirm the business logic of it all is hooked up correctly, and that does require going outside of the scope of this method a bit.

However, I don't think relying on the tests from above for this is the answer either, since if we ever decide to use something besides GitRepository or MiqQueue, this spec would fail when we want it to and inform us that something in this model needs to change. I feel like that is some "brittleness" that we can afford to confirm that this is still doing it's job when things are inevitably refactored, and save us from having other groups inform of us this first.

Copy link
Member Author

Choose a reason for hiding this comment

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

Also, this is what was causing the specs to fail and cause this PR to be red. Hence the change in the first place.

Copy link
Member

Choose a reason for hiding this comment

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

It's no worse than how I feel about the rest of the MiqQueue#deliver calls in the other specs in this PR so I'd rather just get it in before I head out for the day 😉

Copy link
Member Author

Choose a reason for hiding this comment

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

Was also partially bringing this up since there was a lengthy discussion about this (and similar issues) by the two of us Friday, and I wanted this to be mentioned somewhere public instead of it just being something simply discussed out of band.

@carbonin carbonin self-assigned this Aug 12, 2019
@carbonin carbonin merged commit 89164c4 into ManageIQ:master Aug 12, 2019
@carbonin carbonin added this to the Sprint 118 Ending Aug 19, 2019 milestone Aug 12, 2019
simaishi pushed a commit that referenced this pull request Aug 12, 2019
…lesystem_deletes

[GitRepository] Broadcast delete of repo_dir

(cherry picked from commit 89164c4)
@simaishi
Copy link
Contributor

Ivanchuk backport details:

$ git log -1
commit 0f2ef6069722df2507fa30d0c34673fdfcae47f3
Author: Nick Carboni <ncarboni@redhat.com>
Date:   Mon Aug 12 18:01:34 2019 -0400

    Merge pull request #19123 from NickLaMuro/git_repository_broadcast_filesystem_deletes
    
    [GitRepository] Broadcast delete of repo_dir
    
    (cherry picked from commit 89164c4e6ae3fa40ae5ea25f87a2ddf5eb082991)

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.

5 participants