-
Notifications
You must be signed in to change notification settings - Fork 213
NE-1318: Add always-enable-capabilities flag and set Ingress as always enabled #946
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
Changes from all commits
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 |
|---|---|---|
|
|
@@ -181,11 +181,16 @@ type SyncWorker struct { | |
| requiredFeatureSet configv1.FeatureSet | ||
|
|
||
| clusterProfile string | ||
|
|
||
| // alwaysEnableCapabilities is a list of cluster capabilities which should | ||
| // always be implicitly enabled. | ||
| // This contributes to whether or not some manifests are included for reconciliation. | ||
| alwaysEnableCapabilities []configv1.ClusterVersionCapability | ||
| } | ||
|
|
||
| // NewSyncWorker initializes a ConfigSyncWorker that will retrieve payloads to disk, apply them via builder | ||
| // to a server, and obey limits about how often to reconcile or retry on errors. | ||
| func NewSyncWorker(retriever PayloadRetriever, builder payload.ResourceBuilder, reconcileInterval time.Duration, backoff wait.Backoff, exclude string, requiredFeatureSet configv1.FeatureSet, eventRecorder record.EventRecorder, clusterProfile string) *SyncWorker { | ||
| func NewSyncWorker(retriever PayloadRetriever, builder payload.ResourceBuilder, reconcileInterval time.Duration, backoff wait.Backoff, exclude string, requiredFeatureSet configv1.FeatureSet, eventRecorder record.EventRecorder, clusterProfile string, alwaysEnableCapabilities []configv1.ClusterVersionCapability) *SyncWorker { | ||
| return &SyncWorker{ | ||
| retriever: retriever, | ||
| builder: builder, | ||
|
|
@@ -200,18 +205,18 @@ func NewSyncWorker(retriever PayloadRetriever, builder payload.ResourceBuilder, | |
| // if the reader is not fast enough. | ||
| report: make(chan SyncWorkerStatus, 500), | ||
|
|
||
| exclude: exclude, | ||
| requiredFeatureSet: requiredFeatureSet, | ||
|
|
||
| clusterProfile: clusterProfile, | ||
| exclude: exclude, | ||
| requiredFeatureSet: requiredFeatureSet, | ||
| clusterProfile: clusterProfile, | ||
| alwaysEnableCapabilities: alwaysEnableCapabilities, | ||
| } | ||
| } | ||
|
|
||
| // NewSyncWorkerWithPreconditions initializes a ConfigSyncWorker that will retrieve payloads to disk, apply them via builder | ||
| // to a server, and obey limits about how often to reconcile or retry on errors. | ||
| // It allows providing preconditions for loading payload. | ||
| func NewSyncWorkerWithPreconditions(retriever PayloadRetriever, builder payload.ResourceBuilder, preconditions precondition.List, reconcileInterval time.Duration, backoff wait.Backoff, exclude string, requiredFeatureSet configv1.FeatureSet, eventRecorder record.EventRecorder, clusterProfile string) *SyncWorker { | ||
| worker := NewSyncWorker(retriever, builder, reconcileInterval, backoff, exclude, requiredFeatureSet, eventRecorder, clusterProfile) | ||
| func NewSyncWorkerWithPreconditions(retriever PayloadRetriever, builder payload.ResourceBuilder, preconditions precondition.List, reconcileInterval time.Duration, backoff wait.Backoff, exclude string, requiredFeatureSet configv1.FeatureSet, eventRecorder record.EventRecorder, clusterProfile string, alwaysEnableCapabilities []configv1.ClusterVersionCapability) *SyncWorker { | ||
| worker := NewSyncWorker(retriever, builder, reconcileInterval, backoff, exclude, requiredFeatureSet, eventRecorder, clusterProfile, alwaysEnableCapabilities) | ||
| worker.preconditions = preconditions | ||
| return worker | ||
| } | ||
|
|
@@ -462,7 +467,7 @@ func (w *SyncWorker) Update(ctx context.Context, generation int64, desired confi | |
| return w.status.DeepCopy() | ||
| } | ||
|
|
||
| work.Capabilities = capability.SetCapabilities(config, priorCaps) | ||
| work.Capabilities = capability.SetCapabilities(config, priorCaps, capability.GetCapabilitiesAsMap(w.alwaysEnableCapabilities)) | ||
|
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. I think you need to set a variable from 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. But I also wonder why you didn't add
Contributor
Author
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.
I wanted to consolidate the process of determining the list of implicitly enabled capabilities within one function: 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. Yeah, I was mixing up |
||
|
|
||
| versionEqual, overridesEqual, capabilitiesEqual := | ||
| equalSyncWork(w.work, work, fmt.Sprintf("considering cluster version generation %d", generation)) | ||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -80,6 +80,10 @@ type Options struct { | |
|
|
||
| ClusterProfile string | ||
|
|
||
| // AlwaysEnableCapabilities is a list of cluster version capabilities | ||
| // which will always be implicitly enabled. | ||
| AlwaysEnableCapabilities []string | ||
|
|
||
| // for testing only | ||
| Name string | ||
| Namespace string | ||
|
|
@@ -148,6 +152,10 @@ func (o *Options) Run(ctx context.Context) error { | |
| if len(o.Exclude) > 0 { | ||
| klog.Infof("Excluding manifests for %q", o.Exclude) | ||
| } | ||
| alwaysEnableCaps, unknownCaps := parseAlwaysEnableCapabilities(o.AlwaysEnableCapabilities) | ||
| if len(unknownCaps) > 0 { | ||
| return fmt.Errorf("--always-enable-capabilities was set with unknown capabilities: %v", unknownCaps) | ||
| } | ||
|
|
||
| // parse the prometheus url | ||
| var err error | ||
|
|
@@ -168,7 +176,7 @@ func (o *Options) Run(ctx context.Context) error { | |
| } | ||
|
|
||
| // initialize the controllers and attempt to load the payload information | ||
| controllerCtx, err := o.NewControllerContext(cb) | ||
| controllerCtx, err := o.NewControllerContext(cb, alwaysEnableCaps) | ||
| if err != nil { | ||
| return err | ||
| } | ||
|
|
@@ -446,7 +454,7 @@ type Context struct { | |
|
|
||
| // NewControllerContext initializes the default Context for the current Options. It does | ||
| // not start any background processes. | ||
| func (o *Options) NewControllerContext(cb *ClientBuilder) (*Context, error) { | ||
| func (o *Options) NewControllerContext(cb *ClientBuilder, alwaysEnableCapabilities []configv1.ClusterVersionCapability) (*Context, error) { | ||
| client := cb.ClientOrDie("shared-informer") | ||
| kubeClient := cb.KubeClientOrDie(internal.ConfigNamespace, useProtobuf) | ||
|
|
||
|
|
@@ -480,6 +488,7 @@ func (o *Options) NewControllerContext(cb *ClientBuilder) (*Context, error) { | |
| o.PromQLTarget, | ||
| o.InjectClusterIdIntoPromQL, | ||
| o.UpdateService, | ||
| alwaysEnableCapabilities, | ||
| ) | ||
| if err != nil { | ||
| return nil, err | ||
|
|
@@ -584,3 +593,26 @@ func (c *Context) InitializeFromPayload(ctx context.Context, restConfig *rest.Co | |
|
|
||
| return nil | ||
| } | ||
|
|
||
| // parseAlwaysEnableCapabilities parses the string list of capabilities | ||
| // into two lists of configv1.ClusterVersionCapability: known and unknown. | ||
| func parseAlwaysEnableCapabilities(caps []string) ([]configv1.ClusterVersionCapability, []configv1.ClusterVersionCapability) { | ||
| var ( | ||
| knownCaps []configv1.ClusterVersionCapability | ||
| unknownCaps []configv1.ClusterVersionCapability | ||
| ) | ||
| for _, c := range caps { | ||
| known := false | ||
| for _, kc := range configv1.KnownClusterVersionCapabilities { | ||
|
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. Is
Contributor
Author
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. No, it's a slice. |
||
| if configv1.ClusterVersionCapability(c) == kc { | ||
| knownCaps = append(knownCaps, kc) | ||
| known = true | ||
| break | ||
| } | ||
| } | ||
| if !known { | ||
| unknownCaps = append(unknownCaps, configv1.ClusterVersionCapability(c)) | ||
| } | ||
| } | ||
| return knownCaps, unknownCaps | ||
| } | ||
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.
Why not add these capabilities to SyncWork.Capabilities? Then you don't have to pass the variable around in the signatures of other functions.
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.
My idea was to keep the assignment of the capabilities within a single function: SetCapabilities. This way 1) the logic of setting implicitly enabled capabilities would stay in a single function instead of being scattered over the code base, 2) I could tweak the operator without messing with other parts of the "work processing" logic.