Skip to content

Commit 9136544

Browse files
authored
ignore first user cancelled and get actual error as final error (#5941)
1 parent 8ba2ae3 commit 9136544

File tree

2 files changed

+29
-7
lines changed

2 files changed

+29
-7
lines changed

pkg/skaffold/deploy/status/status_check.go

Lines changed: 9 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -221,15 +221,17 @@ func pollDeploymentStatus(ctx context.Context, cfg pkgkubectl.Config, r *resourc
221221
}
222222

223223
func getSkaffoldDeployStatus(c *counter, rs []*resource.Deployment) (proto.StatusCode, error) {
224-
if c.failed > 0 {
225-
err := fmt.Errorf("%d/%d deployment(s) failed", c.failed, c.total)
226-
for _, r := range rs {
227-
if r.StatusCode() != proto.StatusCode_STATUSCHECK_SUCCESS {
228-
return r.StatusCode(), err
229-
}
224+
if c.failed == 0 {
225+
return proto.StatusCode_STATUSCHECK_SUCCESS, nil
226+
}
227+
err := fmt.Errorf("%d/%d deployment(s) failed", c.failed, c.total)
228+
for _, r := range rs {
229+
if r.StatusCode() != proto.StatusCode_STATUSCHECK_SUCCESS &&
230+
r.StatusCode() != proto.StatusCode_STATUSCHECK_USER_CANCELLED {
231+
return r.StatusCode(), err
230232
}
231233
}
232-
return proto.StatusCode_STATUSCHECK_SUCCESS, nil
234+
return proto.StatusCode_STATUSCHECK_USER_CANCELLED, err
233235
}
234236

235237
func getDeadline(d int) time.Duration {

pkg/skaffold/deploy/status/status_check_test.go

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -289,6 +289,26 @@ func TestGetDeployStatus(t *testing.T) {
289289
shouldErr: true,
290290
expectedCode: proto.StatusCode_STATUSCHECK_DEPLOYMENT_FETCH_ERR,
291291
},
292+
{
293+
description: "one deployment failed and others cancelled and or succeeded",
294+
counter: &counter{total: 3, failed: 2},
295+
deployments: []*resource.Deployment{
296+
withStatus(
297+
resource.NewDeployment("deployment-cancelled", "test", 1),
298+
proto.ActionableErr{ErrCode: proto.StatusCode_STATUSCHECK_USER_CANCELLED},
299+
),
300+
withStatus(
301+
resource.NewDeployment("deployment-success", "test", 1),
302+
proto.ActionableErr{ErrCode: proto.StatusCode_STATUSCHECK_SUCCESS},
303+
),
304+
withStatus(
305+
resource.NewDeployment("deployment", "test", 1),
306+
proto.ActionableErr{ErrCode: proto.StatusCode_STATUSCHECK_DEPLOYMENT_FETCH_ERR},
307+
),
308+
},
309+
shouldErr: true,
310+
expectedCode: proto.StatusCode_STATUSCHECK_DEPLOYMENT_FETCH_ERR,
311+
},
292312
}
293313

294314
for _, test := range tests {

0 commit comments

Comments
 (0)