-
Notifications
You must be signed in to change notification settings - Fork 493
MCO-831: added feature gate to mco for on cluster builds #4060
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -71,6 +71,24 @@ func TestMachineOSBuilder(t *testing.T) { | |
|
|
||
| t.Cleanup(createConfigMapForTest(t, cs)) | ||
|
|
||
| // get the feature gates because we're gating this for now | ||
| featureGates, err := cs.ConfigV1Interface.FeatureGates().Get(context.TODO(), "cluster", metav1.GetOptions{}) | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. you might need to add the FGs to the cs if you want them to be initialized.
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. does the ClientSet itself store or manage feature gate configurations? I fetch the existing feature gate configurations and use that info to adjust the behavior of the test |
||
| require.NoError(t, err, "Failed to retrieve feature gates") | ||
|
|
||
| // TODO(jkyros): this should be a helper or we should use whatever the "best practice" way is | ||
| // for retrieving the gates during a test, but this works for now | ||
| var featureGateEnabled bool | ||
| for _, featureGateDetails := range featureGates.Status.FeatureGates { | ||
| for _, enabled := range featureGateDetails.Enabled { | ||
| if enabled.Name == "OnClusterBuild" { | ||
| featureGateEnabled = true | ||
|
|
||
| } | ||
| } | ||
| } | ||
|
|
||
| t.Logf("Feature gate OnClusterBuiild enabled: %t", featureGateEnabled) | ||
|
|
||
| cleanup := helpers.MakeIdempotent(helpers.CreateMCP(t, cs, mcpName)) | ||
| t.Cleanup(cleanup) | ||
| time.Sleep(10 * time.Second) // Wait a bit to ensure MCP is fully created | ||
|
|
@@ -94,33 +112,38 @@ func TestMachineOSBuilder(t *testing.T) { | |
|
|
||
| // assertion to see if the deployment object is present after setting the label | ||
| ctx := context.TODO() | ||
| err := wait.PollUntilContextTimeout(ctx, 2*time.Second, time.Minute, true, func(ctx context.Context) (bool, error) { | ||
| exists, err := helpers.CheckDeploymentExists(cs, "machine-os-builder", namespace) | ||
| return exists, err | ||
| }) | ||
| require.NoError(t, err, "Failed to check the existence of the Machine OS Builder deployment") | ||
|
|
||
| // wait for Machine OS Builder pod to start | ||
| err = helpers.WaitForPodStart(cs, mobPodNamePrefix, namespace) | ||
| require.NoError(t, err, "Failed to start the Machine OS Builder pod") | ||
| t.Logf("machine-os-builder deployment exists") | ||
|
|
||
| // delete the MachineConfigPool | ||
| cleanup() | ||
| time.Sleep(20 * time.Second) | ||
|
|
||
| // assertion to see if the deployment object is absent after deleting the MCP | ||
| err = wait.PollUntilContextTimeout(ctx, 2*time.Second, time.Minute, true, func(ctx context.Context) (bool, error) { | ||
| exists, err := helpers.CheckDeploymentExists(cs, "machine-os-builder", namespace) | ||
| return !exists, err | ||
| return exists, err | ||
| }) | ||
| require.NoError(t, err, "Failed to check the absence of the Machine OS Builder deployment") | ||
|
|
||
| // wait for Machine OS Builder pod to stop | ||
| err = helpers.WaitForPodStop(cs, mobPodNamePrefix, namespace) | ||
| require.NoError(t, err, "Failed to stop the Machine OS Builder pod") | ||
| t.Logf("machine-os-builder deployment no longer exists") | ||
|
|
||
| _, err = cs.AppsV1Interface.Deployments(ctrlcommon.MCONamespace).Get(context.TODO(), "machine-os-builder", metav1.GetOptions{}) | ||
| assert.True(t, apierrs.IsNotFound(err), "machine-os-builder deployment still present") | ||
| if featureGateEnabled { | ||
| require.NoError(t, err, "Failed to check the existence of the Machine OS Builder deployment") | ||
|
|
||
| // wait for Machine OS Builder pod to start | ||
| err = helpers.WaitForPodStart(cs, mobPodNamePrefix, namespace) | ||
| require.NoError(t, err, "Failed to start the Machine OS Builder pod") | ||
| t.Logf("machine-os-builder deployment exists") | ||
|
|
||
| // delete the MachineConfigPool | ||
| cleanup() | ||
| time.Sleep(20 * time.Second) | ||
|
|
||
| // assertion to see if the deployment object is absent after deleting the MCP | ||
| err = wait.PollUntilContextTimeout(ctx, 2*time.Second, time.Minute, true, func(ctx context.Context) (bool, error) { | ||
| exists, err := helpers.CheckDeploymentExists(cs, "machine-os-builder", namespace) | ||
| return !exists, err | ||
| }) | ||
| require.NoError(t, err, "Failed to check the absence of the Machine OS Builder deployment") | ||
|
|
||
| // wait for Machine OS Builder pod to stop | ||
| err = helpers.WaitForPodStop(cs, mobPodNamePrefix, namespace) | ||
| require.NoError(t, err, "Failed to stop the Machine OS Builder pod") | ||
| t.Logf("machine-os-builder deployment no longer exists") | ||
|
|
||
| _, err = cs.AppsV1Interface.Deployments(ctrlcommon.MCONamespace).Get(context.TODO(), "machine-os-builder", metav1.GetOptions{}) | ||
| assert.True(t, apierrs.IsNotFound(err), "machine-os-builder deployment still present") | ||
| } else { | ||
| require.Error(t, err, "Machine OS Builder deployment exists and it should not, because the feature gate is disabled") | ||
| } | ||
| } | ||
Uh oh!
There was an error while loading. Please reload this page.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
what is this for? This seems harmless, but just checking :)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I feel like I remember this existing but it claims you're adding this, do we not do this somewhere else?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
unit tests were failing with
error finding pools for machineconfigandAction update machineconfigpools has wrong objectthe order of elements in the slice was being altered in
syncMachineConfigPoolfrom the listerUh oh!
There was an error while loading. Please reload this page.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We do it later in like MergeMachineConfigs, but there is some weird non-determinism that we hit a lot in this PR during tests for some reason. see: #4060 (comment)
I have been seeing it intermittently, e.g. #4003 (comment) so I know this PR didn't introduce it, it just seems like it happens way more often here. It might be intended behavior ( like how they intentionally don't want you to depend on go map order so they shuffle it) but I haven't done the due diligence, I'm a slob. 😄
I wasn't being prescriptive on how we accommodate this, I just wanted to prove why it was breaking -- it's possible we could mangle the test fixture to just test for presence not order, but that also might be a weird one-off.