Skip to content

Commit

Permalink
Merge pull request GoogleContainerTools#4683 from nkubala/status-chec…
Browse files Browse the repository at this point in the history
…k-no-pods

Return deployment status code when status check can't retrieve pods from cluster
  • Loading branch information
tejal29 authored and nkubala committed Aug 20, 2020
1 parent e573568 commit 45cadb1
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 0 deletions.
3 changes: 3 additions & 0 deletions pkg/skaffold/deploy/resource/deployment.go
Original file line number Diff line number Diff line change
Expand Up @@ -268,6 +268,9 @@ func (d *Deployment) fetchPods(ctx context.Context) error {
// Return first pod status in error.
// TODO: should we return all distinct error codes in future?
func (d *Deployment) FirstPodErrOccurred() proto.StatusCode {
if len(d.pods) == 0 {
return d.Status().ActionableError().ErrCode
}
for _, p := range d.pods {
if s := p.ActionableError().ErrCode; s != proto.StatusCode_STATUSCHECK_SUCCESS {
return s
Expand Down
12 changes: 12 additions & 0 deletions pkg/skaffold/deploy/status_check_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -275,6 +275,18 @@ func TestGetDeployStatus(t *testing.T) {
description: "0 deployments",
counter: &counter{},
},
{
description: "unable to retrieve pods for deployment",
counter: &counter{total: 1, failed: 1},
deployments: []*resource.Deployment{
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

0 comments on commit 45cadb1

Please sign in to comment.