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

Soft-delete deployments #348

Merged
merged 6 commits into from
Jul 9, 2024
Merged

Soft-delete deployments #348

merged 6 commits into from
Jul 9, 2024

Conversation

jsun-m
Copy link
Contributor

@jsun-m jsun-m commented Jul 2, 2024

No description provided.

@jsun-m jsun-m requested review from luke-lombardi and nickpetrovic and removed request for luke-lombardi July 2, 2024 21:53
@@ -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 {
Copy link
Contributor

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

Copy link
Contributor Author

Choose a reason for hiding this comment

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

nice, will add this

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")
Copy link
Contributor

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.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

yea you are right

// Get deployment
deploymentWithRelated, err := g.backendRepo.GetDeploymentByExternalId(ctx.Request().Context(), cc.AuthInfo.Workspace.Id, deploymentId)
if err != nil {
if err == sql.ErrNoRows {
Copy link
Contributor

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.

// 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",
Copy link
Contributor

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?

@jsun-m jsun-m requested a review from nickpetrovic July 9, 2024 19:31
@jsun-m jsun-m merged commit 8f4927f into main Jul 9, 2024
3 checks passed
@jsun-m jsun-m deleted the jm/soft-delete-deployment branch July 9, 2024 20:00
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