Skip to content

Commit 78857e5

Browse files
committed
fix: address review comments
Signed-off-by: Jayapriya Pai <[email protected]>
1 parent 4352039 commit 78857e5

File tree

1 file changed

+12
-16
lines changed

1 file changed

+12
-16
lines changed

pkg/operator/operator.go

+12-16
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,6 @@ import (
1818
"context"
1919
"crypto/x509/pkix"
2020
"fmt"
21-
"os"
2221
"strings"
2322
"time"
2423

@@ -220,7 +219,7 @@ func New(
220219
return nil, err
221220
}
222221

223-
c, err := client.NewForConfig(config, version, namespace, namespaceUserWorkload, client.KubernetesClient(kclient), client.EventRecorder(eventRecorder))
222+
c, err := client.NewForConfig(config, version, namespace, namespaceUserWorkload, client.KubernetesClient(kclient), client.OpenshiftConfigClient(configClient), client.EventRecorder(eventRecorder))
224223
if err != nil {
225224
return nil, err
226225
}
@@ -414,14 +413,12 @@ func New(
414413

415414
configInformers := configv1informers.NewSharedInformerFactory(configClient, 10*time.Minute)
416415
missingVersion := "0.0.1-snapshot"
417-
desiredVersion := missingVersion
418-
if envVersion, exists := os.LookupEnv("RELEASE_VERSION"); exists {
419-
desiredVersion = envVersion
420-
}
421416

422-
// By default, this will exit(0) if the featuregates change
417+
// By default when the enabled/disabled list of featuregates changes,
418+
// os.Exit is called which will trigger a restart of the container and
419+
// the new container will get the updated value.
423420
featureGateAccessor := featuregates.NewFeatureGateAccess(
424-
desiredVersion, missingVersion,
421+
version, missingVersion,
425422
configInformers.Config().V1().ClusterVersions(),
426423
configInformers.Config().V1().FeatureGates(),
427424
eventRecorder,
@@ -431,19 +428,18 @@ func New(
431428

432429
select {
433430
case <-featureGateAccessor.InitialFeatureGatesObserved():
434-
featureGates, _ := featureGateAccessor.CurrentFeatureGates()
435-
klog.Infof("FeatureGates initialized: %v", featureGates.KnownFeatures())
431+
featureGates, err := featureGateAccessor.CurrentFeatureGates()
432+
if err != nil {
433+
return nil, err
434+
}
435+
o.metricsServerEnabled = featureGates.Enabled(configv1.FeatureGateMetricsServer)
436436
case <-time.After(1 * time.Minute):
437-
klog.Errorf("timed out waiting for FeatureGate detection")
438437
return nil, fmt.Errorf("timed out waiting for FeatureGate detection")
439438
}
440439

441-
featureGates, err := featureGateAccessor.CurrentFeatureGates()
442-
if err != nil {
443-
return nil, err
440+
if o.metricsServerEnabled {
441+
klog.Info("Metrics Server enabled")
444442
}
445-
// read featuregate read and usage to set a variable to pass to a controller
446-
o.metricsServerEnabled = featureGates.Enabled(configv1.FeatureGateMetricsServer)
447443

448444
// csrController runs a controller that requests a client TLS certificate
449445
// for Prometheus k8s. This certificate is used to authenticate against the

0 commit comments

Comments
 (0)