Skip to content

Ignore first user cancelled and get actual error as final error #5941

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

Merged
merged 1 commit into from
Jun 7, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 9 additions & 7 deletions pkg/skaffold/deploy/status/status_check.go
Original file line number Diff line number Diff line change
Expand Up @@ -221,15 +221,17 @@ func pollDeploymentStatus(ctx context.Context, cfg pkgkubectl.Config, r *resourc
}

func getSkaffoldDeployStatus(c *counter, rs []*resource.Deployment) (proto.StatusCode, error) {
if c.failed > 0 {
err := fmt.Errorf("%d/%d deployment(s) failed", c.failed, c.total)
for _, r := range rs {
if r.StatusCode() != proto.StatusCode_STATUSCHECK_SUCCESS {
return r.StatusCode(), err
}
if c.failed == 0 {
return proto.StatusCode_STATUSCHECK_SUCCESS, nil
}
err := fmt.Errorf("%d/%d deployment(s) failed", c.failed, c.total)
for _, r := range rs {
if r.StatusCode() != proto.StatusCode_STATUSCHECK_SUCCESS &&
r.StatusCode() != proto.StatusCode_STATUSCHECK_USER_CANCELLED {
return r.StatusCode(), err
}
}
return proto.StatusCode_STATUSCHECK_SUCCESS, nil
return proto.StatusCode_STATUSCHECK_USER_CANCELLED, err
}

func getDeadline(d int) time.Duration {
Expand Down
20 changes: 20 additions & 0 deletions pkg/skaffold/deploy/status/status_check_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -289,6 +289,26 @@ func TestGetDeployStatus(t *testing.T) {
shouldErr: true,
expectedCode: proto.StatusCode_STATUSCHECK_DEPLOYMENT_FETCH_ERR,
},
{
description: "one deployment failed and others cancelled and or succeeded",
counter: &counter{total: 3, failed: 2},
deployments: []*resource.Deployment{
withStatus(
resource.NewDeployment("deployment-cancelled", "test", 1),
proto.ActionableErr{ErrCode: proto.StatusCode_STATUSCHECK_USER_CANCELLED},
),
withStatus(
resource.NewDeployment("deployment-success", "test", 1),
proto.ActionableErr{ErrCode: proto.StatusCode_STATUSCHECK_SUCCESS},
),
withStatus(
resource.NewDeployment("deployment", "test", 1),
proto.ActionableErr{ErrCode: proto.StatusCode_STATUSCHECK_DEPLOYMENT_FETCH_ERR},
),
},
shouldErr: true,
expectedCode: proto.StatusCode_STATUSCHECK_DEPLOYMENT_FETCH_ERR,
},
}

for _, test := range tests {
Expand Down