From d592acd80497975236c0cb296cca6ca78f9b39da Mon Sep 17 00:00:00 2001 From: Richard Cox <18697775+richard-cox@users.noreply.github.com> Date: Fri, 8 Nov 2024 12:35:54 +0100 Subject: [PATCH] Merge pull request #12547 from momesgin/12530-prebootstrap-flag Take `prebootstrap` flag into account before creating vSphere secrets --- shell/store/features.js | 1 + shell/utils/v-sphere.ts | 26 ++++++++++++++++++++++++++ 2 files changed, 27 insertions(+) diff --git a/shell/store/features.js b/shell/store/features.js index d74d4359682..e0911626dd3 100644 --- a/shell/store/features.js +++ b/shell/store/features.js @@ -32,6 +32,7 @@ export const FLEET = create('continuous-delivery', true); export const HARVESTER = create('harvester', true); export const HARVESTER_CONTAINER = create('harvester-baremetal-container-workload', false); export const FLEET_WORKSPACE_BACK = create('provisioningv2-fleet-workspace-back-population', false); +export const PROVISIONING_PRE_BOOTSTRAP = create('provisioningprebootstrap', false); // Not currently used.. no point defining ones we don't use // export const EMBEDDED_CLUSTER_API = create('embedded-cluster-api', true); diff --git a/shell/utils/v-sphere.ts b/shell/utils/v-sphere.ts index 4e1efbdf439..2111412ced9 100644 --- a/shell/utils/v-sphere.ts +++ b/shell/utils/v-sphere.ts @@ -1,5 +1,8 @@ import merge from 'lodash/merge'; import { SECRET } from '@shell/config/types'; +import { PROVISIONING_PRE_BOOTSTRAP } from '@shell/store/features'; + +export const VMWARE_VSPHERE = 'vmwarevsphere'; type Rke2Component = { versionInfo: any; @@ -7,6 +10,7 @@ type Rke2Component = { chartVersionKey: (chartName: string) => string; value: any; isEdit: boolean; + provider: string; $store: any, } @@ -88,10 +92,28 @@ class VSphereUtils { }; } + private handleVsphereSecret({ $store, provider }: { $store: any, provider: string}): boolean { + if (provider !== VMWARE_VSPHERE) { + return false; + } + + const isPrebootstrapEnabled = $store.getters['features/get'](PROVISIONING_PRE_BOOTSTRAP); + + if (!isPrebootstrapEnabled) { + return false; + } + + return true; + } + /** * Create upstream vsphere cpi secret to sync downstream */ async handleVsphereCpiSecret(rke2Component: Rke2Component) { + if (!this.handleVsphereSecret(rke2Component)) { + return; + } + const generateName = `${ rootGenerateName }cpi-`; const downstreamName = 'rancher-vsphere-cpi-credentials'; const downstreamNamespace = 'kube-system'; @@ -165,6 +187,10 @@ class VSphereUtils { * Create upstream vsphere csi secret to sync downstream */ async handleVsphereCsiSecret(rke2Component: Rke2Component) { + if (!this.handleVsphereSecret(rke2Component)) { + return; + } + const generateName = `${ rootGenerateName }csi-`; const downstreamName = 'rancher-vsphere-csi-credentials'; const downstreamNamespace = 'kube-system';