Skip to content
Merged
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 bootstrap/bootstrap-pod.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ spec:
- "start"
- "--release-image={{.ReleaseImage}}"
- "--enable-auto-update=false"
- "--enable-default-cluster-version=false"
- "--v=4"
- "--kubeconfig=/etc/kubernetes/kubeconfig"
securityContext:
Expand Down
1 change: 1 addition & 0 deletions cmd/start.go
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@ func init() {
cmd.PersistentFlags().StringVar(&opts.Kubeconfig, "kubeconfig", opts.Kubeconfig, "Kubeconfig file to access a remote cluster (testing only)")
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().BoolVar(&opts.EnableDefaultClusterVersion, "enable-default-cluster-version", opts.EnableDefaultClusterVersion, "Allows the operator to create a ClusterVersion object if one does not already exist.")
Copy link
Contributor

Choose a reason for hiding this comment

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

this makes the default false, when the previous behavior was true. So that would be bad in terms of compatibility...

Copy link
Member Author

Choose a reason for hiding this comment

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

this makes the default false, when the previous behavior was true. So that would be bad in terms of compatibility...

Do we care what the default is if we always set this flag explicitly?

Copy link
Contributor

Choose a reason for hiding this comment

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

I know only openshift uses this with explicit flags, so it doesn't matter that much. But I would prefer we don't make these incompatible changes.

I wouldn't block on it this time.

/lgtm

cmd.PersistentFlags().StringVar(&opts.ReleaseImage, "release-image", opts.ReleaseImage, "The Openshift release image url.")
rootCmd.AddCommand(cmd)
}
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@ spec:
- "start"
- "--release-image={{.ReleaseImage}}"
- "--enable-auto-update=false"
- "--enable-default-cluster-version=true"
- "--v=4"
resources:
requests:
Expand Down
19 changes: 17 additions & 2 deletions pkg/cvo/cvo.go
Original file line number Diff line number Diff line change
Expand Up @@ -85,6 +85,10 @@ type Operator struct {
// releaseCreated, if set, is the timestamp of the current update.
releaseCreated time.Time

// enableDefaultClusterVersion allows the operator to create a
// ClusterVersion object if one does not already exist.
enableDefaultClusterVersion bool

client clientset.Interface
kubeClient kubernetes.Interface
eventRecorder record.EventRecorder
Expand Down Expand Up @@ -133,6 +137,7 @@ func New(
nodename string,
namespace, name string,
releaseImage string,
enableDefaultClusterVersion bool,
overridePayloadDir string,
minimumInterval time.Duration,
cvInformer configinformersv1.ClusterVersionInformer,
Expand All @@ -153,6 +158,8 @@ func New(
name: name,
releaseImage: releaseImage,

enableDefaultClusterVersion: enableDefaultClusterVersion,

statusInterval: 15 * time.Second,
minimumUpdateCheckInterval: minimumInterval,
payloadDir: overridePayloadDir,
Expand Down Expand Up @@ -349,14 +356,18 @@ func (optr *Operator) sync(key string) error {

// ensure the cluster version exists, that the object is valid, and that
// all initial conditions are set.
original, changed, err := optr.getOrCreateClusterVersion()
original, changed, err := optr.getOrCreateClusterVersion(optr.enableDefaultClusterVersion)
if err != nil {
return err
}
if changed {
klog.V(4).Infof("Cluster version changed, waiting for newer event")
return nil
}
if original == nil {
klog.V(4).Infof("No ClusterVersion object and defaulting not enabled, waiting for one")
return nil
}

// ensure that the object we do have is valid
errs := validation.ValidateClusterVersion(original)
Expand Down Expand Up @@ -448,7 +459,7 @@ func (optr *Operator) rememberLastUpdate(config *configv1.ClusterVersion) {
optr.lastResourceVersion = i
}

func (optr *Operator) getOrCreateClusterVersion() (*configv1.ClusterVersion, bool, error) {
func (optr *Operator) getOrCreateClusterVersion(enableDefault bool) (*configv1.ClusterVersion, bool, error) {
obj, err := optr.cvLister.Get(optr.name)
if err == nil {
// if we are waiting to see a newer cached version, just exit
Expand All @@ -462,6 +473,10 @@ func (optr *Operator) getOrCreateClusterVersion() (*configv1.ClusterVersion, boo
return nil, false, err
}

if !enableDefault {
return nil, false, nil
}

var upstream configv1.URL
if len(optr.defaultUpstreamServer) > 0 {
u := configv1.URL(optr.defaultUpstreamServer)
Expand Down
11 changes: 6 additions & 5 deletions pkg/cvo/cvo_scenarios_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -69,11 +69,12 @@ func setupCVOTest(payloadDir string) (*Operator, map[string]runtime.Object, *fak
})

o := &Operator{
namespace: "test",
name: "version",
queue: workqueue.NewNamedRateLimitingQueue(workqueue.DefaultControllerRateLimiter(), "cvo-loop-test"),
client: client,
cvLister: &clientCVLister{client: client},
namespace: "test",
name: "version",
enableDefaultClusterVersion: true,
queue: workqueue.NewNamedRateLimitingQueue(workqueue.DefaultControllerRateLimiter(), "cvo-loop-test"),
client: client,
cvLister: &clientCVLister{client: client},
}

dynamicScheme := runtime.NewScheme()
Expand Down
11 changes: 6 additions & 5 deletions pkg/cvo/cvo_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -255,11 +255,12 @@ func TestOperator_sync(t *testing.T) {
{
name: "create version and status",
optr: Operator{
releaseVersion: "4.0.1",
releaseImage: "image/image:v4.0.1",
namespace: "test",
name: "default",
client: fake.NewSimpleClientset(),
releaseVersion: "4.0.1",
releaseImage: "image/image:v4.0.1",
enableDefaultClusterVersion: true,
namespace: "test",
name: "default",
client: fake.NewSimpleClientset(),
},
wantActions: func(t *testing.T, optr *Operator) {
f := optr.client.(*fake.Clientset)
Expand Down
4 changes: 3 additions & 1 deletion pkg/start/start.go
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,8 @@ type Options struct {
NodeName string
ListenAddr string

EnableAutoUpdate bool
EnableAutoUpdate bool
EnableDefaultClusterVersion bool

// for testing only
Name string
Expand Down Expand Up @@ -326,6 +327,7 @@ func (o *Options) NewControllerContext(cb *ClientBuilder) *Context {
o.NodeName,
o.Namespace, o.Name,
o.ReleaseImage,
o.EnableDefaultClusterVersion,
o.PayloadOverride,
resyncPeriod(o.ResyncInterval)(),
cvInformer.Config().V1().ClusterVersions(),
Expand Down
2 changes: 2 additions & 0 deletions pkg/start/start_integration_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -234,6 +234,7 @@ func TestIntegrationCVO_initializeAndUpgrade(t *testing.T) {
options.Namespace = ns
options.Name = ns
options.ListenAddr = ""
options.EnableDefaultClusterVersion = true
options.NodeName = "test-node"
options.ReleaseImage = payloadImage1
options.PayloadOverride = filepath.Join(dir, "ignored")
Expand Down Expand Up @@ -385,6 +386,7 @@ func TestIntegrationCVO_initializeAndHandleError(t *testing.T) {
options.Namespace = ns
options.Name = ns
options.ListenAddr = ""
options.EnableDefaultClusterVersion = true
options.NodeName = "test-node"
options.ReleaseImage = payloadImage1
options.PayloadOverride = filepath.Join(dir, "ignored")
Expand Down