@@ -66,6 +66,7 @@ func (s *Operator) Run(ctx context.Context, controller *controllercmd.Controller
66
66
if err != nil {
67
67
return err
68
68
}
69
+ configInformers := configv1informers .NewSharedInformerFactory (configClient , 10 * time .Minute )
69
70
70
71
operatorClient , err := operatorv1client .NewForConfig (controller .KubeConfig )
71
72
if err != nil {
@@ -83,52 +84,45 @@ func (s *Operator) Run(ctx context.Context, controller *controllercmd.Controller
83
84
return err
84
85
}
85
86
86
- desiredVersion := config . OperatorReleaseVersion
87
+ desiredVersion := os . Getenv ( "RELEASE_VERSION" )
87
88
missingVersion := "0.0.1-snapshot"
88
89
89
90
// By default, this will exit(0) the process if the featuregates ever change to a different set of values.
90
91
featureGateAccessor := featuregates .NewFeatureGateAccess (
91
92
desiredVersion , missingVersion ,
92
93
configInformers .Config ().V1 ().ClusterVersions (), configInformers .Config ().V1 ().FeatureGates (),
93
- eventRecorder ,
94
+ controller . EventRecorder ,
94
95
)
95
96
go featureGateAccessor .Run (ctx )
96
- go configInformers .Start (config . Stop )
97
+ go configInformers .Start (ctx . Done () )
97
98
98
99
select {
99
100
case <- featureGateAccessor .InitialFeatureGatesObserved ():
100
101
featureGates , _ := featureGateAccessor .CurrentFeatureGates ()
101
- log . Info ("FeatureGates initialized" , "knownFeatures " , featureGates .KnownFeatures ())
102
+ klog . Infof ("FeatureGates initialized: knownFeatureGates=%v " , featureGates .KnownFeatures ())
102
103
case <- time .After (1 * time .Minute ):
103
- log . Error ( nil , "timed out waiting for FeatureGate detection" )
104
- return nil , fmt .Errorf ("timed out waiting for FeatureGate detection" )
104
+ klog . Errorf ( "timed out waiting for FeatureGate detection" )
105
+ return fmt .Errorf ("timed out waiting for FeatureGate detection" )
105
106
}
106
107
107
108
featureGates , err := featureGateAccessor .CurrentFeatureGates ()
108
109
if err != nil {
109
- return nil , err
110
+ return err
110
111
}
111
- // example of future featuregate read and usage to set a variable to pass to a controller
112
- gatewayAPIEnabled := featureGates .Enabled (configv1 .FeatureGateGatewayAPI )
112
+ insightsConfigAPIEnabled := featureGates .Enabled (v1 .FeatureGateInsightsConfigAPI )
113
113
114
114
// ensure the insight snapshot directory exists
115
115
if _ , err = os .Stat (s .StoragePath ); err != nil && os .IsNotExist (err ) {
116
116
if err = os .MkdirAll (s .StoragePath , 0777 ); err != nil {
117
117
return fmt .Errorf ("can't create --path: %v" , err )
118
118
}
119
119
}
120
- tpEnabled , err := isTechPreviewEnabled (ctx , configClient )
121
- if err != nil {
122
- klog .Error ("can't read cluster feature gates: %v" , err )
123
- }
124
120
var apiConfigObserver configobserver.APIConfigObserver
125
- if tpEnabled {
126
- configInformers := configv1informers .NewSharedInformerFactory (configClient , 10 * time .Minute )
121
+ if insightsConfigAPIEnabled {
127
122
apiConfigObserver , err = configobserver .NewAPIConfigObserver (gatherKubeConfig , controller .EventRecorder , configInformers )
128
123
if err != nil {
129
124
return err
130
125
}
131
- configInformers .Start (ctx .Done ())
132
126
go apiConfigObserver .Run (ctx , 1 )
133
127
}
134
128
0 commit comments