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(HMS-2757): improve unexpected row error #706

Merged
merged 1 commit into from
Oct 11, 2023

Conversation

lzap
Copy link
Member

@lzap lzap commented Oct 11, 2023

An error striked me this morning: "failed to save AWS pubkey name to DB: expected 1 row: unexpected affected rows" which means detail reservation could not be updated after AWS key was updated. It looks like we fetch AWS reservation detail from the database but we do not load reservation_id field which is okay unless we need to update such record. This field is used in the WHERE query to locate the correct record.

I am adding few more log statements to see little bit more and adding the missing field.

During this, I noticed that our reservation - detail association is set up in a way that one reservation can have multiple details for different providers. But we have never done that, our current implementation is 1:1, we might drop this in the future. But it is okay for now.

@ezr-ondrej
Copy link
Member

are you sure, as I went looking for usage and we do not load reservation_id anywhere to the model, we use aws_reservation_id which I'm not sure exists, but won't load reservation_id field data I'm guessing:
https://github.com/lzap/provisioning-backend/blob/3b30277346e6dfe862a428a62c3afd62cefed026/internal/models/reservation_model.go#L85

and on usage, we fetch the ID of Reservation to use in the where condition: https://github.com/lzap/provisioning-backend/blob/3b30277346e6dfe862a428a62c3afd62cefed026/internal/jobs/launch_instance_aws.go#L142

@lzap lzap force-pushed the reservation-detail-id branch from 04da5c7 to f012208 Compare October 11, 2023 09:27
@lzap lzap force-pushed the reservation-detail-id branch from f012208 to f7b1106 Compare October 11, 2023 09:27
@lzap lzap changed the title fix(HMS-2757): fetch reservation id for update fix(HMS-2757): improve unexpected row error Oct 11, 2023
@lzap
Copy link
Member Author

lzap commented Oct 11, 2023

You are right that was an invalid conclusion, I renamed this only to improve logging which might come handy.

I believe the root cause is this: #707

But we need to confirm, I am not sure.

Copy link
Member

@ezr-ondrej ezr-ondrej left a comment

Choose a reason for hiding this comment

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

Thanks @lzap ! :)

@ezr-ondrej ezr-ondrej merged commit e86523a into RHEnVision:main Oct 11, 2023
6 checks passed
@lzap lzap deleted the reservation-detail-id branch October 11, 2023 10:32
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants