-
-
Notifications
You must be signed in to change notification settings - Fork 36
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
Conversation
Quality Gate passedIssues Measures |
@@ -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. |
There was a problem hiding this comment.
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?
There was a problem hiding this comment.
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{}) |
There was a problem hiding this comment.
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"
There was a problem hiding this comment.
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.
There was a problem hiding this comment.
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.
There was a problem hiding this comment.
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.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The implementation would be close to func mergeMap
https://github.com/kubernetes/kubernetes/blob/7c48c2bd72b9bf5c44d21d7338cc7bea77d0ad2a/staging/src/k8s.io/apimachinery/pkg/util/strategicpatch/patch.go#L1322
Not sure if we can find a public interface to reuse. Maybe func StrategicMergeMapPatch
in https://github.com/kubernetes/kubernetes/blob/7c48c2bd72b9bf5c44d21d7338cc7bea77d0ad2a/staging/src/k8s.io/apimachinery/pkg/util/strategicpatch/patch.go#L856
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Implemented in #720
Let's close this issue as #720 fixes this too :) |
#694