Description
While developing a new in-tree feature, I need to add integration tests which conditionally enable/disable my feature. I've added the gate to the 'versioned feature gates' file, which seems to work ok. However, my feature gate's configuration is read upon initialisation of the apiserver (it's read by an admission plugin). This means I must set this feature gate to be enabled prior to calling StartTestServerOrDie
(or at least, prior to this function actually running/starting the apiserver startup functions).
This feature is considered 'pre-alpha' in 1.31, as it'd be only become alpha in 1.32 (assuming it's merged etc.). This means if I attempt to set this flag to 'true' without also changing the 'emulation version', I receive an error that the feature cannot be enabled at this version (1.31) as it is PreAlpha.
So, I have updated my call to StartTestServer to set the BinaryVersion in the instance options to '1.32':
// Force to run in 1.32 mode as we are testing a feature that only exists (in alpha) from 1.32 onwards.
opts := kubeapiservertesting.NewDefaultTestServerOptions()
opts.BinaryVersion = "1.32"
server := kubeapiservertesting.StartTestServerOrDie(t, opts, framework.DefaultTestServerFlags(), framework.SharedEtcd())
However, I still need to set the feature gate itself to enabled, as it's disabled by default (it's an alpha feature). This presents a chicken-egg problem for me:
If I add featuregatetesting.SetFeatureGateDuringTest(t, utilfeature.DefaultFeatureGate, features.SetPodTopologyLabels, true)
before StartTestServerOrDie
, the call to set the emulation version to 1.32 has not happened yet (it is within StartTestServerOrDie).
If I set the flag after, my feature flag value will have already been read by the admission plugin and I won't get the behaviour I need.
The only alternative I can think of here is to set feature flags using the --feature-flags
argument passed in InstanceOptions, but this is a departure from how we'd have done this prior to the introduction of versioned feature gates, so I wanted to gather some feedback on how we're supposed to enable pre-alpha feature flags that are required during apiserver initialisation.
/area testing
/sig architecture