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

Fix editing multi-build updates when title failed to update #2435

Merged
merged 1 commit into from
Jul 26, 2018

Conversation

puiterwijk
Copy link
Contributor

Sometimes an update title fails to update, and the title was used
in multi-build updates to determine whether a particular build was
in the update being edited.
This patch makes it actually look at whether the build is in the
current update by comparing.

Signed-off-by: Patrick Uiterwijk [email protected]

@puiterwijk puiterwijk added Critical We can't go on living in this sqalor, drop everything and fix it! reliability Issues pertaining to Bodhi's reliability WebUI Issues pertaining to Bodhi's web interface labels Jun 11, 2018
@puiterwijk puiterwijk requested a review from bowlofeggs June 11, 2018 18:10
@puiterwijk puiterwijk force-pushed the fixmultiupdates branch 3 times, most recently from 26c3f7b to edeb1db Compare June 11, 2018 20:42
@fedora-infra fedora-infra deleted a comment from centos-ci Jun 11, 2018
"Update for {} already exists".format(nvr))
# Ensure it doesn't already exist in another update
build = request.db.query(Build).filter_by(nvr=nvr).first()
if build and build.update is not None and up.title != build.update.title:
Copy link
Contributor

Choose a reason for hiding this comment

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

Is the intention here to compare up to build.update? If so, it might be good to compare the alias field instead of the title field since we want to remove/repurpose the title field some day.

Copy link
Contributor

Choose a reason for hiding this comment

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

Also, I'm not sure, but you might be able to use the is operator to compare them. I'd have to read some sqlalchemy docs to verify. If it were me, I'd just play it safe and compare a field I know to be unique like you did 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.

Sure, I'll switch to the .alias field.
However, the whole problem is that sometimes the update's title doesn't get correctly updated, and on later update, if one of the builds in the update remain, it will abort otherwise.

My example from the test:

  • I submitted a-1.0-1.fc17 b-1.0-1.fc17 c-1.0-1.fc17
  • At some point, I edited that to replace b-1.0-1.fc17 with b-1.0-2.fc17. However, due to a sometimes-occuring bug, the update.title is still a-1.0-1.fc17 b-1.0-1.fc17 c-1.0-1.fc17. This has happened a few times, and given that we're intending to remove/repurpose title, I didn't feel like fixing that.
  • I then want to edit it to replace c-1.0-1.fc17 with c-2.0-1.fc17. At this point, Bodhi checks each of the new builds whether they are in an existing update that is not the update I'm testing. It does that by testing against the nvr in update.title. HOWEVER, since the title didn't update correctly after the first edit, it no longer sees b-1.0-2.fc17 as part of this update, but when it goes request that build, that build does have an update attached to it.
  • My last edit now fails, because b-1.0-2.fc17 is in another update.

This patch fixes that problem by instead of checking whether all of the new builds are listed in the update.title, just look if the update the build is in is the one we're currently editing, thus fixing the example.

Copy link
Contributor

Choose a reason for hiding this comment

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

That makes sense, thanks for the detailed explanation!

@@ -227,13 +227,11 @@ def validate_builds(request, **kwargs):
'Cannot edit stable updates')

for nvr in request.validated.get('builds', []):
# If the build is new
if nvr not in edited:
Copy link
Contributor

Choose a reason for hiding this comment

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

Do you think this was here just to help with performance? It seems like it was just trying to make this verification when an NVR was being added to an update. Do you think we need to always perform this test?


Removed build(s):

- b-1.0-1.fc17
Copy link
Contributor

Choose a reason for hiding this comment

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

One day I will add tags to the Comment model so we don't have to have Bodhi test its own comments to see if stuff like this happened :)

args['builds'] = ['a-1.0-1.fc17', 'b-2.0-1.fc17', 'c-1.0-1.fc17']
r = self.app.post_json('/updates/', args)
up = r.json_body
self.assertEquals(up['title'], u'a-1.0-1.fc17 b-2.0-1.fc17 c-1.0-1.fc17')
Copy link
Contributor

Choose a reason for hiding this comment

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

The name and description of the test makes it sound like we expect the title not to change, but it seems like the title is correct 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.

This catches the case where the title didn't correctly update on an earlier update, read my summary from the other comment.

bowlofeggs
bowlofeggs previously approved these changes Jul 24, 2018
Sometimes an update title fails to update, and the title was used
in multi-build updates to determine whether a particular build was
in the update being edited.
This patch makes it actually look at whether the build is in the
current update by comparing.

Signed-off-by: Patrick Uiterwijk <[email protected]>
@puiterwijk puiterwijk requested a review from a team as a code owner July 26, 2018 21:21
@mergify mergify bot merged commit d997ed4 into fedora-infra:develop Jul 26, 2018
@bowlofeggs
Copy link
Contributor

This patch is planned to be included in the upcoming 3.10.0 release: #2556.

@bowlofeggs
Copy link
Contributor

This patch has been deployed to Fedora's staging Bodhi instance:

https://bodhi.stg.fedoraproject.org/

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Critical We can't go on living in this sqalor, drop everything and fix it! reliability Issues pertaining to Bodhi's reliability WebUI Issues pertaining to Bodhi's web interface
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants