-
Notifications
You must be signed in to change notification settings - Fork 27
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
Soft-delete deployments #348
Conversation
pkg/api/v1/deployment.go
Outdated
@@ -84,6 +86,11 @@ func (g *DeploymentGroup) RetrieveDeployment(ctx echo.Context) error { | |||
|
|||
deploymentId := ctx.Param("deploymentId") | |||
if deployment, err := g.backendRepo.GetDeploymentByExternalId(ctx.Request().Context(), workspace.Id, deploymentId); err != nil { | |||
if err == sql.ErrNoRows { |
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.
This doesn't check for bad input (id not being a uuid) and will surface as a 500 when it should probably be a 400.
Check this out.
https://github.com/beam-cloud/beta9/blob/main/pkg/repository/backend_postgres.go#L419-L427
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.
nice, will add this
pkg/api/v1/deployment.go
Outdated
func (g *DeploymentGroup) DeleteDeployment(ctx echo.Context) error { | ||
cc, ok := ctx.(*auth.HttpAuthContext) | ||
if !ok { | ||
return echo.NewHTTPError(http.StatusInternalServerError, "Failed to get auth info") |
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.
Is this needed? I thought we took care of this here.
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.
yea you are right
pkg/api/v1/deployment.go
Outdated
// Get deployment | ||
deploymentWithRelated, err := g.backendRepo.GetDeploymentByExternalId(ctx.Request().Context(), cc.AuthInfo.Workspace.Id, deploymentId) | ||
if err != nil { | ||
if err == sql.ErrNoRows { |
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.
Feels like we're leaking sql into the service. Can we return nil, nil
when we don't find a deployment and there isn't an error? See my comment about the bad sql input.
pkg/api/v1/deployment.go
Outdated
// Delete deployment | ||
if err := g.backendRepo.DeleteDeployment(ctx.Request().Context(), deploymentWithRelated.Deployment); err != nil { | ||
return ctx.JSON(http.StatusInternalServerError, map[string]interface{}{ | ||
"error": "failed to delete deployment", |
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.
Most of these errors start lower cased, but one doesn't. Can we choose a style and keep it consistent?
No description provided.