-
Notifications
You must be signed in to change notification settings - Fork 218
GenericKubernetesResourceMatcher
does not detect removals within StatefulSet.spec
#1878
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
Comments
Hi @matthew-pintar , as we discussed maybe in your case it is good enough to use a Matcher with equality, see: But I completely agree that would be nice to support, some ignore list in the matchers. Will take a look on that. |
But it is always possible to also provide you custom logic in a dependent resource, just overriding the matcher, in case of Kubernetes Dependent resource, implementing the Matcher interface. |
@matthew-pintar pls check the related PR, added there basically an ognore list. Also there is an Integration test how to use it. This still ingores only the adds on the listed paths. For example for Service this is needed (see also in the PR), since it is added to specs by k8s: @KubernetesDependent
public class ServiceDependentResource
extends CRUDKubernetesDependentResource<Service, ServiceStrictMatcherTestCustomResource> {
// omitted code
@Override
public Matcher.Result<Service> match(Service actualResource,
ServiceStrictMatcherTestCustomResource primary,
Context<ServiceStrictMatcherTestCustomResource> context) {
return GenericKubernetesResourceMatcher.match(this, actualResource, primary, context, false,
false,
"/spec/ports",
"/spec/clusterIP",
"/spec/clusterIPs",
"/spec/externalTrafficPolicy",
"/spec/internalTrafficPolicy",
"/spec/ipFamilies",
"/spec/ipFamilyPolicy",
"/spec/sessionAffinity");
}
} Will be available in the next minor release. |
Awesome! This will work perfectly for me as using a matcher with just equality would cause it to never match in our situation. With the ignore list, it will work for us. Thanks for the quick turn around! |
Bug Report
What did you do?
StatefulSet
in kubernetes which contains more than one container in thespec.template.spec.containers
StatefulSet
no longer has it and there are no other changesWhat did you expect to see?
The removal of the container from the
StatefulSets
spec.template.spec.containers
is detected as a mismatch and the changes are applied to kubernetes.What did you see instead? Under which circumstances?
When the
GenericKubernetesResourceMatcher.match(R desired, R actualResource, boolean considerMetadata)
method is called, it does a resource comparison from desired to actual. It then looks at the operations and if there are any non-add operations, it considers the actual and desired not matching. If there are onlyadd
operations (which would be the case since something is being removed from the desired), it would still consider them matching. As a result, it returns the last linereturn Result.computed(true, desired);
so the operator thinks that actual and desired match and does not update kuberenetes.Environment
Kubernetes cluster type:
docker-desktop and GKE
$ Mention java-operator-sdk version from pom.xml file
$ java -version
$ kubectl version
Possible Solution
OR
The text was updated successfully, but these errors were encountered: