Skip to content

Commit

Permalink
Introduce WCP_TKG_Multiple_CL FSS related changes
Browse files Browse the repository at this point in the history
  • Loading branch information
ridaz committed Mar 12, 2024
1 parent 7ce31b1 commit cedd33b
Show file tree
Hide file tree
Showing 9 changed files with 38 additions and 1 deletion.
2 changes: 2 additions & 0 deletions config/local/vmoperator/local_env_var_patch.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -32,4 +32,6 @@ spec:
- name: FSS_WCP_VMSERVICE_BACKUPRESTORE
value: "false"
- name: FSS_PODVMONSTRETCHEDSUPERVISOR
value: "false"
- name: FSS_WCP_TKG_Multiple_CL
value: "false"
6 changes: 6 additions & 0 deletions config/wcp/vmoperator/manager_env_var_patch.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -87,3 +87,9 @@
value:
name: FSS_PODVMONSTRETCHEDSUPERVISOR
value: "<FSS_PODVMONSTRETCHEDSUPERVISOR>"

- op: add
path: /spec/template/spec/containers/0/env/-
value:
name: FSS_WCP_TKG_Multiple_CL
value: "<FSS_WCP_TKG_Multiple_CL_VALUE>"
Original file line number Diff line number Diff line change
Expand Up @@ -245,13 +245,32 @@ func (r *Reconciler) setUpCVMIFromCCLItem(ctx *context.ClusterContentLibraryItem
return err
}

// Setting the label Key Prefix on the basis of
// WCP_TKG_Multiple_CL FSS is enabled or not

if cvmi.Labels == nil {
cvmi.Labels = make(map[string]string)
}

labelKeyPrefix := utils.TKGServiceTypeLabelKeyPrefix
if pkgconfig.FromContext(ctx).Features.TKGMultipleCL {
labelKeyPrefix = utils.MultipleCLServiceTypeLabelKeyPrefix

// Reconcile the labels between CCLItem and CVMI
// This should execute only for labels containing MultipleCLServiceTypeLabelKeyPrefix
for label := range cvmi.Labels {
if strings.HasPrefix(label, labelKeyPrefix) {
_, labelExists := cclItem.Labels[label]
if !labelExists {
delete(cvmi.Labels, label)
}
}
}
}

// Only watch for service type labels from ClusterContentLibraryItem
for label := range cclItem.Labels {
if strings.HasPrefix(label, "type.services.vmware.com/") {
if strings.HasPrefix(label, labelKeyPrefix) {
cvmi.Labels[label] = ""
}
}
Expand Down
3 changes: 3 additions & 0 deletions controllers/contentlibrary/v1alpha2/utils/constants.go
Original file line number Diff line number Diff line change
Expand Up @@ -13,4 +13,7 @@ const (

ContentLibraryItemVmopFinalizer = "contentlibraryitem.vmoperator.vmware.com"
ClusterContentLibraryItemVmopFinalizer = "clustercontentlibraryitem.vmoperator.vmware.com"

TKGServiceTypeLabelKeyPrefix = "type.services.vmware.com/"
MultipleCLServiceTypeLabelKeyPrefix = "services.supervisor.vmware.com/"
)
1 change: 1 addition & 0 deletions pkg/config/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -107,6 +107,7 @@ type FeatureStates struct {
VMClassAsConfigDayNDate bool // FSS_WCP_VM_CLASS_AS_CONFIG_DAYNDATE
VMOpV1Alpha2 bool // FSS_WCP_VMSERVICE_V1ALPHA2
PodVMOnStretchedSupervisor bool // FSS_PODVMONSTRETCHEDSUPERVISOR
TKGMultipleCL bool // FSS_WCP_TKG_Multiple_CL
}

type InstanceStorage struct {
Expand Down
1 change: 1 addition & 0 deletions pkg/config/default.go
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,7 @@ func Default() Config {
VMClassAsConfigDayNDate: true,
VMOpV1Alpha2: true,
PodVMOnStretchedSupervisor: false,
TKGMultipleCL: false,
},
InstanceStorage: InstanceStorage{
JitterMaxFactor: 1.0,
Expand Down
1 change: 1 addition & 0 deletions pkg/config/env.go
Original file line number Diff line number Diff line change
Expand Up @@ -57,6 +57,7 @@ func FromEnv() Config {
setBool(env.FSSWindowsSysprep, &config.Features.WindowsSysprep)
setBool(env.FSSVMServiceBackupRestore, &config.Features.AutoVADPBackupRestore)
setBool(env.FSSPodVMOnStretchedSupervisor, &config.Features.PodVMOnStretchedSupervisor)
setBool(env.FSSTKGMultipleCL, &config.Features.TKGMultipleCL)

return config
}
Expand Down
3 changes: 3 additions & 0 deletions pkg/config/env/env.go
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,7 @@ const (
FSSWindowsSysprep
FSSVMServiceBackupRestore
FSSPodVMOnStretchedSupervisor
FSSTKGMultipleCL

_varNameEnd
)
Expand Down Expand Up @@ -152,6 +153,8 @@ func (n VarName) String() string {
return "FSS_WCP_VMSERVICE_BACKUPRESTORE"
case FSSPodVMOnStretchedSupervisor:
return "FSS_PODVMONSTRETCHEDSUPERVISOR"
case FSSTKGMultipleCL:
return "FSS_WCP_TKG_Multiple_CL"
}
panic("unknown environment variable")
}
1 change: 1 addition & 0 deletions pkg/config/env_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -95,6 +95,7 @@ var _ = Describe(
Expect(os.Setenv("FSS_WCP_NAMESPACED_VM_CLASS", "false")).To(Succeed())
Expect(os.Setenv("FSS_WCP_WINDOWS_SYSPREP", "false")).To(Succeed())
Expect(os.Setenv("FSS_WCP_VMSERVICE_BACKUPRESTORE", "true")).To(Succeed())
Expect(os.Setenv("FSS_WCP_TKG_Multiple_CL", "false")).To(Succeed())
})
It("Should return a default config overridden by the environment", func() {
Expect(config).To(Equal(pkgconfig.Config{
Expand Down

0 comments on commit cedd33b

Please sign in to comment.