@@ -24,7 +24,6 @@ import (
24
24
"github.com/stretchr/testify/require"
25
25
26
26
"github.com/openshift/machine-config-operator/pkg/controller/build/buildrequest"
27
- "github.com/openshift/machine-config-operator/pkg/controller/build/constants"
28
27
"github.com/openshift/machine-config-operator/pkg/controller/build/utils"
29
28
ctrlcommon "github.com/openshift/machine-config-operator/pkg/controller/common"
30
29
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
@@ -109,8 +108,6 @@ func TestOnClusterLayeringOnOKD(t *testing.T) {
109
108
110
109
// Tests that an on-cluster build can be performed with the Custom Pod Builder.
111
110
func TestOnClusterLayering (t * testing.T ) {
112
- ctx , cancel := context .WithCancel (context .Background ())
113
- t .Cleanup (cancel )
114
111
115
112
runOnClusterLayeringTest (t , onClusterLayeringTestOpts {
116
113
poolName : layeredMCPName ,
@@ -119,6 +116,11 @@ func TestOnClusterLayering(t *testing.T) {
119
116
},
120
117
})
121
118
119
+ /* Removing this portion of this test - update when https://issues.redhat.com/browse/OCPBUGS-46421 fixed.
120
+
121
+ ctx, cancel := context.WithCancel(context.Background())
122
+ t.Cleanup(cancel)
123
+
122
124
t.Logf("Applying rebuild annotation (%q) to MachineOSConfig (%q) to cause a rebuild", constants.RebuildMachineOSConfigAnnotationKey, layeredMCPName)
123
125
124
126
cs := framework.NewClientSet("")
@@ -132,6 +134,7 @@ func TestOnClusterLayering(t *testing.T) {
132
134
require.NoError(t, err)
133
135
134
136
waitForBuildToStartForPoolAndConfig(t, cs, layeredMCPName, layeredMCPName)
137
+ */
135
138
}
136
139
137
140
// Tests that an on-cluster build can be performed and that the resulting image
@@ -313,75 +316,67 @@ func TestMachineConfigPoolChangeRestartsBuild(t *testing.T) {
313
316
require .NoError (t , err )
314
317
}
315
318
316
- // This test starts a build with an image that is known to fail because it does
317
- // not have the necessary binaries within it . After failure, it edits the
318
- // MachineOSConfig with the expectation that the failed build and its objects
319
- // will be deleted and a new build will start in its place.
319
+ // This test starts a build with an image that is known to fail because it uses
320
+ // an invalid containerfile . After failure, it edits the MachineOSConfig
321
+ // with the expectation that the failed build and its will be deleted and a new
322
+ // build will start in its place.
320
323
func TestGracefulBuildFailureRecovery (t * testing.T ) {
321
324
322
- //TODO: Update this test to use a bad container file
323
- /*
324
- ctx, cancel := context.WithCancel(context.Background())
325
- t.Cleanup(cancel)
326
-
327
- cs := framework.NewClientSet("")
328
-
329
- mosc := prepareForOnClusterLayeringTest(t, cs, onClusterLayeringTestOpts{
330
- poolName: layeredMCPName,
331
- customDockerfiles: map[string]string{
332
- layeredMCPName: cowsayDockerfile,
333
- },
334
- })
325
+ ctx , cancel := context .WithCancel (context .Background ())
326
+ t .Cleanup (cancel )
335
327
336
- // Override the base OS container image to pull an invalid (and smaller)
337
- // image that should produce a failure faster.
328
+ cs := framework .NewClientSet ("" )
338
329
339
- pullspec, err := getImagePullspecForFailureTest(ctx, cs)
340
- require.NoError(t, err)
330
+ mosc := prepareForOnClusterLayeringTest (t , cs , onClusterLayeringTestOpts {
331
+ poolName : layeredMCPName ,
332
+ customDockerfiles : map [string ]string {
333
+ layeredMCPName : cowsayDockerfile ,
334
+ },
335
+ })
341
336
342
- t.Logf("Overriding BaseImagePullspec for MachineOSConfig %s with %q to cause a build failure", mosc.Name, pullspec)
337
+ // Add a bad containerfile so that we can cause a build failure
338
+ t .Logf ("Adding a bad containerfile for MachineOSConfig %s to cause a build failure" , mosc .Name )
343
339
344
- mosc.Spec.BuildInputs.BaseOSImagePullspec = pullspec
340
+ mosc .Spec .Containerfile = getBadContainerFileForFailureTest ()
345
341
346
- createMachineOSConfig(t, cs, mosc)
342
+ createMachineOSConfig (t , cs , mosc )
347
343
348
- // Wait for the build to start.
349
- firstMosb := waitForBuildToStartForPoolAndConfig(t, cs, layeredMCPName, mosc.Name)
344
+ // Wait for the build to start.
345
+ firstMosb := waitForBuildToStartForPoolAndConfig (t , cs , layeredMCPName , mosc .Name )
350
346
351
- t.Logf("Waiting for MachineOSBuild %s to fail", firstMosb.Name)
347
+ t .Logf ("Waiting for MachineOSBuild %s to fail" , firstMosb .Name )
352
348
353
- // Wait for the build to fail.
354
- kubeassert := helpers.AssertClientSet(t, cs).WithContext(ctx)
355
- kubeassert.Eventually().MachineOSBuildIsFailure(firstMosb)
349
+ // Wait for the build to fail.
350
+ kubeassert := helpers .AssertClientSet (t , cs ).WithContext (ctx )
351
+ kubeassert .Eventually ().MachineOSBuildIsFailure (firstMosb )
356
352
357
- // Clear the overridden image pullspec.
358
- apiMosc, err := cs.MachineconfigurationV1Interface.MachineOSConfigs().Get(ctx, mosc.Name, metav1.GetOptions{})
359
- require.NoError(t, err)
353
+ // Clear the overridden image pullspec.
354
+ apiMosc , err := cs .MachineconfigurationV1Interface .MachineOSConfigs ().Get (ctx , mosc .Name , metav1.GetOptions {})
355
+ require .NoError (t , err )
360
356
361
- apiMosc.Spec.BaseOSImagePullspec = ""
357
+ apiMosc .Spec .Containerfile = []mcfgv1. MachineOSContainerfile {}
362
358
363
- updated, err := cs.MachineconfigurationV1Interface.MachineOSConfigs().Update(ctx, apiMosc, metav1.UpdateOptions{})
364
- require.NoError(t, err)
359
+ updated , err := cs .MachineconfigurationV1Interface .MachineOSConfigs ().Update (ctx , apiMosc , metav1.UpdateOptions {})
360
+ require .NoError (t , err )
365
361
366
- t.Logf("Cleared BaseImagePullspec to use default value ")
362
+ t .Logf ("Cleared out bad containerfile " )
367
363
368
- mcp, err := cs.MachineconfigurationV1Interface.MachineConfigPools().Get(ctx, layeredMCPName, metav1.GetOptions{})
369
- require.NoError(t, err)
364
+ mcp , err := cs .MachineconfigurationV1Interface .MachineConfigPools ().Get (ctx , layeredMCPName , metav1.GetOptions {})
365
+ require .NoError (t , err )
370
366
371
- // Compute the new MachineOSBuild image name.
372
- moscChangeMosb := buildrequest.NewMachineOSBuildFromAPIOrDie(ctx, cs.GetKubeclient(), updated, mcp)
367
+ // Compute the new MachineOSBuild image name.
368
+ moscChangeMosb := buildrequest .NewMachineOSBuildFromAPIOrDie (ctx , cs .GetKubeclient (), updated , mcp )
373
369
374
- // Wait for the second build to start.
375
- secondMosb := waitForBuildToStart(t, cs, moscChangeMosb)
370
+ // Wait for the second build to start.
371
+ secondMosb := waitForBuildToStart (t , cs , moscChangeMosb )
376
372
377
- // Ensure that the first build is eventually cleaned up.
378
- kubeassert.Eventually().MachineOSBuildDoesNotExist(firstMosb)
379
- assertBuildObjectsAreDeleted(t, kubeassert.Eventually(), firstMosb)
373
+ // Ensure that the first build is eventually cleaned up.
374
+ kubeassert .Eventually ().MachineOSBuildDoesNotExist (firstMosb )
375
+ assertBuildObjectsAreDeleted (t , kubeassert .Eventually (), firstMosb )
380
376
381
- // Ensure that the second build is still running.
382
- kubeassert.MachineOSBuildExists(secondMosb)
383
- assertBuildObjectsAreCreated(t, kubeassert, secondMosb)
384
- */
377
+ // Ensure that the second build is still running.
378
+ kubeassert .MachineOSBuildExists (secondMosb )
379
+ assertBuildObjectsAreCreated (t , kubeassert , secondMosb )
385
380
386
381
}
387
382
@@ -811,14 +806,11 @@ func prepareForOnClusterLayeringTest(t *testing.T, cs *framework.ClientSet, test
811
806
})
812
807
813
808
imagestreamObjMeta := metav1.ObjectMeta {
814
- Name : "os-image" ,
815
- Namespace : strings .ToLower (t .Name ()),
809
+ Name : "os-image" ,
816
810
}
817
811
818
812
pushSecretName , finalPullspec , _ := setupImageStream (t , cs , imagestreamObjMeta )
819
813
820
- copyGlobalPullSecret (t , cs )
821
-
822
814
if testOpts .targetNode != nil {
823
815
makeIdempotentAndRegister (t , helpers .CreatePoolWithNode (t , cs , testOpts .poolName , * testOpts .targetNode ))
824
816
} else {
@@ -860,9 +852,6 @@ func prepareForOnClusterLayeringTest(t *testing.T, cs *framework.ClientSet, test
860
852
MachineConfigPool : mcfgv1.MachineConfigPoolReference {
861
853
Name : testOpts .poolName ,
862
854
},
863
- BaseImagePullSecret : & mcfgv1.ImageSecretObjectReference {
864
- Name : globalPullSecretCloneName ,
865
- },
866
855
RenderedImagePushSecret : mcfgv1.ImageSecretObjectReference {
867
856
Name : pushSecretName ,
868
857
},
0 commit comments