You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I'm working on an operator that, absolutely unsurprisingly, creates deployments. Following what seems to be the good controller style, I tried using CreateOrUpdate in roughly this way (simplified):
As you can guess from the title, this naive approach does not actually work. Because there are certain defaults in the schema (e.g. ImagePullPolicy), the deep comparison inside CreateOrUpdate always fails, and my controller gets stuck in an infinite reconcile loop trying to update the "defaulted" fields to their empty values.
What is a possible way out of this problem?
I've tried only changing fields that I want to set to non-default values. This quickly becomes really tedious.
Apply defaults before comparisons. So something like
I've seen this solution mentioned on stackoverflow, but I see a large problem here. The local copy of Kubernetes code may not match the server side causing one of three issues:
If the server is older, my code may try sending fields that do not exist in it.
If the server is newer, it may have fields my code doesn't know defaults for, causing the infinite reconcile loop again.
If the server changes any defaults (I hope they don't but who knows), I'm now sending non-default values.
The only possible solution I can imaging is to run comparison on copies with defaults applied. So, change CreateOrUpdate to something like
If the server is newer, it may have fields my code doesn't know defaults for, causing the infinite reconcile loop again.
Hmm, this has to be false: if my client is older than the server, I will not see new fields at all. So at least this is not an issue. Point 3 (changing defaults) is probably a rare case. Now I'm just curious how much of a problem point 1 (older servers) is.
In any case, this stuff could use a lot of documentation.
Hi folks.
I'm working on an operator that, absolutely unsurprisingly, creates deployments. Following what seems to be the good controller style, I tried using CreateOrUpdate in roughly this way (simplified):
As you can guess from the title, this naive approach does not actually work. Because there are certain defaults in the schema (e.g.
ImagePullPolicy
), the deep comparison insideCreateOrUpdate
always fails, and my controller gets stuck in an infinite reconcile loop trying to update the "defaulted" fields to their empty values.What is a possible way out of this problem?
I've seen this solution mentioned on stackoverflow, but I see a large problem here. The local copy of Kubernetes code may not match the server side causing one of three issues:
The only possible solution I can imaging is to run comparison on copies with defaults applied. So, change
CreateOrUpdate
to something likebut obviously
Schema
nowNo idea if this issue even has solutions but recording it here for any potential ideas.
The text was updated successfully, but these errors were encountered: