Skip to content

OTA-1404: Add Support for a Configuration File: Creation of a Periodic Check #1192

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

Open
wants to merge 2 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions cmd/cluster-version-operator/start.go
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@ func init() {

cmd.PersistentFlags().StringVar(&opts.ListenAddr, "listen", opts.ListenAddr, "Address to listen on for metrics")
cmd.PersistentFlags().StringVar(&opts.Kubeconfig, "kubeconfig", opts.Kubeconfig, "Kubeconfig file to access a remote cluster (testing only)")
cmd.PersistentFlags().StringVar(&opts.ConfigFile, "config-file", opts.ConfigFile, "Configuration file for the CVO (represented by a clusterversionoperators.operator.openshift.io manifest file). DevPreview functionality.")
cmd.PersistentFlags().StringVar(&opts.NodeName, "node-name", opts.NodeName, "kubernetes node name CVO is scheduled on.")
cmd.PersistentFlags().BoolVar(&opts.EnableAutoUpdate, "enable-auto-update", opts.EnableAutoUpdate, "Enables the autoupdate controller.")
cmd.PersistentFlags().StringVar(&opts.ReleaseImage, "release-image", opts.ReleaseImage, "The Openshift release image url.")
Expand Down
22 changes: 20 additions & 2 deletions pkg/cvo/cvo.go
Original file line number Diff line number Diff line change
Expand Up @@ -183,6 +183,9 @@ type Operator struct {
// always be implicitly enabled.
alwaysEnableCapabilities []configv1.ClusterVersionCapability

// configFile is a path to a ClusterVersionOperator configuration file
configFile string
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Should we validate this when passed (it is a path to a file that exists and can be opened)?


// configuration, if enabled, reconciles the ClusterVersionOperator configuration.
configuration *configuration.ClusterVersionOperatorConfiguration
}
Expand All @@ -209,6 +212,7 @@ func New(
promqlTarget clusterconditions.PromQLTarget,
injectClusterIdIntoPromQL bool,
updateService string,
configFile string,
alwaysEnableCapabilities []configv1.ClusterVersionCapability,
) (*Operator, error) {
eventBroadcaster := record.NewBroadcaster()
Expand Down Expand Up @@ -237,6 +241,7 @@ func New(
availableUpdatesQueue: workqueue.NewTypedRateLimitingQueueWithConfig[any](workqueue.DefaultTypedControllerRateLimiter[any](), workqueue.TypedRateLimitingQueueConfig[any]{Name: "availableupdates"}),
upgradeableQueue: workqueue.NewTypedRateLimitingQueueWithConfig[any](workqueue.DefaultTypedControllerRateLimiter[any](), workqueue.TypedRateLimitingQueueConfig[any]{Name: "upgradeable"}),

configFile: configFile,
hypershift: hypershift,
exclude: exclude,
clusterProfile: clusterProfile,
Expand Down Expand Up @@ -463,7 +468,7 @@ func (optr *Operator) Run(runContext context.Context, shutdownContext context.Co
resultChannel <- asyncResult{name: "available updates"}
}()

if optr.shouldReconcileCVOConfiguration() {
if optr.shouldReconcileCVOConfiguration() && optr.configFile == "" {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Maybe the config file presence check should be in shouldReconcileCVOConfiguration?

resultChannelCount++
go func() {
defer utilruntime.HandleCrash()
Expand All @@ -477,7 +482,20 @@ func (optr *Operator) Run(runContext context.Context, shutdownContext context.Co
resultChannel <- asyncResult{name: "cvo configuration"}
}()
} else {
klog.Infof("The ClusterVersionOperatorConfiguration feature gate is disabled or HyperShift is detected; the configuration sync routine will not run.")
klog.Infof("The ClusterVersionOperatorConfiguration feature gate is disabled, HyperShift is detected or --config-file flag is used; the configuration sync routine will not run.")
}

if optr.enabledFeatureGates.CVOConfiguration() && optr.configFile != "" {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

...and we should have something like shouldWatchCVOConfigurationFile?

resultChannelCount++
go func() {
defer utilruntime.HandleCrash()
wait.UntilWithContext(runContext, func(_ context.Context) {
klog.V(4).Infof("Syncing configuration file")
}, time.Second*15)
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Maybe 15 seconds is too little; however, the logic won't be that extensive.

resultChannel <- asyncResult{name: "cvo configuration file"}
}()
} else {
klog.Infof("The ClusterVersionOperatorConfiguration feature gate is disabled or --config-file flag is not used; the configuration file sync routine will not run.")
}

resultChannelCount++
Expand Down
2 changes: 2 additions & 0 deletions pkg/start/start.go
Original file line number Diff line number Diff line change
Expand Up @@ -64,6 +64,7 @@ type Options struct {
ServingKeyFile string

Kubeconfig string
ConfigFile string
NodeName string
ListenAddr string

Expand Down Expand Up @@ -517,6 +518,7 @@ func (o *Options) NewControllerContext(cb *ClientBuilder) (*Context, error) {
o.PromQLTarget,
o.InjectClusterIdIntoPromQL,
o.UpdateService,
o.ConfigFile,
stringsToCapabilities(o.AlwaysEnableCapabilities),
)
if err != nil {
Expand Down