-
Notifications
You must be signed in to change notification settings - Fork 169
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
Apply mc-name-suffix annotation to kubeletconfig #3353
Changes from 1 commit
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -32,6 +32,10 @@ type Reconciler struct { | |
const ( | ||
ControllerName = "AutoSizedNodes" | ||
configName = "dynamic-node" | ||
|
||
// machineconfiguration annotation added on the kubelet CRD - dynamic-node | ||
mcAnnotationName = "machineconfiguration.openshift.io/mc-name-suffix" | ||
mcAnnotationValue = "" | ||
) | ||
|
||
func NewReconciler(log *logrus.Entry, client client.Client) *Reconciler { | ||
|
@@ -90,7 +94,14 @@ func (r *Reconciler) Reconcile(ctx context.Context, request ctrl.Request) (ctrl. | |
return ctrl.Result{}, fmt.Errorf("could not fetch KubeletConfig: %w", err) | ||
} | ||
|
||
// If already exists, update the spec | ||
// If already exists, update the spec and annotations | ||
if config.Annotations == nil { | ||
lranjbar marked this conversation as resolved.
Show resolved
Hide resolved
|
||
config.Annotations = defaultConfig.Annotations | ||
} | ||
if val, ok := config.Annotations[mcAnnotationName]; !ok || val != mcAnnotationValue { | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. If this is already set, we shouldn't be changing it regardless of value, as it will disconnect the kubeletconfig from the already rendered machineconfig There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This is true, we understand MCO behaviour in this condition. |
||
config.Annotations[mcAnnotationName] = mcAnnotationValue | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. What happens if a different There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Srini did some testing on this and found that if two kubeletconfig have the same value for this annotation it breaks MCO. This is potentially a breaking issue. I think we should rethink this approach because of this |
||
} | ||
|
||
config.Spec = defaultConfig.Spec | ||
err = r.client.Update(ctx, &config) | ||
if err != nil { | ||
|
@@ -120,7 +131,8 @@ func (r *Reconciler) SetupWithManager(mgr ctrl.Manager) error { | |
func makeConfig() mcv1.KubeletConfig { | ||
return mcv1.KubeletConfig{ | ||
ObjectMeta: metav1.ObjectMeta{ | ||
Name: configName, | ||
Name: configName, | ||
Annotations: map[string]string{mcAnnotationName: mcAnnotationValue}, | ||
}, | ||
Spec: mcv1.KubeletConfigSpec{ | ||
AutoSizingReserved: to.BoolPtr(true), | ||
|
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.
I would comment why we use
""
here just so we remember in a while, it's unintuitive.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.
Or we can make the name descriptive (e.g. lowPriority)?
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.
It's because the value
""
is viewed by MCO as zero. Hm.