Skip to content
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

[release-1.11] fix: Allow disabling of common data import crons #3112

Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions controllers/operands/ssp.go
Original file line number Diff line number Diff line change
Expand Up @@ -307,6 +307,10 @@ func isDataImportCronTemplateEnabled(dict hcov1beta1.DataImportCronTemplate) boo

func getCustomDicts(list []hcov1beta1.DataImportCronTemplateStatus, crDicts map[string]hcov1beta1.DataImportCronTemplate) []hcov1beta1.DataImportCronTemplateStatus {
for dictName, crDict := range crDicts {
if !isDataImportCronTemplateEnabled(crDict) {
continue
}

if _, isCommon := dataImportCronTemplateHardCodedMap[dictName]; !isCommon {
list = append(list, hcov1beta1.DataImportCronTemplateStatus{
DataImportCronTemplate: *crDict.DeepCopy(),
Expand Down
23 changes: 23 additions & 0 deletions controllers/operands/ssp_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -769,6 +769,29 @@ var _ = Describe("SSP Operands", func() {
Expect(goldenImageList).To(ContainElements(*statusImage2Enabled, statusImage3, statusImage4))
})

It("should not add user DIC template if it is disabled", func() {
dataImportCronTemplateHardCodedMap = nil
hco := commontestutils.NewHco()
hco.Spec.FeatureGates.EnableCommonBootImageImport = ptr.To(true)

disabledUserImage := image1.DeepCopy()
disableDict(disabledUserImage)
enabledUserImage := image2.DeepCopy()
enableDict(enabledUserImage)

hco.Spec.DataImportCronTemplates = []hcov1beta1.DataImportCronTemplate{*disabledUserImage, *enabledUserImage}
goldenImageList, err := getDataImportCronTemplates(hco)
Expect(err).ToNot(HaveOccurred())
Expect(goldenImageList).To(HaveLen(1))

statusImageEnabled := hcov1beta1.DataImportCronTemplateStatus{
DataImportCronTemplate: *enabledUserImage,
Status: hcov1beta1.DataImportCronStatus{},
}

Expect(goldenImageList).To(ContainElements(statusImageEnabled))
})

It("Should reject if the CR list contain DIC templates with the same name, when there are also common DIC templates", func() {
dataImportCronTemplateHardCodedMap = map[string]hcov1beta1.DataImportCronTemplate{
image1.Name: image1,
Expand Down
Loading