@@ -25,7 +25,6 @@ import (
25
25
"k8s.io/apimachinery/pkg/runtime/schema"
26
26
"k8s.io/apimachinery/pkg/util/wait"
27
27
flowcontrolbootstrap "k8s.io/apiserver/pkg/apis/flowcontrol/bootstrap"
28
- "k8s.io/apiserver/pkg/features"
29
28
"k8s.io/apiserver/pkg/registry/generic"
30
29
"k8s.io/apiserver/pkg/registry/rest"
31
30
genericapiserver "k8s.io/apiserver/pkg/server"
@@ -109,7 +108,7 @@ func (p RESTStorageProvider) GroupName() string {
109
108
// PostStartHook returns the hook func that launches the config provider
110
109
func (p RESTStorageProvider ) PostStartHook () (string , genericapiserver.PostStartHookFunc , error ) {
111
110
bce := & bootstrapConfigurationEnsurer {
112
- v134Config : p .FeatureGate . Enabled ( features . APFv134Config ) ,
111
+ featureGate : p .FeatureGate ,
113
112
informersSynced : []cache.InformerSynced {
114
113
p .InformerFactory .Flowcontrol ().V1 ().PriorityLevelConfigurations ().Informer ().HasSynced ,
115
114
p .InformerFactory .Flowcontrol ().V1 ().FlowSchemas ().Informer ().HasSynced ,
@@ -121,7 +120,7 @@ func (p RESTStorageProvider) PostStartHook() (string, genericapiserver.PostStart
121
120
}
122
121
123
122
type bootstrapConfigurationEnsurer struct {
124
- v134Config bool
123
+ featureGate featuregate. FeatureGate
125
124
informersSynced []cache.InformerSynced
126
125
fsLister flowcontrollisters.FlowSchemaLister
127
126
plcLister flowcontrollisters.PriorityLevelConfigurationLister
@@ -145,7 +144,7 @@ func (bce *bootstrapConfigurationEnsurer) ensureAPFBootstrapConfiguration(hookCo
145
144
146
145
err = wait .PollUntilContextCancel (ctx , time .Second , true ,
147
146
func (context.Context ) (bool , error ) {
148
- if err := ensure (ctx , bce .v134Config , clientset , bce .fsLister , bce .plcLister ); err != nil {
147
+ if err := ensure (ctx , bce .featureGate , clientset , bce .fsLister , bce .plcLister ); err != nil {
149
148
klog .ErrorS (err , "APF bootstrap ensurer ran into error, will retry later" )
150
149
return false , nil
151
150
}
@@ -165,7 +164,7 @@ func (bce *bootstrapConfigurationEnsurer) ensureAPFBootstrapConfiguration(hookCo
165
164
go func () {
166
165
_ = wait .PollUntilContextCancel (hookContext , time .Minute , true ,
167
166
func (ctx context.Context ) (bool , error ) {
168
- if err := ensure (ctx , bce .v134Config , clientset , bce .fsLister , bce .plcLister ); err != nil {
167
+ if err := ensure (ctx , bce .featureGate , clientset , bce .fsLister , bce .plcLister ); err != nil {
169
168
klog .ErrorS (err , "APF bootstrap ensurer ran into error, will retry later" )
170
169
}
171
170
// always auto update both suggested and mandatory configuration
@@ -177,29 +176,29 @@ func (bce *bootstrapConfigurationEnsurer) ensureAPFBootstrapConfiguration(hookCo
177
176
return nil
178
177
}
179
178
180
- func ensure (ctx context.Context , v134Config bool , clientset flowcontrolclient.FlowcontrolV1Interface , fsLister flowcontrollisters.FlowSchemaLister , plcLister flowcontrollisters.PriorityLevelConfigurationLister ) error {
179
+ func ensure (ctx context.Context , featureGate featuregate. FeatureGate , clientset flowcontrolclient.FlowcontrolV1Interface , fsLister flowcontrollisters.FlowSchemaLister , plcLister flowcontrollisters.PriorityLevelConfigurationLister ) error {
181
180
182
- if err := ensureSuggestedConfiguration (ctx , v134Config , clientset , fsLister , plcLister ); err != nil {
181
+ if err := ensureSuggestedConfiguration (ctx , featureGate , clientset , fsLister , plcLister ); err != nil {
183
182
// We should not attempt creation of mandatory objects if ensuring the suggested
184
183
// configuration resulted in an error.
185
184
// This only happens when the stop channel is closed.
186
185
return fmt .Errorf ("failed ensuring suggested settings - %w" , err )
187
186
}
188
187
189
- if err := ensureMandatoryConfiguration (ctx , v134Config , clientset , fsLister , plcLister ); err != nil {
188
+ if err := ensureMandatoryConfiguration (ctx , featureGate , clientset , fsLister , plcLister ); err != nil {
190
189
return fmt .Errorf ("failed ensuring mandatory settings - %w" , err )
191
190
}
192
191
193
- if err := removeDanglingBootstrapConfiguration (ctx , v134Config , clientset , fsLister , plcLister ); err != nil {
192
+ if err := removeDanglingBootstrapConfiguration (ctx , featureGate , clientset , fsLister , plcLister ); err != nil {
194
193
return fmt .Errorf ("failed to delete removed settings - %w" , err )
195
194
}
196
195
197
196
return nil
198
197
}
199
198
200
- func ensureSuggestedConfiguration (ctx context.Context , v134Config bool , clientset flowcontrolclient.FlowcontrolV1Interface , fsLister flowcontrollisters.FlowSchemaLister , plcLister flowcontrollisters.PriorityLevelConfigurationLister ) error {
199
+ func ensureSuggestedConfiguration (ctx context.Context , featureGate featuregate. FeatureGate , clientset flowcontrolclient.FlowcontrolV1Interface , fsLister flowcontrollisters.FlowSchemaLister , plcLister flowcontrollisters.PriorityLevelConfigurationLister ) error {
201
200
plcOps := ensurer .NewPriorityLevelConfigurationOps (clientset .PriorityLevelConfigurations (), plcLister )
202
- config := flowcontrolbootstrap .GetV1ConfigCollection (v134Config ).Suggested
201
+ config := flowcontrolbootstrap .GetV1ConfigCollection (featureGate ).Suggested
203
202
if err := ensurer .EnsureConfigurations (ctx , plcOps , config .PriorityLevelConfigurations , ensurer .NewSuggestedEnsureStrategy [* flowcontrolv1.PriorityLevelConfiguration ]()); err != nil {
204
203
return err
205
204
}
@@ -208,9 +207,9 @@ func ensureSuggestedConfiguration(ctx context.Context, v134Config bool, clientse
208
207
return ensurer .EnsureConfigurations (ctx , fsOps , config .FlowSchemas , ensurer .NewSuggestedEnsureStrategy [* flowcontrolv1.FlowSchema ]())
209
208
}
210
209
211
- func ensureMandatoryConfiguration (ctx context.Context , v134Config bool , clientset flowcontrolclient.FlowcontrolV1Interface , fsLister flowcontrollisters.FlowSchemaLister , plcLister flowcontrollisters.PriorityLevelConfigurationLister ) error {
210
+ func ensureMandatoryConfiguration (ctx context.Context , featureGate featuregate. FeatureGate , clientset flowcontrolclient.FlowcontrolV1Interface , fsLister flowcontrollisters.FlowSchemaLister , plcLister flowcontrollisters.PriorityLevelConfigurationLister ) error {
212
211
plcOps := ensurer .NewPriorityLevelConfigurationOps (clientset .PriorityLevelConfigurations (), plcLister )
213
- config := flowcontrolbootstrap .GetV1ConfigCollection (v134Config ).Mandatory
212
+ config := flowcontrolbootstrap .GetV1ConfigCollection (featureGate ).Mandatory
214
213
if err := ensurer .EnsureConfigurations (ctx , plcOps , config .PriorityLevelConfigurations , ensurer .NewMandatoryEnsureStrategy [* flowcontrolv1.PriorityLevelConfiguration ]()); err != nil {
215
214
return err
216
215
}
@@ -219,22 +218,22 @@ func ensureMandatoryConfiguration(ctx context.Context, v134Config bool, clientse
219
218
return ensurer .EnsureConfigurations (ctx , fsOps , config .FlowSchemas , ensurer .NewMandatoryEnsureStrategy [* flowcontrolv1.FlowSchema ]())
220
219
}
221
220
222
- func removeDanglingBootstrapConfiguration (ctx context.Context , v134Config bool , clientset flowcontrolclient.FlowcontrolV1Interface , fsLister flowcontrollisters.FlowSchemaLister , plcLister flowcontrollisters.PriorityLevelConfigurationLister ) error {
223
- if err := removeDanglingBootstrapFlowSchema (ctx , v134Config , clientset , fsLister ); err != nil {
221
+ func removeDanglingBootstrapConfiguration (ctx context.Context , featureGate featuregate. FeatureGate , clientset flowcontrolclient.FlowcontrolV1Interface , fsLister flowcontrollisters.FlowSchemaLister , plcLister flowcontrollisters.PriorityLevelConfigurationLister ) error {
222
+ if err := removeDanglingBootstrapFlowSchema (ctx , featureGate , clientset , fsLister ); err != nil {
224
223
return err
225
224
}
226
225
227
- return removeDanglingBootstrapPriorityLevel (ctx , v134Config , clientset , plcLister )
226
+ return removeDanglingBootstrapPriorityLevel (ctx , featureGate , clientset , plcLister )
228
227
}
229
228
230
- func removeDanglingBootstrapFlowSchema (ctx context.Context , v134Config bool , clientset flowcontrolclient.FlowcontrolV1Interface , fsLister flowcontrollisters.FlowSchemaLister ) error {
229
+ func removeDanglingBootstrapFlowSchema (ctx context.Context , featureGate featuregate. FeatureGate , clientset flowcontrolclient.FlowcontrolV1Interface , fsLister flowcontrollisters.FlowSchemaLister ) error {
231
230
fsOps := ensurer .NewFlowSchemaOps (clientset .FlowSchemas (), fsLister )
232
- return ensurer .RemoveUnwantedObjects (ctx , fsOps , flowcontrolbootstrap .GetFlowSchemas (v134Config ))
231
+ return ensurer .RemoveUnwantedObjects (ctx , fsOps , flowcontrolbootstrap .GetFlowSchemas (featureGate ))
233
232
}
234
233
235
- func removeDanglingBootstrapPriorityLevel (ctx context.Context , v134Config bool , clientset flowcontrolclient.FlowcontrolV1Interface , plcLister flowcontrollisters.PriorityLevelConfigurationLister ) error {
234
+ func removeDanglingBootstrapPriorityLevel (ctx context.Context , featureGate featuregate. FeatureGate , clientset flowcontrolclient.FlowcontrolV1Interface , plcLister flowcontrollisters.PriorityLevelConfigurationLister ) error {
236
235
plcOps := ensurer .NewPriorityLevelConfigurationOps (clientset .PriorityLevelConfigurations (), plcLister )
237
- return ensurer .RemoveUnwantedObjects (ctx , plcOps , flowcontrolbootstrap .GetPrioritylevelConfigurations (v134Config ))
236
+ return ensurer .RemoveUnwantedObjects (ctx , plcOps , flowcontrolbootstrap .GetPrioritylevelConfigurations (featureGate ))
238
237
}
239
238
240
239
// contextFromChannelAndMaxWaitDuration returns a Context that is bound to the
0 commit comments