Skip to content

Commit ef5c2ef

Browse files
Updates operator to pass operand feature gates
This updates the operator to pass the feature gates required by the operands.
1 parent 622bc69 commit ef5c2ef

File tree

3 files changed

+52
-56
lines changed

3 files changed

+52
-56
lines changed

pkg/operator/operator.go

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -468,11 +468,14 @@ func (optr *Operator) maoConfigFromInfrastructure() (*OperatorConfig, error) {
468468
mhcImage = ""
469469
}
470470

471-
// Given we only support the MachineAPIMigration featuregate being passed by
472-
// flags, it shold be the only thing populated our map (and therefore passed
471+
// Given we only support a handful of featuregates being passed by
472+
// flags, we selectively populate the map (and therefore passed
473473
// as args)
474474
features := map[string]bool{
475-
string(apifeatures.FeatureGateMachineAPIMigration): featureGates.Enabled(apifeatures.FeatureGateMachineAPIMigration),
475+
string(apifeatures.FeatureGateMachineAPIMigration): featureGates.Enabled(apifeatures.FeatureGateMachineAPIMigration),
476+
string(apifeatures.FeatureGateVSphereStaticIPs): featureGates.Enabled(apifeatures.FeatureGateVSphereStaticIPs),
477+
string(apifeatures.FeatureGateGCPLabelsTags): featureGates.Enabled(apifeatures.FeatureGateGCPLabelsTags),
478+
string(apifeatures.FeatureGateAzureWorkloadIdentity): featureGates.Enabled(apifeatures.FeatureGateAzureWorkloadIdentity),
476479
}
477480
if features[string(apifeatures.FeatureGateMachineAPIMigration)] {
478481
klog.V(2).Info("Enabling MachineAPIMigration for provider controller and machinesets")

pkg/operator/operator_test.go

Lines changed: 43 additions & 53 deletions
Original file line numberDiff line numberDiff line change
@@ -39,6 +39,22 @@ const (
3939
releaseVersion = "0.0.0.test-unit"
4040
)
4141

42+
var (
43+
enabledFeatureGates = []openshiftv1.FeatureGateAttributes{
44+
{Name: apifeatures.FeatureGateMachineAPIMigration},
45+
{Name: apifeatures.FeatureGateVSphereStaticIPs},
46+
{Name: apifeatures.FeatureGateGCPLabelsTags},
47+
{Name: apifeatures.FeatureGateAzureWorkloadIdentity},
48+
}
49+
50+
enabledFeatureMap = map[string]bool{
51+
"MachineAPIMigration": true,
52+
"GCPLabelsTags": true,
53+
"AzureWorkloadIdentity": true,
54+
"VSphereStaticIPs": true,
55+
}
56+
)
57+
4258
func newFakeOperator(kubeObjects, osObjects, machineObjects []runtime.Object, imagesFile string, fg *openshiftv1.FeatureGate, stopCh <-chan struct{}) (*Operator, error) {
4359
kubeClient := fakekube.NewSimpleClientset(kubeObjects...)
4460
osClient := fakeos.NewSimpleClientset(osObjects...)
@@ -61,7 +77,7 @@ func newFakeOperator(kubeObjects, osObjects, machineObjects []runtime.Object, im
6177
FeatureGates: []openshiftv1.FeatureGateDetails{
6278
{
6379
Version: "",
64-
Enabled: []openshiftv1.FeatureGateAttributes{{Name: apifeatures.FeatureGateMachineAPIMigration}},
80+
Enabled: enabledFeatureGates,
6581
Disabled: []openshiftv1.FeatureGateAttributes{{Name: apifeatures.FeatureGateMachineAPIOperatorDisableMachineHealthCheckController}},
6682
},
6783
},
@@ -360,7 +376,7 @@ func TestMAOConfigFromInfrastructure(t *testing.T) {
360376
FeatureGates: []openshiftv1.FeatureGateDetails{
361377
{
362378
Version: "",
363-
Enabled: []openshiftv1.FeatureGateAttributes{{Name: apifeatures.FeatureGateMachineAPIMigration}},
379+
Enabled: enabledFeatureGates,
364380
Disabled: []openshiftv1.FeatureGateAttributes{{Name: apifeatures.FeatureGateMachineAPIOperatorDisableMachineHealthCheckController}},
365381
},
366382
},
@@ -379,9 +395,7 @@ func TestMAOConfigFromInfrastructure(t *testing.T) {
379395
KubeRBACProxy: images.KubeRBACProxy,
380396
},
381397
PlatformType: openshiftv1.AWSPlatformType,
382-
Features: map[string]bool{
383-
"MachineAPIMigration": true,
384-
},
398+
Features: enabledFeatureMap,
385399
},
386400
},
387401
{
@@ -396,7 +410,7 @@ func TestMAOConfigFromInfrastructure(t *testing.T) {
396410
FeatureGates: []openshiftv1.FeatureGateDetails{
397411
{
398412
Version: "",
399-
Enabled: []openshiftv1.FeatureGateAttributes{{Name: apifeatures.FeatureGateMachineAPIMigration}},
413+
Enabled: enabledFeatureGates,
400414
Disabled: []openshiftv1.FeatureGateAttributes{{Name: apifeatures.FeatureGateMachineAPIOperatorDisableMachineHealthCheckController}},
401415
},
402416
},
@@ -415,9 +429,7 @@ func TestMAOConfigFromInfrastructure(t *testing.T) {
415429
KubeRBACProxy: images.KubeRBACProxy,
416430
},
417431
PlatformType: openshiftv1.LibvirtPlatformType,
418-
Features: map[string]bool{
419-
"MachineAPIMigration": true,
420-
},
432+
Features: enabledFeatureMap,
421433
},
422434
},
423435
{
@@ -432,7 +444,7 @@ func TestMAOConfigFromInfrastructure(t *testing.T) {
432444
FeatureGates: []openshiftv1.FeatureGateDetails{
433445
{
434446
Version: "",
435-
Enabled: []openshiftv1.FeatureGateAttributes{{Name: apifeatures.FeatureGateMachineAPIMigration}},
447+
Enabled: enabledFeatureGates,
436448
Disabled: []openshiftv1.FeatureGateAttributes{{Name: apifeatures.FeatureGateMachineAPIOperatorDisableMachineHealthCheckController}},
437449
},
438450
},
@@ -451,9 +463,7 @@ func TestMAOConfigFromInfrastructure(t *testing.T) {
451463
KubeRBACProxy: images.KubeRBACProxy,
452464
},
453465
PlatformType: openshiftv1.OpenStackPlatformType,
454-
Features: map[string]bool{
455-
"MachineAPIMigration": true,
456-
},
466+
Features: enabledFeatureMap,
457467
},
458468
},
459469
{
@@ -468,7 +478,7 @@ func TestMAOConfigFromInfrastructure(t *testing.T) {
468478
FeatureGates: []openshiftv1.FeatureGateDetails{
469479
{
470480
Version: "",
471-
Enabled: []openshiftv1.FeatureGateAttributes{{Name: apifeatures.FeatureGateMachineAPIMigration}},
481+
Enabled: enabledFeatureGates,
472482
Disabled: []openshiftv1.FeatureGateAttributes{{Name: apifeatures.FeatureGateMachineAPIOperatorDisableMachineHealthCheckController}},
473483
},
474484
},
@@ -487,9 +497,7 @@ func TestMAOConfigFromInfrastructure(t *testing.T) {
487497
KubeRBACProxy: images.KubeRBACProxy,
488498
},
489499
PlatformType: openshiftv1.AzurePlatformType,
490-
Features: map[string]bool{
491-
"MachineAPIMigration": true,
492-
},
500+
Features: enabledFeatureMap,
493501
},
494502
},
495503
{
@@ -504,7 +512,7 @@ func TestMAOConfigFromInfrastructure(t *testing.T) {
504512
FeatureGates: []openshiftv1.FeatureGateDetails{
505513
{
506514
Version: "",
507-
Enabled: []openshiftv1.FeatureGateAttributes{{Name: apifeatures.FeatureGateMachineAPIMigration}},
515+
Enabled: enabledFeatureGates,
508516
Disabled: []openshiftv1.FeatureGateAttributes{{Name: apifeatures.FeatureGateMachineAPIOperatorDisableMachineHealthCheckController}},
509517
},
510518
},
@@ -523,9 +531,7 @@ func TestMAOConfigFromInfrastructure(t *testing.T) {
523531
KubeRBACProxy: images.KubeRBACProxy,
524532
},
525533
PlatformType: openshiftv1.BareMetalPlatformType,
526-
Features: map[string]bool{
527-
"MachineAPIMigration": true,
528-
},
534+
Features: enabledFeatureMap,
529535
},
530536
},
531537
{
@@ -540,7 +546,7 @@ func TestMAOConfigFromInfrastructure(t *testing.T) {
540546
FeatureGates: []openshiftv1.FeatureGateDetails{
541547
{
542548
Version: "",
543-
Enabled: []openshiftv1.FeatureGateAttributes{{Name: apifeatures.FeatureGateMachineAPIMigration}},
549+
Enabled: enabledFeatureGates,
544550
Disabled: []openshiftv1.FeatureGateAttributes{{Name: apifeatures.FeatureGateMachineAPIOperatorDisableMachineHealthCheckController}},
545551
},
546552
},
@@ -559,9 +565,7 @@ func TestMAOConfigFromInfrastructure(t *testing.T) {
559565
KubeRBACProxy: images.KubeRBACProxy,
560566
},
561567
PlatformType: openshiftv1.GCPPlatformType,
562-
Features: map[string]bool{
563-
"MachineAPIMigration": true,
564-
},
568+
Features: enabledFeatureMap,
565569
},
566570
},
567571
{
@@ -576,7 +580,7 @@ func TestMAOConfigFromInfrastructure(t *testing.T) {
576580
FeatureGates: []openshiftv1.FeatureGateDetails{
577581
{
578582
Version: "",
579-
Enabled: []openshiftv1.FeatureGateAttributes{{Name: apifeatures.FeatureGateMachineAPIMigration}},
583+
Enabled: enabledFeatureGates,
580584
Disabled: []openshiftv1.FeatureGateAttributes{{Name: apifeatures.FeatureGateMachineAPIOperatorDisableMachineHealthCheckController}},
581585
},
582586
},
@@ -595,9 +599,7 @@ func TestMAOConfigFromInfrastructure(t *testing.T) {
595599
KubeRBACProxy: images.KubeRBACProxy,
596600
},
597601
PlatformType: kubemarkPlatform,
598-
Features: map[string]bool{
599-
"MachineAPIMigration": true,
600-
},
602+
Features: enabledFeatureMap,
601603
},
602604
},
603605
{
@@ -612,7 +614,7 @@ func TestMAOConfigFromInfrastructure(t *testing.T) {
612614
FeatureGates: []openshiftv1.FeatureGateDetails{
613615
{
614616
Version: "",
615-
Enabled: []openshiftv1.FeatureGateAttributes{{Name: apifeatures.FeatureGateMachineAPIMigration}},
617+
Enabled: enabledFeatureGates,
616618
Disabled: []openshiftv1.FeatureGateAttributes{{Name: apifeatures.FeatureGateMachineAPIOperatorDisableMachineHealthCheckController}},
617619
},
618620
},
@@ -631,9 +633,7 @@ func TestMAOConfigFromInfrastructure(t *testing.T) {
631633
KubeRBACProxy: images.KubeRBACProxy,
632634
},
633635
PlatformType: openshiftv1.VSpherePlatformType,
634-
Features: map[string]bool{
635-
"MachineAPIMigration": true,
636-
},
636+
Features: enabledFeatureMap,
637637
},
638638
},
639639
{
@@ -648,7 +648,7 @@ func TestMAOConfigFromInfrastructure(t *testing.T) {
648648
FeatureGates: []openshiftv1.FeatureGateDetails{
649649
{
650650
Version: "",
651-
Enabled: []openshiftv1.FeatureGateAttributes{{Name: apifeatures.FeatureGateMachineAPIMigration}},
651+
Enabled: enabledFeatureGates,
652652
Disabled: []openshiftv1.FeatureGateAttributes{{Name: apifeatures.FeatureGateMachineAPIOperatorDisableMachineHealthCheckController}},
653653
},
654654
},
@@ -667,9 +667,7 @@ func TestMAOConfigFromInfrastructure(t *testing.T) {
667667
KubeRBACProxy: images.KubeRBACProxy,
668668
},
669669
PlatformType: openshiftv1.OvirtPlatformType,
670-
Features: map[string]bool{
671-
"MachineAPIMigration": true,
672-
},
670+
Features: enabledFeatureMap,
673671
},
674672
},
675673
{
@@ -684,7 +682,7 @@ func TestMAOConfigFromInfrastructure(t *testing.T) {
684682
FeatureGates: []openshiftv1.FeatureGateDetails{
685683
{
686684
Version: "",
687-
Enabled: []openshiftv1.FeatureGateAttributes{{Name: apifeatures.FeatureGateMachineAPIMigration}},
685+
Enabled: enabledFeatureGates,
688686
Disabled: []openshiftv1.FeatureGateAttributes{{Name: apifeatures.FeatureGateMachineAPIOperatorDisableMachineHealthCheckController}},
689687
},
690688
},
@@ -703,9 +701,7 @@ func TestMAOConfigFromInfrastructure(t *testing.T) {
703701
KubeRBACProxy: images.KubeRBACProxy,
704702
},
705703
PlatformType: openshiftv1.NonePlatformType,
706-
Features: map[string]bool{
707-
"MachineAPIMigration": true,
708-
},
704+
Features: enabledFeatureMap,
709705
},
710706
},
711707
{
@@ -722,7 +718,7 @@ func TestMAOConfigFromInfrastructure(t *testing.T) {
722718
FeatureGates: []openshiftv1.FeatureGateDetails{
723719
{
724720
Version: "",
725-
Enabled: []openshiftv1.FeatureGateAttributes{{Name: apifeatures.FeatureGateMachineAPIMigration}},
721+
Enabled: enabledFeatureGates,
726722
Disabled: []openshiftv1.FeatureGateAttributes{{Name: apifeatures.FeatureGateMachineAPIOperatorDisableMachineHealthCheckController}},
727723
},
728724
},
@@ -741,9 +737,7 @@ func TestMAOConfigFromInfrastructure(t *testing.T) {
741737
KubeRBACProxy: images.KubeRBACProxy,
742738
},
743739
PlatformType: openshiftv1.BareMetalPlatformType,
744-
Features: map[string]bool{
745-
"MachineAPIMigration": true,
746-
},
740+
Features: enabledFeatureMap,
747741
},
748742
},
749743
{
@@ -758,7 +752,7 @@ func TestMAOConfigFromInfrastructure(t *testing.T) {
758752
FeatureGates: []openshiftv1.FeatureGateDetails{
759753
{
760754
Version: "",
761-
Enabled: []openshiftv1.FeatureGateAttributes{{Name: apifeatures.FeatureGateMachineAPIOperatorDisableMachineHealthCheckController}, {Name: apifeatures.FeatureGateMachineAPIMigration}},
755+
Enabled: append(enabledFeatureGates, openshiftv1.FeatureGateAttributes{Name: apifeatures.FeatureGateMachineAPIOperatorDisableMachineHealthCheckController}),
762756
Disabled: []openshiftv1.FeatureGateAttributes{},
763757
},
764758
},
@@ -777,9 +771,7 @@ func TestMAOConfigFromInfrastructure(t *testing.T) {
777771
KubeRBACProxy: images.KubeRBACProxy,
778772
},
779773
PlatformType: openshiftv1.BareMetalPlatformType,
780-
Features: map[string]bool{
781-
"MachineAPIMigration": true,
782-
},
774+
Features: enabledFeatureMap,
783775
},
784776
},
785777
{
@@ -794,7 +786,7 @@ func TestMAOConfigFromInfrastructure(t *testing.T) {
794786
FeatureGates: []openshiftv1.FeatureGateDetails{
795787
{
796788
Version: "",
797-
Enabled: []openshiftv1.FeatureGateAttributes{{Name: apifeatures.FeatureGateMachineAPIMigration}},
789+
Enabled: enabledFeatureGates,
798790
Disabled: []openshiftv1.FeatureGateAttributes{{Name: apifeatures.FeatureGateMachineAPIOperatorDisableMachineHealthCheckController}},
799791
},
800792
},
@@ -813,9 +805,7 @@ func TestMAOConfigFromInfrastructure(t *testing.T) {
813805
KubeRBACProxy: images.KubeRBACProxy,
814806
},
815807
PlatformType: "bad-platform",
816-
Features: map[string]bool{
817-
"MachineAPIMigration": true,
818-
},
808+
Features: enabledFeatureMap,
819809
},
820810
},
821811
{

pkg/operator/sync.go

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@ import (
44
"context"
55
"fmt"
66
"os"
7+
"slices"
78
"strings"
89
"time"
910

@@ -643,6 +644,8 @@ func buildFeatureGatesString(featureGates map[string]bool) string {
643644
part := fmt.Sprintf("%s=%t", name, enabled)
644645
parts = append(parts, part)
645646
}
647+
slices.Sort(parts)
648+
646649
return "--feature-gates=" + strings.Join(parts, ",")
647650
}
648651

0 commit comments

Comments
 (0)