forked from openshift/hive
/
clusterdeployment_controller_test.go
3454 lines (3324 loc) · 129 KB
/
clusterdeployment_controller_test.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
package clusterdeployment
import (
"context"
"fmt"
"os"
"testing"
"time"
"github.com/golang/mock/gomock"
log "github.com/sirupsen/logrus"
"github.com/stretchr/testify/assert"
"github.com/stretchr/testify/require"
"golang.org/x/crypto/openpgp"
batchv1 "k8s.io/api/batch/v1"
corev1 "k8s.io/api/core/v1"
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
"k8s.io/apimachinery/pkg/apis/meta/v1/unstructured"
"k8s.io/apimachinery/pkg/runtime"
"k8s.io/apimachinery/pkg/runtime/schema"
"k8s.io/apimachinery/pkg/types"
"k8s.io/apimachinery/pkg/util/sets"
"k8s.io/client-go/kubernetes/scheme"
"k8s.io/utils/pointer"
"sigs.k8s.io/controller-runtime/pkg/client"
"sigs.k8s.io/controller-runtime/pkg/client/fake"
"sigs.k8s.io/controller-runtime/pkg/controller/controllerutil"
"sigs.k8s.io/controller-runtime/pkg/event"
"sigs.k8s.io/controller-runtime/pkg/reconcile"
openshiftapiv1 "github.com/openshift/api/config/v1"
routev1 "github.com/openshift/api/route/v1"
"github.com/openshift/library-go/pkg/verify"
"github.com/openshift/library-go/pkg/verify/store"
"github.com/openshift/hive/apis"
hivev1 "github.com/openshift/hive/apis/hive/v1"
hivev1aws "github.com/openshift/hive/apis/hive/v1/aws"
"github.com/openshift/hive/apis/hive/v1/baremetal"
hiveintv1alpha1 "github.com/openshift/hive/apis/hiveinternal/v1alpha1"
"github.com/openshift/hive/pkg/constants"
controllerutils "github.com/openshift/hive/pkg/controller/utils"
"github.com/openshift/hive/pkg/remoteclient"
remoteclientmock "github.com/openshift/hive/pkg/remoteclient/mock"
testassert "github.com/openshift/hive/pkg/test/assert"
testclusterdeployment "github.com/openshift/hive/pkg/test/clusterdeployment"
testclusterdeprovision "github.com/openshift/hive/pkg/test/clusterdeprovision"
testdnszone "github.com/openshift/hive/pkg/test/dnszone"
)
const (
testName = "foo-lqmsh"
testClusterName = "bar"
testClusterID = "testFooClusterUUID"
testInfraID = "testFooInfraID"
provisionName = "foo-lqmsh-random"
imageSetJobName = "foo-lqmsh-imageset"
testNamespace = "default"
testSyncsetInstanceName = "testSSI"
metadataName = "foo-lqmsh-metadata"
pullSecretSecret = "pull-secret"
installLogSecret = "install-log-secret"
globalPullSecret = "global-pull-secret"
adminKubeconfigSecret = "foo-lqmsh-admin-kubeconfig"
adminKubeconfig = `clusters:
- cluster:
certificate-authority-data: JUNK
server: https://bar-api.clusters.example.com:6443
name: bar
contexts:
- context:
cluster: bar
name: admin
current-context: admin
`
adminPasswordSecret = "foo-lqmsh-admin-password"
adminPassword = "foo"
credsSecret = "foo-aws-creds"
sshKeySecret = "foo-ssh-key"
remoteClusterRouteObjectName = "console"
remoteClusterRouteObjectNamespace = "openshift-console"
testClusterImageSetName = "test-image-set"
)
func init() {
log.SetLevel(log.DebugLevel)
}
func TestClusterDeploymentReconcile(t *testing.T) {
apis.AddToScheme(scheme.Scheme)
openshiftapiv1.Install(scheme.Scheme)
routev1.Install(scheme.Scheme)
// Utility function to get the test CD from the fake client
getCD := func(c client.Client) *hivev1.ClusterDeployment {
cd := &hivev1.ClusterDeployment{}
err := c.Get(context.TODO(), client.ObjectKey{Name: testName, Namespace: testNamespace}, cd)
if err == nil {
return cd
}
return nil
}
getDNSZone := func(c client.Client) *hivev1.DNSZone {
zone := &hivev1.DNSZone{}
err := c.Get(context.TODO(), client.ObjectKey{Name: testName + "-zone", Namespace: testNamespace}, zone)
if err == nil {
return zone
}
return nil
}
getDeprovision := func(c client.Client) *hivev1.ClusterDeprovision {
req := &hivev1.ClusterDeprovision{}
err := c.Get(context.TODO(), client.ObjectKey{Name: testName, Namespace: testNamespace}, req)
if err == nil {
return req
}
return nil
}
getImageSetJob := func(c client.Client) *batchv1.Job {
return getJob(c, imageSetJobName)
}
imageVerifier := testReleaseVerifier{known: sets.NewString("sha256:digest1", "sha256:digest2", "sha256:digest3")}
tests := []struct {
name string
existing []runtime.Object
riVerifier verify.Interface
pendingCreation bool
expectErr bool
expectedRequeueAfter time.Duration
expectPendingCreation bool
expectConsoleRouteFetch bool
validate func(client.Client, *testing.T)
reconcilerSetup func(*ReconcileClusterDeployment)
platformCredentialsValidation func(client.Client, *hivev1.ClusterDeployment, log.FieldLogger) (bool, error)
}{
{
name: "Initialize conditions",
existing: []runtime.Object{
testClusterDeployment(),
},
validate: func(c client.Client, t *testing.T) {
cd := getCD(c)
compareCD := testClusterDeploymentWithInitializedConditions(testClusterDeployment())
testassert.AssertConditions(t, cd, compareCD.Status.Conditions)
},
},
{
name: "Add finalizer",
existing: []runtime.Object{
testClusterDeploymentWithInitializedConditions(testClusterDeploymentWithoutFinalizer()),
testSecret(corev1.SecretTypeDockerConfigJson, pullSecretSecret, corev1.DockerConfigJsonKey, "{}"),
},
validate: func(c client.Client, t *testing.T) {
cd := getCD(c)
if cd == nil || !controllerutils.HasFinalizer(cd, hivev1.FinalizerDeprovision) {
t.Errorf("did not get expected clusterdeployment finalizer")
}
},
},
{
name: "Create provision",
existing: []runtime.Object{
testClusterDeploymentWithDefaultConditions(testClusterDeploymentWithInitializedConditions(testClusterDeployment())),
testSecret(corev1.SecretTypeDockerConfigJson, pullSecretSecret, corev1.DockerConfigJsonKey, "{}"),
testSecret(corev1.SecretTypeDockerConfigJson, constants.GetMergedPullSecretName(testClusterDeployment()), corev1.DockerConfigJsonKey, "{}"),
},
expectPendingCreation: true,
validate: func(c client.Client, t *testing.T) {
provisions := getProvisions(c)
assert.Len(t, provisions, 1, "expected provision to exist")
},
},
{
name: "Provision not created when pending create",
existing: []runtime.Object{
testClusterDeployment(),
testSecret(corev1.SecretTypeDockerConfigJson, pullSecretSecret, corev1.DockerConfigJsonKey, "{}"),
testSecret(corev1.SecretTypeDockerConfigJson, constants.GetMergedPullSecretName(testClusterDeployment()), corev1.DockerConfigJsonKey, "{}"),
},
pendingCreation: true,
expectPendingCreation: true,
validate: func(c client.Client, t *testing.T) {
provisions := getProvisions(c)
assert.Empty(t, provisions, "expected provision to not exist")
},
},
{
name: "Adopt provision",
existing: []runtime.Object{
testClusterDeploymentWithInitializedConditions(testClusterDeployment()),
testProvision(),
testSecret(corev1.SecretTypeDockerConfigJson, pullSecretSecret, corev1.DockerConfigJsonKey, "{}"),
testSecret(corev1.SecretTypeDockerConfigJson, constants.GetMergedPullSecretName(testClusterDeployment()), corev1.DockerConfigJsonKey, "{}"),
},
validate: func(c client.Client, t *testing.T) {
cd := getCD(c)
if assert.NotNil(t, cd, "no clusterdeployment found") {
if assert.NotNil(t, cd.Status.ProvisionRef, "missing provision ref") {
assert.Equal(t, provisionName, cd.Status.ProvisionRef.Name, "unexpected provision ref name")
}
}
},
},
{
name: "No-op Running provision",
existing: []runtime.Object{
testClusterDeploymentWithDefaultConditions(testClusterDeploymentWithInitializedConditions(testClusterDeploymentWithProvision())),
testProvision(),
testSecret(corev1.SecretTypeDockerConfigJson, pullSecretSecret, corev1.DockerConfigJsonKey, "{}"),
testSecret(corev1.SecretTypeDockerConfigJson, constants.GetMergedPullSecretName(testClusterDeployment()), corev1.DockerConfigJsonKey, "{}"),
},
validate: func(c client.Client, t *testing.T) {
cd := getCD(c)
if assert.NotNil(t, cd, "no clusterdeployment found") {
e := testClusterDeploymentWithDefaultConditions(testClusterDeploymentWithInitializedConditions(
testClusterDeploymentWithProvision()))
testassert.AssertEqualWhereItCounts(t, e, cd, "unexpected change in clusterdeployment")
}
provisions := getProvisions(c)
if assert.Len(t, provisions, 1, "expected provision to exist") {
e := testProvision()
testassert.AssertEqualWhereItCounts(t, e, provisions[0], "unexpected change in provision")
}
},
},
{
name: "Parse server URL from admin kubeconfig",
existing: []runtime.Object{
func() *hivev1.ClusterDeployment {
cd := testClusterDeploymentWithInitializedConditions(testClusterDeployment())
cd.Spec.Installed = true
cd.Spec.ClusterMetadata = &hivev1.ClusterMetadata{
InfraID: "fakeinfra",
AdminKubeconfigSecretRef: corev1.LocalObjectReference{Name: adminKubeconfigSecret},
}
cd.Status.Conditions = addOrUpdateClusterDeploymentCondition(*cd, hivev1.UnreachableCondition,
corev1.ConditionFalse, "test-reason", "test-message")
return cd
}(),
testSecret(corev1.SecretTypeOpaque, adminKubeconfigSecret, "kubeconfig", adminKubeconfig),
testSecret(corev1.SecretTypeDockerConfigJson, pullSecretSecret, corev1.DockerConfigJsonKey, "{}"),
testSecret(corev1.SecretTypeDockerConfigJson, constants.GetMergedPullSecretName(testClusterDeployment()), corev1.DockerConfigJsonKey, "{}"),
testMetadataConfigMap(),
},
expectConsoleRouteFetch: true,
validate: func(c client.Client, t *testing.T) {
cd := getCD(c)
assert.Equal(t, "https://bar-api.clusters.example.com:6443", cd.Status.APIURL)
assert.Equal(t, "https://bar-api.clusters.example.com:6443/console", cd.Status.WebConsoleURL)
},
},
{
name: "Add additional CAs to admin kubeconfig",
existing: []runtime.Object{
func() *hivev1.ClusterDeployment {
cd := testClusterDeploymentWithInitializedConditions(testClusterDeployment())
cd.Spec.Installed = true
cd.Spec.ClusterMetadata = &hivev1.ClusterMetadata{
InfraID: "fakeinfra",
AdminKubeconfigSecretRef: corev1.LocalObjectReference{Name: adminKubeconfigSecret},
}
cd.Status.WebConsoleURL = "https://example.com"
cd.Status.APIURL = "https://example.com"
return cd
}(),
testSecret(corev1.SecretTypeOpaque, adminKubeconfigSecret, "kubeconfig", adminKubeconfig),
testSecret(corev1.SecretTypeDockerConfigJson, pullSecretSecret, corev1.DockerConfigJsonKey, "{}"),
testSecret(corev1.SecretTypeDockerConfigJson, constants.GetMergedPullSecretName(testClusterDeployment()), corev1.DockerConfigJsonKey, "{}"),
testMetadataConfigMap(),
},
expectConsoleRouteFetch: false,
validate: func(c client.Client, t *testing.T) {
// Ensure the admin kubeconfig secret got a copy of the raw data, indicating that we would have
// added additional CAs if any were configured.
akcSecret := &corev1.Secret{}
err := c.Get(context.TODO(), client.ObjectKey{Name: adminKubeconfigSecret, Namespace: testNamespace},
akcSecret)
require.NoError(t, err)
require.NotNil(t, akcSecret)
assert.Contains(t, akcSecret.Data, constants.RawKubeconfigSecretKey)
},
},
{
name: "Completed provision",
existing: []runtime.Object{
testClusterDeploymentWithInitializedConditions(testClusterDeploymentWithProvision()),
testSuccessfulProvision(),
testMetadataConfigMap(),
testSecret(corev1.SecretTypeOpaque, adminKubeconfigSecret, "kubeconfig", adminKubeconfig),
testSecret(corev1.SecretTypeDockerConfigJson, pullSecretSecret, corev1.DockerConfigJsonKey, "{}"),
testSecret(corev1.SecretTypeDockerConfigJson, constants.GetMergedPullSecretName(testClusterDeployment()), corev1.DockerConfigJsonKey, "{}"),
},
validate: func(c client.Client, t *testing.T) {
cd := getCD(c)
if assert.NotNil(t, cd, "missing clusterdeployment") {
assert.True(t, cd.Spec.Installed, "expected cluster to be installed")
assert.NotContains(t, cd.Annotations, constants.ProtectedDeleteAnnotation, "unexpected protected delete annotation")
}
},
},
{
name: "Completed provision with protected delete",
existing: []runtime.Object{
testClusterDeploymentWithInitializedConditions(testClusterDeploymentWithProvision()),
testSuccessfulProvision(),
testMetadataConfigMap(),
testSecret(corev1.SecretTypeOpaque, adminKubeconfigSecret, "kubeconfig", adminKubeconfig),
testSecret(corev1.SecretTypeDockerConfigJson, pullSecretSecret, corev1.DockerConfigJsonKey, "{}"),
testSecret(corev1.SecretTypeDockerConfigJson, constants.GetMergedPullSecretName(testClusterDeployment()), corev1.DockerConfigJsonKey, "{}"),
},
reconcilerSetup: func(r *ReconcileClusterDeployment) {
r.protectedDelete = true
},
validate: func(c client.Client, t *testing.T) {
cd := getCD(c)
if assert.NotNil(t, cd, "missing clusterdeployment") {
assert.True(t, cd.Spec.Installed, "expected cluster to be installed")
assert.Equal(t, "true", cd.Annotations[constants.ProtectedDeleteAnnotation], "unexpected protected delete annotation")
}
},
},
{
name: "clusterdeployment must specify pull secret when there is no global pull secret ",
existing: []runtime.Object{
func() *hivev1.ClusterDeployment {
cd := testClusterDeploymentWithInitializedConditions(testClusterDeployment())
cd.Spec.PullSecretRef = nil
return cd
}(),
},
expectErr: true,
},
{
name: "Legacy dockercfg pull secret causes no errors once installed",
existing: []runtime.Object{
testInstalledClusterDeployment(time.Date(2019, 9, 6, 11, 58, 32, 45, time.UTC)),
testMetadataConfigMap(),
testSecret(corev1.SecretTypeOpaque, adminKubeconfigSecret, "kubeconfig", adminKubeconfig),
testSecret(corev1.SecretTypeOpaque, adminPasswordSecret, "password", adminPassword),
testSecret(corev1.SecretTypeDockerConfigJson, pullSecretSecret, corev1.DockerConfigJsonKey, "{}"),
testSecret(corev1.SecretTypeDockerConfigJson, constants.GetMergedPullSecretName(testClusterDeployment()), corev1.DockerConfigJsonKey, "{}"),
},
},
{
name: "No-op deleted cluster without finalizer",
existing: []runtime.Object{
testDeletedClusterDeploymentWithoutFinalizer(),
testSecret(corev1.SecretTypeDockerConfigJson, pullSecretSecret, corev1.DockerConfigJsonKey, "{}"),
testSecret(corev1.SecretTypeDockerConfigJson, constants.GetMergedPullSecretName(testClusterDeployment()), corev1.DockerConfigJsonKey, "{}"),
},
validate: func(c client.Client, t *testing.T) {
deprovision := getDeprovision(c)
if deprovision != nil {
t.Errorf("got unexpected deprovision request")
}
},
},
{
name: "Block deprovision when protected delete on",
existing: []runtime.Object{
func() *hivev1.ClusterDeployment {
cd := testClusterDeployment()
if cd.Annotations == nil {
cd.Annotations = make(map[string]string, 1)
}
cd.Annotations[constants.ProtectedDeleteAnnotation] = "true"
now := metav1.Now()
cd.DeletionTimestamp = &now
return cd
}(),
testSecret(corev1.SecretTypeDockerConfigJson, pullSecretSecret, corev1.DockerConfigJsonKey, "{}"),
testSecret(corev1.SecretTypeDockerConfigJson, constants.GetMergedPullSecretName(testClusterDeployment()), corev1.DockerConfigJsonKey, "{}"),
},
validate: func(c client.Client, t *testing.T) {
deprovision := getDeprovision(c)
assert.Nil(t, deprovision, "expected no deprovision request")
cd := getCD(c)
assert.Contains(t, cd.Finalizers, hivev1.FinalizerDeprovision, "expected finalizer")
},
},
{
name: "Skip deprovision for deleted BareMetal cluster",
existing: []runtime.Object{
func() *hivev1.ClusterDeployment {
cd := testClusterDeploymentWithInitializedConditions(testClusterDeployment())
cd.Spec.Platform.AWS = nil
cd.Spec.Platform.BareMetal = &baremetal.Platform{}
cd.Labels[hivev1.HiveClusterPlatformLabel] = "baremetal"
now := metav1.Now()
cd.DeletionTimestamp = &now
return cd
}(),
testSecret(corev1.SecretTypeDockerConfigJson, pullSecretSecret, corev1.DockerConfigJsonKey, "{}"),
testSecret(corev1.SecretTypeDockerConfigJson, constants.GetMergedPullSecretName(testClusterDeployment()), corev1.DockerConfigJsonKey, "{}"),
},
validate: func(c client.Client, t *testing.T) {
deprovision := getDeprovision(c)
assert.Nil(t, deprovision, "expected no deprovision request")
cd := getCD(c)
assert.Equal(t, 0, len(cd.Finalizers))
},
},
{
name: "Delete expired cluster deployment",
existing: []runtime.Object{
testClusterDeploymentWithInitializedConditions(testExpiredClusterDeployment()),
testSecret(corev1.SecretTypeDockerConfigJson, pullSecretSecret, corev1.DockerConfigJsonKey, "{}"),
testSecret(corev1.SecretTypeDockerConfigJson, constants.GetMergedPullSecretName(testClusterDeployment()), corev1.DockerConfigJsonKey, "{}"),
},
validate: func(c client.Client, t *testing.T) {
cd := getCD(c)
if cd != nil {
t.Errorf("got unexpected cluster deployment (expected deleted)")
}
},
},
{
name: "Test PreserveOnDelete",
existing: []runtime.Object{
func() *hivev1.ClusterDeployment {
cd := testClusterDeploymentWithInitializedConditions(testDeletedClusterDeployment())
cd.Spec.Installed = true
cd.Spec.PreserveOnDelete = true
return cd
}(),
testSecret(corev1.SecretTypeDockerConfigJson, pullSecretSecret, corev1.DockerConfigJsonKey, "{}"),
testSecret(corev1.SecretTypeDockerConfigJson, constants.GetMergedPullSecretName(testClusterDeployment()), corev1.DockerConfigJsonKey, "{}"),
},
validate: func(c client.Client, t *testing.T) {
cd := getCD(c)
if assert.NotNil(t, cd, "missing clusterdeployment") {
assert.Empty(t, cd.Finalizers, "expected empty finalizers")
}
deprovision := getDeprovision(c)
assert.Nil(t, deprovision, "expected no deprovision request")
},
},
{
name: "Test creation of uninstall job when PreserveOnDelete is true but cluster deployment is not installed",
existing: []runtime.Object{
func() *hivev1.ClusterDeployment {
cd := testClusterDeploymentWithInitializedConditions(testDeletedClusterDeployment())
cd.Spec.PreserveOnDelete = true
cd.Spec.Installed = false
return cd
}(),
testSecret(corev1.SecretTypeDockerConfigJson, pullSecretSecret, corev1.DockerConfigJsonKey, "{}"),
testSecret(corev1.SecretTypeDockerConfigJson, constants.GetMergedPullSecretName(testClusterDeployment()), corev1.DockerConfigJsonKey, "{}"),
},
validate: func(c client.Client, t *testing.T) {
deprovision := getDeprovision(c)
require.NotNil(t, deprovision, "expected deprovision request")
assert.Equal(t, testClusterDeployment().Name, deprovision.Labels[constants.ClusterDeploymentNameLabel], "incorrect cluster deployment name label")
},
},
{
name: "Create job to resolve installer image",
existing: []runtime.Object{
func() *hivev1.ClusterDeployment {
cd := testClusterDeploymentWithInitializedConditions(testClusterDeployment())
cd.Status.InstallerImage = nil
cd.Spec.Provisioning.ImageSetRef = &hivev1.ClusterImageSetReference{Name: testClusterImageSetName}
return cd
}(),
testClusterImageSet(),
testSecret(corev1.SecretTypeDockerConfigJson, pullSecretSecret, corev1.DockerConfigJsonKey, "{}"),
testSecret(corev1.SecretTypeDockerConfigJson, constants.GetMergedPullSecretName(testClusterDeployment()), corev1.DockerConfigJsonKey, "{}"),
},
validate: func(c client.Client, t *testing.T) {
job := getImageSetJob(c)
if job == nil {
t.Errorf("did not find expected imageset job")
}
// Ensure that the release image from the imageset is used in the job
envVars := job.Spec.Template.Spec.Containers[0].Env
for _, e := range envVars {
if e.Name == "RELEASE_IMAGE" {
if e.Value != testClusterImageSet().Spec.ReleaseImage {
t.Errorf("unexpected release image used in job: %s", e.Value)
}
break
}
}
// Ensure job type labels are set correctly
require.NotNil(t, job, "expected job")
assert.Equal(t, testClusterDeployment().Name, job.Labels[constants.ClusterDeploymentNameLabel], "incorrect cluster deployment name label")
assert.Equal(t, constants.JobTypeImageSet, job.Labels[constants.JobTypeLabel], "incorrect job type label")
},
},
{
name: "failed verification of release image using tags should set InstallImagesNotResolvedCondition",
existing: []runtime.Object{
func() *hivev1.ClusterDeployment {
cd := testClusterDeploymentWithInitializedConditions(testClusterDeployment())
cd.Status.InstallerImage = nil
cd.Spec.Provisioning.ImageSetRef = &hivev1.ClusterImageSetReference{Name: testClusterImageSetName}
return cd
}(),
testClusterImageSet(),
testCompletedFailedImageSetJob(),
testSecret(corev1.SecretTypeDockerConfigJson, pullSecretSecret, corev1.DockerConfigJsonKey, "{}"),
testSecret(corev1.SecretTypeDockerConfigJson, constants.GetMergedPullSecretName(testClusterDeployment()), corev1.DockerConfigJsonKey, "{}"),
},
riVerifier: verify.Reject,
validate: func(c client.Client, t *testing.T) {
cd := getCD(c)
testassert.AssertConditions(t, cd, []hivev1.ClusterDeploymentCondition{
{
Type: hivev1.InstallImagesNotResolvedCondition,
Status: corev1.ConditionTrue,
Reason: "ReleaseImageVerificationFailed",
},
})
},
},
{
name: "failed verification of release image using unknown digest should set InstallImagesNotResolvedCondition",
existing: []runtime.Object{
func() *hivev1.ClusterDeployment {
cd := testClusterDeploymentWithInitializedConditions(testClusterDeployment())
cd.Status.InstallerImage = nil
cd.Spec.Provisioning.ReleaseImage = "test-image@sha256:unknowndigest1"
return cd
}(),
testClusterImageSet(),
testCompletedFailedImageSetJob(),
testSecret(corev1.SecretTypeDockerConfigJson, pullSecretSecret, corev1.DockerConfigJsonKey, "{}"),
testSecret(corev1.SecretTypeDockerConfigJson, constants.GetMergedPullSecretName(testClusterDeployment()), corev1.DockerConfigJsonKey, "{}"),
},
riVerifier: imageVerifier,
validate: func(c client.Client, t *testing.T) {
cd := getCD(c)
testassert.AssertConditions(t, cd, []hivev1.ClusterDeploymentCondition{
{
Type: hivev1.InstallImagesNotResolvedCondition,
Status: corev1.ConditionTrue,
Reason: "ReleaseImageVerificationFailed",
},
})
},
},
{
name: "Create job to resolve installer image using verified image",
existing: []runtime.Object{
func() *hivev1.ClusterDeployment {
cd := testClusterDeploymentWithInitializedConditions(testClusterDeployment())
cd.Status.InstallerImage = nil
cd.Spec.Provisioning.ReleaseImage = "test-image@sha256:digest1"
return cd
}(),
testClusterImageSet(),
testSecret(corev1.SecretTypeDockerConfigJson, pullSecretSecret, corev1.DockerConfigJsonKey, "{}"),
testSecret(corev1.SecretTypeDockerConfigJson, constants.GetMergedPullSecretName(testClusterDeployment()), corev1.DockerConfigJsonKey, "{}"),
},
riVerifier: imageVerifier,
validate: func(c client.Client, t *testing.T) {
job := getImageSetJob(c)
if job == nil {
t.Errorf("did not find expected imageset job")
}
// Ensure that the release image from the imageset is used in the job
envVars := job.Spec.Template.Spec.Containers[0].Env
for _, e := range envVars {
if e.Name == "RELEASE_IMAGE" {
if e.Value != "test-image@sha256:digest1" {
t.Errorf("unexpected release image used in job: %s", e.Value)
}
break
}
}
// Ensure job type labels are set correctly
require.NotNil(t, job, "expected job")
assert.Equal(t, testClusterDeployment().Name, job.Labels[constants.ClusterDeploymentNameLabel], "incorrect cluster deployment name label")
assert.Equal(t, constants.JobTypeImageSet, job.Labels[constants.JobTypeLabel], "incorrect job type label")
},
},
{
name: "failed image should set InstallImagesNotResolved condition on clusterdeployment",
existing: []runtime.Object{
func() *hivev1.ClusterDeployment {
cd := testClusterDeploymentWithInitializedConditions(testClusterDeployment())
cd.Status.InstallerImage = nil
cd.Spec.Provisioning.ImageSetRef = &hivev1.ClusterImageSetReference{Name: testClusterImageSetName}
return cd
}(),
testClusterImageSet(),
testCompletedFailedImageSetJob(),
testSecret(corev1.SecretTypeDockerConfigJson, pullSecretSecret, corev1.DockerConfigJsonKey, "{}"),
testSecret(corev1.SecretTypeDockerConfigJson, constants.GetMergedPullSecretName(testClusterDeployment()), corev1.DockerConfigJsonKey, "{}"),
},
validate: func(c client.Client, t *testing.T) {
cd := getCD(c)
testassert.AssertConditions(t, cd, []hivev1.ClusterDeploymentCondition{
{
Type: hivev1.InstallImagesNotResolvedCondition,
Status: corev1.ConditionTrue,
Reason: "JobToResolveImagesFailed",
},
})
},
},
{
name: "clear InstallImagesNotResolved condition on success",
existing: []runtime.Object{
func() *hivev1.ClusterDeployment {
cd := testClusterDeploymentWithDefaultConditions(testClusterDeploymentWithInitializedConditions(testClusterDeployment()))
cd.Status.InstallerImage = pointer.StringPtr("test-installer-image")
cd.Status.CLIImage = pointer.StringPtr("test-cli-image")
cd.Spec.Provisioning.ImageSetRef = &hivev1.ClusterImageSetReference{Name: testClusterImageSetName}
cd.Status.Conditions = addOrUpdateClusterDeploymentCondition(*cd, hivev1.InstallImagesNotResolvedCondition,
corev1.ConditionTrue, "test-reason", "test-message")
return cd
}(),
testClusterImageSet(),
testCompletedImageSetJob(),
testSecret(corev1.SecretTypeDockerConfigJson, pullSecretSecret, corev1.DockerConfigJsonKey, "{}"),
testSecret(corev1.SecretTypeDockerConfigJson, constants.GetMergedPullSecretName(testClusterDeployment()), corev1.DockerConfigJsonKey, "{}"),
},
expectPendingCreation: true,
validate: func(c client.Client, t *testing.T) {
cd := getCD(c)
testassert.AssertConditionStatus(t, cd, hivev1.InstallImagesNotResolvedCondition, corev1.ConditionFalse)
},
},
{
name: "Delete imageset job when complete",
existing: []runtime.Object{
func() *hivev1.ClusterDeployment {
cd := testClusterDeploymentWithDefaultConditions(testClusterDeploymentWithInitializedConditions(testClusterDeployment()))
cd.Status.InstallerImage = pointer.StringPtr("test-installer-image")
cd.Status.CLIImage = pointer.StringPtr("test-cli-image")
cd.Spec.Provisioning.ImageSetRef = &hivev1.ClusterImageSetReference{Name: testClusterImageSetName}
return cd
}(),
testClusterImageSet(),
testCompletedImageSetJob(),
testSecret(corev1.SecretTypeDockerConfigJson, pullSecretSecret, corev1.DockerConfigJsonKey, "{}"),
testSecret(corev1.SecretTypeDockerConfigJson, constants.GetMergedPullSecretName(testClusterDeployment()), corev1.DockerConfigJsonKey, "{}"),
},
expectPendingCreation: true,
validate: func(c client.Client, t *testing.T) {
job := getImageSetJob(c)
assert.Nil(t, job, "expected imageset job to be deleted")
},
},
{
name: "Ensure release image from clusterdeployment (when present) is used to generate imageset job",
existing: []runtime.Object{
func() *hivev1.ClusterDeployment {
cd := testClusterDeploymentWithInitializedConditions(testClusterDeployment())
cd.Status.InstallerImage = nil
cd.Spec.Provisioning.ReleaseImage = "embedded-release-image:latest"
cd.Spec.Provisioning.ImageSetRef = &hivev1.ClusterImageSetReference{Name: testClusterImageSetName}
return cd
}(),
testClusterImageSet(),
testSecret(corev1.SecretTypeDockerConfigJson, pullSecretSecret, corev1.DockerConfigJsonKey, "{}"),
testSecret(corev1.SecretTypeDockerConfigJson, constants.GetMergedPullSecretName(testClusterDeployment()), corev1.DockerConfigJsonKey, "{}"),
},
validate: func(c client.Client, t *testing.T) {
job := getImageSetJob(c)
if job == nil {
t.Errorf("did not find expected imageset job")
}
envVars := job.Spec.Template.Spec.Containers[0].Env
for _, e := range envVars {
if e.Name == "RELEASE_IMAGE" {
if e.Value != "embedded-release-image:latest" {
t.Errorf("unexpected release image used in job: %s", e.Value)
}
break
}
}
},
},
{
name: "Ensure release image from clusterimageset is used as override image in install job",
existing: []runtime.Object{
func() *hivev1.ClusterDeployment {
cd := testClusterDeploymentWithDefaultConditions(testClusterDeploymentWithInitializedConditions(testClusterDeployment()))
cd.Status.InstallerImage = pointer.StringPtr("test-installer-image:latest")
cd.Spec.Provisioning.ImageSetRef = &hivev1.ClusterImageSetReference{Name: testClusterImageSetName}
return cd
}(),
func() *hivev1.ClusterImageSet {
cis := testClusterImageSet()
cis.Spec.ReleaseImage = "test-release-image:latest"
return cis
}(),
testSecret(corev1.SecretTypeDockerConfigJson, pullSecretSecret, corev1.DockerConfigJsonKey, "{}"),
testSecret(corev1.SecretTypeDockerConfigJson, constants.GetMergedPullSecretName(testClusterDeployment()), corev1.DockerConfigJsonKey, "{}"),
},
expectPendingCreation: true,
validate: func(c client.Client, t *testing.T) {
provisions := getProvisions(c)
if assert.Len(t, provisions, 1, "expected provision to exist") {
env := provisions[0].Spec.PodSpec.Containers[0].Env
variable := corev1.EnvVar{}
found := false
for _, e := range env {
if e.Name == "OPENSHIFT_INSTALL_RELEASE_IMAGE_OVERRIDE" {
variable = e
found = true
break
}
}
if !found {
t.Errorf("did not find expected override environment variable in job")
return
}
if variable.Value != "test-release-image:latest" {
t.Errorf("environment variable did not have the expected value. actual: %s", variable.Value)
}
}
},
},
{
name: "Create DNSZone when manageDNS is true",
existing: []runtime.Object{
func() *hivev1.ClusterDeployment {
cd := testClusterDeploymentWithInitializedConditions(testClusterDeployment())
cd.Spec.ManageDNS = true
return cd
}(),
testSecret(corev1.SecretTypeDockerConfigJson, pullSecretSecret, corev1.DockerConfigJsonKey, "{}"),
testSecret(corev1.SecretTypeDockerConfigJson, constants.GetMergedPullSecretName(testClusterDeployment()), corev1.DockerConfigJsonKey, "{}"),
},
validate: func(c client.Client, t *testing.T) {
zone := getDNSZone(c)
require.NotNil(t, zone, "dns zone should exist")
assert.Equal(t, testClusterDeployment().Name, zone.Labels[constants.ClusterDeploymentNameLabel], "incorrect cluster deployment name label")
assert.Equal(t, constants.DNSZoneTypeChild, zone.Labels[constants.DNSZoneTypeLabel], "incorrect dnszone type label")
},
},
{
name: "Wait when DNSZone is not available yet",
existing: []runtime.Object{
func() *hivev1.ClusterDeployment {
cd := testClusterDeploymentWithInitializedConditions(testClusterDeployment())
cd.Spec.ManageDNS = true
return cd
}(),
testSecret(corev1.SecretTypeDockerConfigJson, pullSecretSecret, corev1.DockerConfigJsonKey, "{}"),
testSecret(corev1.SecretTypeDockerConfigJson, constants.GetMergedPullSecretName(testClusterDeployment()), corev1.DockerConfigJsonKey, "{}"),
testDNSZone(),
},
expectedRequeueAfter: defaultDNSNotReadyTimeout + defaultRequeueTime,
validate: func(c client.Client, t *testing.T) {
provisions := getProvisions(c)
assert.Empty(t, provisions, "provision should not exist")
},
},
{
name: "Set condition when DNSZone is not available yet",
existing: []runtime.Object{
func() *hivev1.ClusterDeployment {
cd := testClusterDeploymentWithInitializedConditions(testClusterDeployment())
cd.Spec.ManageDNS = true
return cd
}(),
testSecret(corev1.SecretTypeDockerConfigJson, pullSecretSecret, corev1.DockerConfigJsonKey, "{}"),
testSecret(corev1.SecretTypeDockerConfigJson, constants.GetMergedPullSecretName(testClusterDeployment()), corev1.DockerConfigJsonKey, "{}"),
testDNSZone(),
},
expectedRequeueAfter: defaultDNSNotReadyTimeout + defaultRequeueTime,
validate: func(c client.Client, t *testing.T) {
cd := getCD(c)
testassert.AssertConditionStatus(t, cd, hivev1.DNSNotReadyCondition, corev1.ConditionTrue)
},
},
{
name: "Set condition when DNSZone cannot be created due to credentials missing permissions",
existing: []runtime.Object{
func() *hivev1.ClusterDeployment {
cd := testClusterDeploymentWithInitializedConditions(testClusterDeployment())
cd.Spec.ManageDNS = true
return cd
}(),
testSecret(corev1.SecretTypeDockerConfigJson, pullSecretSecret, corev1.DockerConfigJsonKey, "{}"),
testSecret(corev1.SecretTypeDockerConfigJson, constants.GetMergedPullSecretName(testClusterDeployment()), corev1.DockerConfigJsonKey, "{}"),
testDNSZoneWithInvalidCredentialsCondition(),
},
validate: func(c client.Client, t *testing.T) {
cd := getCD(c)
testassert.AssertConditions(t, cd, []hivev1.ClusterDeploymentCondition{
{
Type: hivev1.DNSNotReadyCondition,
Status: corev1.ConditionTrue,
Reason: "InsufficientCredentials",
},
})
},
},
{
name: "Set condition when DNSZone cannot be created due to authentication failure",
existing: []runtime.Object{
func() *hivev1.ClusterDeployment {
cd := testClusterDeploymentWithInitializedConditions(testClusterDeployment())
cd.Spec.ManageDNS = true
return cd
}(),
testSecret(corev1.SecretTypeDockerConfigJson, pullSecretSecret, corev1.DockerConfigJsonKey, "{}"),
testSecret(corev1.SecretTypeDockerConfigJson, constants.GetMergedPullSecretName(testClusterDeployment()), corev1.DockerConfigJsonKey, "{}"),
testDNSZoneWithAuthenticationFailureCondition(),
},
validate: func(c client.Client, t *testing.T) {
cd := getCD(c)
testassert.AssertConditions(t, cd, []hivev1.ClusterDeploymentCondition{
{
Type: hivev1.DNSNotReadyCondition,
Status: corev1.ConditionTrue,
Reason: "AuthenticationFailure",
},
})
},
},
{
name: "Clear condition when DNSZone is available",
existing: []runtime.Object{
func() *hivev1.ClusterDeployment {
cd := testClusterDeploymentWithInitializedConditions(testClusterDeployment())
cd.Spec.ManageDNS = true
cd.Status.Conditions = append(cd.Status.Conditions, hivev1.ClusterDeploymentCondition{
Type: hivev1.DNSNotReadyCondition,
Status: corev1.ConditionTrue,
})
return cd
}(),
testSecret(corev1.SecretTypeDockerConfigJson, pullSecretSecret, corev1.DockerConfigJsonKey, "{}"),
testSecret(corev1.SecretTypeDockerConfigJson, constants.GetMergedPullSecretName(testClusterDeployment()), corev1.DockerConfigJsonKey, "{}"),
testAvailableDNSZone(),
},
validate: func(c client.Client, t *testing.T) {
cd := getCD(c)
testassert.AssertConditionStatus(t, cd, hivev1.DNSNotReadyCondition, corev1.ConditionFalse)
},
},
{
name: "Do not use unowned DNSZone",
existing: []runtime.Object{
func() *hivev1.ClusterDeployment {
cd := testClusterDeploymentWithInitializedConditions(testClusterDeployment())
cd.Spec.ManageDNS = true
return cd
}(),
testSecret(corev1.SecretTypeDockerConfigJson, pullSecretSecret, corev1.DockerConfigJsonKey, "{}"),
testSecret(corev1.SecretTypeDockerConfigJson, constants.GetMergedPullSecretName(testClusterDeployment()), corev1.DockerConfigJsonKey, "{}"),
func() *hivev1.DNSZone {
zone := testDNSZone()
zone.OwnerReferences = []metav1.OwnerReference{}
return zone
}(),
},
expectErr: true,
validate: func(c client.Client, t *testing.T) {
cd := getCD(c)
if assert.NotNil(t, cd, "missing clusterdeployment") {
cond := controllerutils.FindClusterDeploymentCondition(cd.Status.Conditions, hivev1.DNSNotReadyCondition)
if assert.NotNil(t, cond, "expected to find condition") {
assert.Equal(t, corev1.ConditionTrue, cond.Status, "unexpected condition status")
assert.Equal(t, "Existing DNS zone not owned by cluster deployment", cond.Message, "unexpected condition message")
}
}
zone := getDNSZone(c)
assert.NotNil(t, zone, "expected DNSZone to exist")
},
},
{
name: "Do not use DNSZone owned by other clusterdeployment",
existing: []runtime.Object{
func() *hivev1.ClusterDeployment {
cd := testClusterDeploymentWithInitializedConditions(testClusterDeployment())
cd.Spec.ManageDNS = true
return cd
}(),
testSecret(corev1.SecretTypeDockerConfigJson, pullSecretSecret, corev1.DockerConfigJsonKey, "{}"),
testSecret(corev1.SecretTypeDockerConfigJson, constants.GetMergedPullSecretName(testClusterDeployment()), corev1.DockerConfigJsonKey, "{}"),
func() *hivev1.DNSZone {
zone := testDNSZone()
zone.OwnerReferences[0].UID = "other-uid"
return zone
}(),
},
expectErr: true,
validate: func(c client.Client, t *testing.T) {
cd := getCD(c)
if assert.NotNil(t, cd, "missing clusterdeployment") {
cond := controllerutils.FindClusterDeploymentCondition(cd.Status.Conditions, hivev1.DNSNotReadyCondition)
if assert.NotNil(t, cond, "expected to find condition") {
assert.Equal(t, corev1.ConditionTrue, cond.Status, "unexpected condition status")
assert.Equal(t, "Existing DNS zone not owned by cluster deployment", cond.Message, "unexpected condition message")
}
}
zone := getDNSZone(c)
assert.NotNil(t, zone, "expected DNSZone to exist")
},
},
{
name: "Create provision when DNSZone is ready",
existing: []runtime.Object{
func() *hivev1.ClusterDeployment {
cd := testClusterDeploymentWithDefaultConditions(testClusterDeploymentWithInitializedConditions(testClusterDeployment()))
cd.Spec.ManageDNS = true
cd.Annotations = map[string]string{dnsReadyAnnotation: "NOW"}
return cd
}(),
testSecret(corev1.SecretTypeDockerConfigJson, pullSecretSecret, corev1.DockerConfigJsonKey, "{}"),
testSecret(corev1.SecretTypeDockerConfigJson, constants.GetMergedPullSecretName(testClusterDeployment()), corev1.DockerConfigJsonKey, "{}"),
testAvailableDNSZone(),
},
expectPendingCreation: true,
validate: func(c client.Client, t *testing.T) {
provisions := getProvisions(c)
assert.Len(t, provisions, 1, "expected provision to exist")
},
},
{
name: "Set DNS delay metric",
existing: []runtime.Object{
func() *hivev1.ClusterDeployment {
cd := testClusterDeploymentWithInitializedConditions(testClusterDeployment())
cd.Spec.ManageDNS = true
return cd
}(),
testSecret(corev1.SecretTypeDockerConfigJson, pullSecretSecret, corev1.DockerConfigJsonKey, "{}"),
testSecret(corev1.SecretTypeDockerConfigJson, constants.GetMergedPullSecretName(testClusterDeployment()), corev1.DockerConfigJsonKey, "{}"),
testAvailableDNSZone(),
},
validate: func(c client.Client, t *testing.T) {
cd := getCD(c)
assert.NotNil(t, cd.Annotations, "annotations should be set on clusterdeployment")
assert.Contains(t, cd.Annotations, dnsReadyAnnotation)
},
},
{
name: "Ensure managed DNSZone is deleted with cluster deployment",
existing: []runtime.Object{
func() *hivev1.ClusterDeployment {
cd := testClusterDeploymentWithInitializedConditions(testDeletedClusterDeployment())
cd.Spec.ManageDNS = true
return cd
}(),
testSecret(corev1.SecretTypeDockerConfigJson, pullSecretSecret, corev1.DockerConfigJsonKey, "{}"),
testSecret(corev1.SecretTypeDockerConfigJson, constants.GetMergedPullSecretName(testClusterDeployment()), corev1.DockerConfigJsonKey, "{}"),
testDNSZone(),
},
validate: func(c client.Client, t *testing.T) {
dnsZone := getDNSZone(c)
assert.Nil(t, dnsZone, "dnsZone should not exist")
},
},
{
name: "Delete cluster deployment with missing clusterimageset",
existing: []runtime.Object{
func() *hivev1.ClusterDeployment {
cd := testClusterDeploymentWithInitializedConditions(testDeletedClusterDeployment())
cd.Spec.Provisioning.ImageSetRef = &hivev1.ClusterImageSetReference{Name: testClusterImageSetName}
return cd
}(),
testSecret(corev1.SecretTypeDockerConfigJson, pullSecretSecret, corev1.DockerConfigJsonKey, "{}"),
testSecret(corev1.SecretTypeDockerConfigJson, constants.GetMergedPullSecretName(testClusterDeployment()), corev1.DockerConfigJsonKey, "{}"),
},
validate: func(c client.Client, t *testing.T) {
deprovision := getDeprovision(c)
assert.NotNil(t, deprovision, "expected deprovision request to be created")
},
},
{
name: "Delete old provisions",
existing: []runtime.Object{
func() runtime.Object {
cd := testClusterDeploymentWithDefaultConditions(testClusterDeploymentWithInitializedConditions(testClusterDeployment()))
cd.Status.InstallRestarts = 4
return cd
}(),
testSecret(corev1.SecretTypeDockerConfigJson, pullSecretSecret, corev1.DockerConfigJsonKey, "{}"),
testSecret(corev1.SecretTypeDockerConfigJson, constants.GetMergedPullSecretName(testClusterDeployment()), corev1.DockerConfigJsonKey, "{}"),
testFailedProvisionAttempt(0),
testFailedProvisionAttempt(1),
testFailedProvisionAttempt(2),
testFailedProvisionAttempt(3),
},
expectPendingCreation: true,
validate: func(c client.Client, t *testing.T) {
actualAttempts := []int{}
for _, p := range getProvisions(c) {
actualAttempts = append(actualAttempts, p.Spec.Attempt)
}
expectedAttempts := []int{0, 2, 3, 4}