Skip to content

Commit 7a60d73

Browse files
author
Vadim Rutkovsky
committed
Set OPERATOR_IMAGE_VERSION env var for kube-apiserver pods
These are required for featuregate detection to function
1 parent 44d9321 commit 7a60d73

File tree

6 files changed

+16
-9
lines changed

6 files changed

+16
-9
lines changed

bindata/assets/kube-apiserver/pod.yaml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -180,6 +180,8 @@ spec:
180180
valueFrom:
181181
fieldRef:
182182
fieldPath: metadata.namespace
183+
- name: OPERATOR_IMAGE_VERSION
184+
value: "{{ .OperatorImageVersion }}"
183185
image: {{.OperatorImage}}
184186
imagePullPolicy: IfNotPresent
185187
terminationMessagePolicy: FallbackToLogsOnError

pkg/cmd/certregenerationcontroller/cmd.go

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -112,7 +112,6 @@ func (o *Options) Run(ctx context.Context, clock clock.Clock) error {
112112
// We can't start informers until after the resources have been requested. Now is the time.
113113
kubeAPIServerInformersForNamespaces.Start(ctx.Done())
114114
dynamicInformers.Start(ctx.Done())
115-
configInformers.Start(ctx.Done())
116115

117116
desiredVersion := status.VersionForOperatorFromEnv()
118117
missingVersion := "0.0.1-snapshot"
@@ -122,9 +121,8 @@ func (o *Options) Run(ctx context.Context, clock clock.Clock) error {
122121
o.controllerContext.EventRecorder,
123122
)
124123

125-
go func() {
126-
featureGateAccessor.Run(ctx)
127-
}()
124+
go configInformers.Start(ctx.Done())
125+
go featureGateAccessor.Run(ctx)
128126

129127
select {
130128
case <-featureGateAccessor.InitialFeatureGatesObserved():

pkg/operator/certrotationcontroller/certrotationcontroller.go

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -138,6 +138,7 @@ func newCertRotationController(
138138
monthPeriod = 2 * time.Hour
139139
yearPeriod = 3 * time.Hour
140140
tenMonthPeriod = 150 * time.Minute
141+
klog.Infof("Setting monthPeriod to %v, yearPeriod to %v, tenMonthPeriod to %v", monthPeriod, yearPeriod, tenMonthPeriod)
141142
}
142143

143144
certRotator := certrotation.NewCertRotationController(

pkg/operator/starter.go

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -263,6 +263,7 @@ func RunOperator(ctx context.Context, controllerContext *controllercmd.Controlle
263263
targetConfigReconciler := targetconfigcontroller.NewTargetConfigController(
264264
os.Getenv("IMAGE"),
265265
os.Getenv("OPERATOR_IMAGE"),
266+
os.Getenv("OPERATOR_IMAGE_VERSION"),
266267
operatorClient,
267268
kubeInformersForNamespaces.InformersFor(operatorclient.TargetNamespace),
268269
kubeInformersForNamespaces,

pkg/operator/targetconfigcontroller/targetconfigcontroller.go

Lines changed: 9 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -48,6 +48,7 @@ const (
4848
type TargetConfigController struct {
4949
targetImagePullSpec string
5050
operatorImagePullSpec string
51+
operatorImageVersion string
5152

5253
operatorClient v1helpers.StaticPodOperatorClient
5354

@@ -59,7 +60,7 @@ type TargetConfigController struct {
5960
}
6061

6162
func NewTargetConfigController(
62-
targetImagePullSpec, operatorImagePullSpec string,
63+
targetImagePullSpec, operatorImagePullSpec, operatorImageVersion string,
6364
operatorClient v1helpers.StaticPodOperatorClient,
6465
kubeInformersForOpenshiftKubeAPIServerNamespace informers.SharedInformerFactory,
6566
kubeInformersForNamespaces v1helpers.KubeInformersForNamespaces,
@@ -71,6 +72,7 @@ func NewTargetConfigController(
7172
c := &TargetConfigController{
7273
targetImagePullSpec: targetImagePullSpec,
7374
operatorImagePullSpec: operatorImagePullSpec,
75+
operatorImageVersion: operatorImageVersion,
7476
operatorClient: operatorClient,
7577
kubeClient: kubeClient,
7678
configMapLister: kubeInformersForNamespaces.ConfigMapLister(),
@@ -215,7 +217,7 @@ func createTargetConfig(ctx context.Context, c TargetConfigController, recorder
215217
if err != nil {
216218
errors = append(errors, fmt.Errorf("%q: %v", "configmap/config", err))
217219
}
218-
_, _, err = managePods(ctx, c.kubeClient.CoreV1(), c.isStartupMonitorEnabledFn, recorder, operatorSpec, c.targetImagePullSpec, c.operatorImagePullSpec)
220+
_, _, err = managePods(ctx, c.kubeClient.CoreV1(), c.isStartupMonitorEnabledFn, recorder, operatorSpec, c.targetImagePullSpec, c.operatorImagePullSpec, c.operatorImageVersion)
219221
if err != nil {
220222
errors = append(errors, fmt.Errorf("%q: %v", "configmap/kube-apiserver-pod", err))
221223
}
@@ -293,8 +295,8 @@ func manageKubeAPIServerConfig(ctx context.Context, client coreclientv1.ConfigMa
293295
return resourceapply.ApplyConfigMap(ctx, client, recorder, requiredConfigMap)
294296
}
295297

296-
func managePods(ctx context.Context, client coreclientv1.ConfigMapsGetter, isStartupMonitorEnabledFn func() (bool, error), recorder events.Recorder, operatorSpec *operatorv1.StaticPodOperatorSpec, imagePullSpec, operatorImagePullSpec string) (*corev1.ConfigMap, bool, error) {
297-
appliedPodTemplate, err := manageTemplate(string(bindata.MustAsset("assets/kube-apiserver/pod.yaml")), imagePullSpec, operatorImagePullSpec, operatorSpec)
298+
func managePods(ctx context.Context, client coreclientv1.ConfigMapsGetter, isStartupMonitorEnabledFn func() (bool, error), recorder events.Recorder, operatorSpec *operatorv1.StaticPodOperatorSpec, imagePullSpec, operatorImagePullSpec, operatorImageVersion string) (*corev1.ConfigMap, bool, error) {
299+
appliedPodTemplate, err := manageTemplate(string(bindata.MustAsset("assets/kube-apiserver/pod.yaml")), imagePullSpec, operatorImagePullSpec, operatorImageVersion, operatorSpec)
298300
if err != nil {
299301
return nil, false, err
300302
}
@@ -547,6 +549,7 @@ func gogcFromConfig(config map[string]interface{}) (int, error) {
547549
type kasTemplate struct {
548550
Image string
549551
OperatorImage string
552+
OperatorImageVersion string
550553
Verbosity string
551554
GracefulTerminationDuration int
552555
SetupContainerTimeoutDuration int
@@ -567,7 +570,7 @@ func effectiveConfiguration(spec *operatorv1.StaticPodOperatorSpec) (map[string]
567570
return effectiveConfig, nil
568571
}
569572

570-
func manageTemplate(rawTemplate string, imagePullSpec string, operatorImagePullSpec string, operatorSpec *operatorv1.StaticPodOperatorSpec) (string, error) {
573+
func manageTemplate(rawTemplate string, imagePullSpec string, operatorImagePullSpec, operatorImageVersion string, operatorSpec *operatorv1.StaticPodOperatorSpec) (string, error) {
571574
var verbosity string
572575
switch operatorSpec.LogLevel {
573576
case operatorv1.Normal:
@@ -600,6 +603,7 @@ func manageTemplate(rawTemplate string, imagePullSpec string, operatorImagePullS
600603
tmplVal := kasTemplate{
601604
Image: imagePullSpec,
602605
OperatorImage: operatorImagePullSpec,
606+
OperatorImageVersion: operatorImageVersion,
603607
Verbosity: verbosity,
604608
GracefulTerminationDuration: gracefulTerminationDuration,
605609
// 80s for minimum-termination-duration (10s port wait, 65s to let pending requests finish after port has been freed) + 5s extra cri-o's graceful termination period

pkg/operator/targetconfigcontroller/targetconfigcontroller_test.go

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -233,6 +233,7 @@ func TestManageTemplate(t *testing.T) {
233233
scenario.template,
234234
"CaptainAmerica",
235235
"Piper",
236+
"v1",
236237
scenario.operatorSpec)
237238

238239
// validate

0 commit comments

Comments
 (0)