-
Notifications
You must be signed in to change notification settings - Fork 22
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): Do not cascade on pubkey delete #725
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Perfect work, there are few nitpicks but overall it is perfect.
internal/dao/dao_errors.go
Outdated
@@ -38,4 +38,7 @@ var ( | |||
|
|||
// ErrReservationRateExceeded is returned when SQL constraint does not allow to insert more reservations | |||
ErrReservationRateExceeded = usrerr.New(429, "rate limit exceeded", "too many reservations, wait and retry") | |||
|
|||
// ErrPubkeyNotFound is returned when a nil pointer to a pubkey is used for reservation detail | |||
ErrPubkeyNotFound = usrerr.New(404, "pubkey not found", "no pubkey found") |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Maybe to stress out the fact that this was caused very likely by deletion (the usecase we see quite often):
ErrPubkeyNotFound = usrerr.New(404, "pubkey not found", "no pubkey found") | |
ErrPubkeyNotFound = usrerr.New(404, "pubkey not found", "no pubkey found (already deleted?)") |
But I have to admit it looks weird, 404 is a 404 period. So feel free to let this wild idea go :-)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I have modified the message a bit to put the information out there.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
One more idea, we might want to incorporate a message telling users what can they do to fix this, right?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I thought it cannot be fixed, but sure that is the intention yes.
Thank you for the comments. All of them are addressed, as they were valid. 🎉 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There are two more anonymous functions but other than that all good.
@@ -58,7 +58,7 @@ func newGCPReservation() *models.GCPReservation { | |||
AccountID: 1, | |||
Status: "Created", | |||
}, | |||
PubkeyID: 1, | |||
PubkeyID: func(i int64) *int64 { return &i }(1), |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Perhaps here too?
@@ -23,6 +23,7 @@ var ( | |||
ErrBothTypeAndTemplateMissing = errors.New("instance type or launch template not set") | |||
ErrUnsupportedRegion = errors.New("unknown region/location/zone") | |||
ErrInvalidNamePattern = errors.New("name pattern is not RFC-1035 compatible") | |||
ErrPubkeyNotFound = errors.New("no pubkey found, it may have been already deleted") |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
For plain Go errors I would keep it simple:
ErrPubkeyNotFound = errors.New("no pubkey found, it may have been already deleted") | |
ErrPubkeyNotFound = errors.New("no pubkey found") |
Only in "user message" (above) it makes sense I think.
1ac1996
to
153aed0
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Please check the linter and this can be merged, thank you.
/retest |
That should be resolved now. /retest |
/retest I suspect the gcp is hitting public IP quota and we are then not having public IP present: https://ci.int.devshift.net/job/RHEnVision-provisioning-backend-pr-check/1975/ |
Maybe if we expose private IPs to the UI, we can not rely on public IP at all. Would that help @akhil-jha ? |
Ah, I guess I've caused conflict here :( Sorry! :( |
@@ -121,7 +121,7 @@ type GCPReservationResponse struct { | |||
ID int64 `json:"reservation_id" yaml:"reservation_id"` | |||
|
|||
// Pubkey ID. | |||
PubkeyID int64 `json:"pubkey_id" yaml:"pubkey_id"` | |||
PubkeyID *int64 `json:"pubkey_id,omitempty" yaml:"pubkey_id"` |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
ditto
Updated the yaml omitempty fields and rebased. |
Thank you @avitova ! 🧡 |
So I think this should do. I forgot to set pubkey_id nullable and could not find rollback, so I have two migrations.
Tested scenario: create key, create a reservation with the key, delete the key, GetReservationById.
In this sequence of steps, this all works as expected; we do not have any pubkey id, and GetReservationById returns a response with no pubkey_id. All occurrences of PubkeyId for both responses and pubkey models should be covered by checking for nil pointers, and we should keep in mind, that we do allow empty pointers here.