Skip to content

Commit c71b0e6

Browse files
committed
Remove feature gate from MHC
1 parent 2426fa7 commit c71b0e6

File tree

2 files changed

+2
-119
lines changed

2 files changed

+2
-119
lines changed

pkg/operator/operator_test.go

Lines changed: 0 additions & 114 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,6 @@ import (
55
"testing"
66
"time"
77

8-
appsv1 "k8s.io/api/apps/v1"
98
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
109
"k8s.io/apimachinery/pkg/runtime"
1110
"k8s.io/apimachinery/pkg/util/wait"
@@ -175,116 +174,3 @@ func TestOperatorSync_NoOp(t *testing.T) {
175174
})
176175
}
177176
}
178-
179-
func deploymentHasContainer(d *appsv1.Deployment, containerName string) bool {
180-
for _, container := range d.Spec.Template.Spec.Containers {
181-
if container.Name == containerName {
182-
return true
183-
}
184-
}
185-
return false
186-
}
187-
188-
func TestOperatorSyncClusterAPIControllerHealthCheckController(t *testing.T) {
189-
tests := []struct {
190-
featureGate *v1.FeatureGate
191-
expectedMachineHealthCheckController bool
192-
}{{
193-
featureGate: newFeatureGate(v1.Default),
194-
expectedMachineHealthCheckController: false,
195-
}, {
196-
featureGate: &v1.FeatureGate{},
197-
expectedMachineHealthCheckController: false,
198-
}, {
199-
featureGate: newFeatureGate(v1.TechPreviewNoUpgrade),
200-
expectedMachineHealthCheckController: true,
201-
}}
202-
203-
for _, tc := range tests {
204-
infra := &v1.Infrastructure{
205-
ObjectMeta: metav1.ObjectMeta{
206-
Name: "cluster",
207-
},
208-
Status: v1.InfrastructureStatus{
209-
Platform: v1.AWSPlatformType,
210-
},
211-
}
212-
213-
stopCh := make(<-chan struct{})
214-
optr := newFakeOperator(nil, []runtime.Object{tc.featureGate, infra}, stopCh)
215-
go optr.Run(2, stopCh)
216-
217-
if err := wait.PollImmediate(1*time.Second, 5*time.Second, func() (bool, error) {
218-
d, err := optr.deployLister.Deployments(targetNamespace).Get(deploymentName)
219-
if err != nil {
220-
t.Logf("Failed to get %q deployment: %v", deploymentName, err)
221-
return false, nil
222-
}
223-
if deploymentHasContainer(d, hcControllerName) != tc.expectedMachineHealthCheckController {
224-
t.Logf("Expected deploymentHasContainer for %q container to be %t", hcControllerName, tc.expectedMachineHealthCheckController)
225-
return false, nil
226-
}
227-
return true, nil
228-
}); err != nil {
229-
t.Errorf("Failed to verify %q deployment", deploymentName)
230-
}
231-
}
232-
}
233-
234-
func TestEnableDisableOperatorSyncClusterAPIControllerHealthCheckController(t *testing.T) {
235-
infra := &v1.Infrastructure{
236-
ObjectMeta: metav1.ObjectMeta{
237-
Name: "cluster",
238-
},
239-
Status: v1.InfrastructureStatus{
240-
Platform: v1.AWSPlatformType,
241-
},
242-
}
243-
stopCh := make(chan struct{})
244-
defer close(stopCh)
245-
246-
optr := newFakeOperator(nil, []runtime.Object{newFeatureGate(v1.TechPreviewNoUpgrade), infra}, stopCh)
247-
go optr.Run(2, stopCh)
248-
249-
if err := wait.PollImmediate(1*time.Second, 5*time.Second, func() (bool, error) {
250-
d, err := optr.deployLister.Deployments(targetNamespace).Get(deploymentName)
251-
if err != nil {
252-
t.Logf("Failed to get %q deployment: %v", deploymentName, err)
253-
return false, nil
254-
}
255-
if !deploymentHasContainer(d, hcControllerName) {
256-
t.Logf("Failed to verify that deployment %q has container %q", deploymentName, hcControllerName)
257-
return false, nil
258-
}
259-
return true, nil
260-
}); err != nil {
261-
t.Fatalf("Failed to verify that deployment %q has container %q", deploymentName, hcControllerName)
262-
}
263-
264-
t.Logf("Found %q container in %q deployment", hcControllerName, deploymentName)
265-
266-
hcFeatureGate, err := optr.osClient.ConfigV1().FeatureGates().Get(MachineAPIFeatureGateName, metav1.GetOptions{})
267-
if err != nil {
268-
t.Fatalf("Unable to get %q feature gate: %v", MachineAPIFeatureGateName, err)
269-
}
270-
hcFeatureGate.Spec.FeatureSet = v1.Default
271-
if _, err := optr.osClient.ConfigV1().FeatureGates().Update(hcFeatureGate); err != nil {
272-
t.Fatalf("Unable to update %q feature gate and set default feature set: %v", MachineAPIFeatureGateName, err)
273-
}
274-
275-
if err := wait.PollImmediate(1*time.Second, 15*time.Second, func() (bool, error) {
276-
d, err := optr.deployLister.Deployments(targetNamespace).Get(deploymentName)
277-
if err != nil {
278-
t.Logf("Failed to get %q deployment: %v", deploymentName, err)
279-
return false, nil
280-
}
281-
if deploymentHasContainer(d, hcControllerName) {
282-
t.Logf("Failed to verify that deployment %q has no container with name %q", deploymentName, hcControllerName)
283-
return false, nil
284-
}
285-
return true, nil
286-
}); err != nil {
287-
t.Errorf("Failed to verify that deployment %q has no container with name %q ", deploymentName, hcControllerName)
288-
}
289-
290-
}

pkg/operator/sync.go

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -253,16 +253,13 @@ func newContainers(config *OperatorConfig, features map[string]bool) []corev1.Co
253253
Args: args,
254254
Resources: resources,
255255
},
256-
}
257-
// add machine-health-check controller container if it exists and enabled under feature gates
258-
if enabled, ok := features[FeatureGateMachineHealthCheck]; ok && enabled {
259-
containers = append(containers, corev1.Container{
256+
{
260257
Name: "machine-healthcheck-controller",
261258
Image: config.Controllers.MachineHealthCheck,
262259
Command: []string{"/machine-healthcheck"},
263260
Args: args,
264261
Resources: resources,
265-
})
262+
},
266263
}
267264
return containers
268265
}

0 commit comments

Comments
 (0)