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

Conversation

jignyasamishra
Copy link
Contributor

What this PR does / why we need it:

The PR enhances deployment logic by adding a "FailedCreate" condition. This helps identify and handle specific failures during creation, improving error handling in deployments.

Which issue(s) this PR fixes:

Fixes #350

Does this PR introduce a user-facing change?

NONE

Additional Notes for your reviewer:

Review Checklist:
  • Follows the developer guidelines
  • Relevant tests are added or updated
  • Relevant docs in this repo added or updated
  • Relevant carvel.dev docs added or updated in a separate PR and there's
    a link to that PR
  • Code is at least as readable and maintainable as it was before this
    change

Additional documentation e.g., Proposal, usage docs, etc.:


@jignyasamishra
Copy link
Contributor Author

Hello @cppforlife Please review this PR.

Copy link
Member

@praveenrewar praveenrewar left a comment

Choose a reason for hiding this comment

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

Thank you for submitting a PR @jignyasamishra!

pkg/kapp/resourcesmisc/apps_v1_deployment.go Outdated Show resolved Hide resolved
Copy link
Member

@praveenrewar praveenrewar left a comment

Choose a reason for hiding this comment

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

It seems that there was some confusion while adding the FailedDelete case, or maybe things have changed since then, we need to combine these two into one.

@@ -59,6 +59,12 @@ func (s AppsV1Deployment) IsDoneApplying() DoneApplyState {
return DoneApplyState{Done: true, Successful: false, Message: fmt.Sprintf(
"Deployment failed to delete pods: %s (message: %s)", cond.Reason, cond.Message)}
}

case "FailedCreate":
Copy link
Member

Choose a reason for hiding this comment

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

I just noticed that the switch is on the type of condition, and "FailedDelete" and "FailedCreate" are Reasons for failure for condition type "ReplicaFailure". So instead of "FailedDelete" above and "FailedCreate", we should be checking for appsv1.DeploymentReplicaFailure. (More details around status conditions can be found here)

It would be great if you could also add a unit test for this in apps_v1_deployment_test.go.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Thank you so much for the explanation!!! I am working on this.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I have added the appsv1.DeploymentReplicaFailure instead of failedcreate/failedDelete condition, also I found apps_v1_deployment_test.go had no test coverage for isDoneApplying function which contains these checks so I added an unit test covering both the checks inside the function ie one for depolyment progressing condition and other for replicafailure.

Signed-off-by: jignyasamishra <[email protected]>
@jignyasamishra jignyasamishra changed the title included FailedCreate condition added 'appsv1.DeploymentReplicaFailure' condition Jan 12, 2024
Copy link
Member

@praveenrewar praveenrewar left a comment

Choose a reason for hiding this comment

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

@jignyasamishra Changes are looking pretty good, I have left a couple of nit picky comments.

@@ -65,3 +65,64 @@ func buildDep(resourcesBs string, t *testing.T) *ctlresm.AppsV1Deployment {

return ctlresm.NewAppsV1Deployment(newResources[0], newResources[1:])
}
func TestIsDoneApplying(t *testing.T) {
Copy link
Member

Choose a reason for hiding this comment

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

Let's move the test above the buildDep helper function. Also, let's rename it to TestAppsV1DeploymentReplicaFailure.

@@ -65,3 +65,64 @@ func buildDep(resourcesBs string, t *testing.T) *ctlresm.AppsV1Deployment {

return ctlresm.NewAppsV1Deployment(newResources[0], newResources[1:])
}
func TestIsDoneApplying(t *testing.T) {
// Define a Deployment with a Progressing condition set to False
Copy link
Member

Choose a reason for hiding this comment

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

The code is self explanatory, so we can remove the comments.

Comment on lines 85 to 89
resources, err := ctlres.NewFileResource(ctlres.NewBytesSource([]byte(depYAML))).Resources()
require.NoError(t, err, "Expected resources to parse")

// Create an AppsV1Deployment instance with the parsed resources
deployment := ctlresm.NewAppsV1Deployment(resources[0], nil)
Copy link
Member

Choose a reason for hiding this comment

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

We can use the existing buildDep helper function for this.

Comment on lines 117 to 119
resources, err = ctlres.NewFileResource(ctlres.NewBytesSource([]byte(depYAML))).Resources()
require.NoError(t, err, "Expected resources to parse")
deployment = ctlresm.NewAppsV1Deployment(resources[0], nil)
Copy link
Member

Choose a reason for hiding this comment

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

Same as above, we can use the existing helper function.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I have made the requested changes. Please have a look.

Signed-off-by: jignyasamishra <[email protected]>
Signed-off-by: jignyasamishra <[email protected]>
Copy link
Member

@praveenrewar praveenrewar left a comment

Choose a reason for hiding this comment

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

LGTM! Thank you so much for the contribution.

@praveenrewar praveenrewar merged commit 2f0080a into carvel-dev:develop Jan 13, 2024
5 checks passed
@jignyasamishra
Copy link
Contributor Author

LGTM! Thank you so much for the contribution.

Thank you so much for your guidance!!! Please do let me know if i can help in some other issues.

@github-actions github-actions bot added the carvel triage This issue has not yet been reviewed for validity label Jan 13, 2024
@praveenrewar praveenrewar removed the carvel triage This issue has not yet been reviewed for validity label Jan 14, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
Archived in project
Development

Successfully merging this pull request may close these issues.

include FailedCreate condition in deployment waiting logic
2 participants