-
Notifications
You must be signed in to change notification settings - Fork 898
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
Test improvements for #14606 #14661
Test improvements for #14606 #14661
Conversation
b70fac8
to
1c8fbd5
Compare
@cben yeah, the images should be disconnected (ems_id foreign key set to nil), though when we allow them again, they will not be reconnected, we will create another record for the image |
Yes, I expected they'll be disconnected but test ~~suggests they aren't~~.
`expect(@container_image.ext_management_system).to eq(@ems)`
However let me improve test to really confirm, `ContainerImage.count` is
not the condition I want...
|
@cben right so, I don't see it on a first sight how is disabling of :container_images behaving, but this is how the old saving works: if you pass hashes[:container_images] = nil, or not even have the key :container_images, it will skip the processing, so leaving what was there intact if you pass hashes[:container_images] = [], it will disconnect all container_images. And it should also disconnect missing container_images. Can you verify what are we passing there? |
1c8fbd5
to
e82a628
Compare
Checked what happens to previous image data when image collection is disabled. => The unused images are disconected, the used image metadata is not deleted. stub_settings is risky, as it omits all other settings, and code may rely on default settings for sane behavior. stub_settings_merge is safer.
e82a628
to
9b77bec
Compare
Checked commit cben@9b77bec with ruby 2.2.6, rubocop 0.47.1, and haml-lint 0.20.0 |
=> Aha, unused images are disconnected; both those and still-used ones retain metadata. |
@cben right, but since we don reconnect the image, then this might break some reports for container.container_image relation? container.container_image.id # => '1'
container.container_image.disconnect_inv
# refresh
container.container_image.id # => '2'
# and we still have disconnected image with id 1 in the db but this happens also elsewhere (except saving VmOrTemplate in the old refresh), we were talking about this with @Fryguy , I would kind of like doing https://github.com/Ladas/manageiq/blob/4ad0054c6a92d2b6ee63437b4f1508fb0a6952e5/app/models/container_definition.rb#L16-L16 in general, we could base the generic reconnect logic on that, with tweaks for region migrations, where it could reconnect from multiple managers |
An image should never be disconnected while referenced by container(s) — refresh parser emits these images even when @Ladas Do you mean what happens after both container and image were disconnected? I think their relation should still hold, container's @Ladas or do you mean what happens after container and image are disconnected and then a new container appears using this image (or |
@cben "Do you mean what happens after both container and image were disconnected? I think their relation should still hold, container's container_image_id is not erased." that is correct "or do you mean what happens after container and image are disconnected and then a new container appears using this image (or get_openshift_images is turned back on) — will the existing record get reconnected to the EMS or will we get a new image record?" this is the case, unless there is a reconnect logic, it will create a duplicate record of a container image (so in the end there can be many disconnected duplicates of the same image) you can try with the example in #14661 (comment) . It will probably be a good example for a spec too, to manually disconnect 1 record and check the next refresh just reconnects it (the :id must be the same). that being said, the generic reconnect logic is not part of the old refresh nor Graph refresh. So we will need to add it. The most effective way should be, to pass AREL limiting where we can look for disconnected entities and then do 1 query to fetch IDs of records that are planned to be created. Then it would do a reconnect instead of the create. Should I prepare that logic for you? |
Indeed they are not reconnected :-( cc @simon3z @agrare
EDIT: tried passing |
@cben could you create a PR with the spec, then I can help you to modify the saving code. We need another relation than association, otherwise it would be disconnecting your disconnected things all the times. So we need a ContainerImage.where('ems_id = ? or old_ems_id = ?', ems.id, ems.id) only for the update_attributes code path |
Created #14808 with a fix, except it's not good. Can we merge this PR? It's just tests for stuff that's already in. (the reconnection test is not here since it's failing). |
yes, this looks good to be merged 👍 |
as long as youre not severing the relationship
depends on your definition of havoc. We would probably get some duplicate lines on the report but again, nothing would break if the relationships are intact. A unique key for a row in a chargeback report would be |
…elete-spec Test improvements for #14606 (cherry picked from commit 6354a4e) https://bugzilla.redhat.com/show_bug.cgi?id=1484548
Fine backport details:
|
…-false-delete-spec Test improvements for ManageIQ#14606 https://bugzilla.redhat.com/show_bug.cgi?id=1484548 (cherry picked from master commit 6354a4e via [FINE] cherry pick commit 0c1fb68 which adjusted for stub_settings_merge not existing yet, then adjusted for different [EUWE] vcr cassette)
Backported to Euwe via #15910 |
…-false-delete-spec Test improvements for ManageIQ#14606 (cherry picked from commit 6354a4e) https://bugzilla.redhat.com/show_bug.cgi?id=1484548
Checked what happens to previous image data when image collection is disabled (#14606).
=> Unused images are disconnected; both those and still-used ones retain metadata.
rely on default settings for sane behavior. Changed to stub_settings_merge.
@miq-bot add-label providers/containers, test
cc @agrare @Ladas @Fryguy