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

added 'appsv1.DeploymentReplicaFailure' condition #878

Merged
merged 3 commits into from
Jan 13, 2024
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
6 changes: 3 additions & 3 deletions pkg/kapp/resourcesmisc/apps_v1_deployment.go
Original file line number Diff line number Diff line change
Expand Up @@ -54,10 +54,10 @@ func (s AppsV1Deployment) IsDoneApplying() DoneApplyState {
"Deployment is not progressing: %s (message: %s)", cond.Reason, cond.Message)}
}

case "FailedDelete":
case appsv1.DeploymentReplicaFailure:
if cond.Status == corev1.ConditionTrue {
return DoneApplyState{Done: true, Successful: false, Message: fmt.Sprintf(
"Deployment failed to delete pods: %s (message: %s)", cond.Reason, cond.Message)}
return DoneApplyState{Done: false, Successful: false, Message: fmt.Sprintf(
"Deployment has encountered replica failure: %s (message: %s)", cond.Reason, cond.Message)}
}
}
}
Expand Down
54 changes: 54 additions & 0 deletions pkg/kapp/resourcesmisc/apps_v1_deployment_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -59,6 +59,60 @@ status:
require.Equal(t, expectedState, state, "Found incorrect state")
}

func TestAppsV1DeploymentReplicaFailure(t *testing.T) {

depYAML := `
apiVersion: apps/v1
kind: Deployment
metadata:
praveenrewar marked this conversation as resolved.
Show resolved Hide resolved
name: test-deployment
generation: 1
status:
observedGeneration: 1
conditions:
- type: Progressing
status: "False"
reason: "ProgressDeadlineExceeded"
message: "Progress deadline exceeded"
`

deployment := buildDep(depYAML, t)
state := deployment.IsDoneApplying()

expectedState := ctlresm.DoneApplyState{
Done: true,
Successful: false,
Message: "Deployment is not progressing: ProgressDeadlineExceeded (message: Progress deadline exceeded)",
}

require.Equal(t, expectedState, state, "Found incorrect state")

depYAML = `
apiVersion: apps/v1
kind: Deployment
metadata:
name: test-deployment
generation: 1
status:
observedGeneration: 1
conditions:
- type: ReplicaFailure
status: "True"
reason: "FailedCreate"
message: "Failed to create pods"
`
deployment = buildDep(depYAML, t)
state = deployment.IsDoneApplying()

expectedState = ctlresm.DoneApplyState{
Done: false,
Successful: false,
Message: "Deployment has encountered replica failure: FailedCreate (message: Failed to create pods)",
}

require.Equal(t, expectedState, state, "Found incorrect state")
}

func buildDep(resourcesBs string, t *testing.T) *ctlresm.AppsV1Deployment {
newResources, err := ctlres.NewFileResource(ctlres.NewBytesSource([]byte(resourcesBs))).Resources()
require.NoErrorf(t, err, "Expected resources to parse")
Expand Down
Loading