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

Fix handler conflict with livenessProbe overrides #701

Closed

Conversation

uritig
Copy link

@uritig uritig commented Apr 18, 2024

Copy link

Quality Gate Passed Quality Gate passed

Issues
0 New issues
0 Accepted issues

Measures
0 Security Hotspots
No data about Coverage
0.0% Duplication on New Code

See analysis details on SonarCloud

@@ -44,6 +44,18 @@ func PatchPodSpecWithOverride(spec, override *corev1.PodSpec) (*corev1.PodSpec,
return nil, fmt.Errorf("can't marshal pod spec override: %w", err)
}

// If any of the override containers have livenessProbe overrides, the entire object should be replaced with the override.
Copy link
Contributor

Choose a reason for hiding this comment

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

More specifically, should we check and replace probeHandler instead of the whole probe?

Copy link
Author

Choose a reason for hiding this comment

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

Replacing the entire probe seemed cleaner (instead of looking for individual probeHandlers). But, I am open to changing it if that causes less confusion.

}
}
}

patchedJSON, err := strategicpatch.StrategicMergePatch(orginalSpec, overrideSpec, corev1.PodSpec{})
Copy link
Contributor

Choose a reason for hiding this comment

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

To be more generic, we'd better support the directives in https://github.com/kubernetes/kubernetes/blob/7c48c2bd72b9bf5c44d21d7338cc7bea77d0ad2a/staging/src/k8s.io/apimachinery/pkg/util/strategicpatch/patch.go#L41

const (
	directiveMarker  = "$patch"
	deleteDirective  = "delete"
	replaceDirective = "replace"
	mergeDirective   = "merge"

Copy link
Author

Choose a reason for hiding this comment

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

This does looks to be a cleaner approach. Will require a bit more digging on my part before I can submit a PR. Would be great, if you or someone can beat me to it :). Otherwise, will get to it as soon as I can.

Copy link
Owner

Choose a reason for hiding this comment

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

Agree with @yujunz !
A more generic solution would be better suited for this use case.

Ping me if you need some help.

Copy link
Author

Choose a reason for hiding this comment

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

@alexandrevilain @yujunz I am not quite sure yet how I'd go about respecting the directives in the operator. If either of you already know of an approach, I request that you proceed with the implementation. Thx.

Copy link
Contributor

@yujunz yujunz Apr 26, 2024

Choose a reason for hiding this comment

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

Copy link
Contributor

Choose a reason for hiding this comment

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

Implemented in #720

@alexandrevilain
Copy link
Owner

Let's close this issue as #720 fixes this too :)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants