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

🌱 Adds inline Sysprep support for VM bootstrapping #298

Merged
merged 1 commit into from
Dec 19, 2023

Conversation

srm09
Copy link
Contributor

@srm09 srm09 commented Dec 11, 2023

What does this PR do, and why is it needed?
This patch adds support for inline sysprep which was introduced in the API in v1alpha2

Which issue(s) is/are addressed by this PR? (optional, in fixes #<issue number>(, fixes #<issue_number>, ...) format, will close the issue(s) when PR gets merged):
n/a

Are there any special notes for your reviewer:
For the secrets, we are currently decoding them and adding the data to the Data field under BootstrapArgs. There could be a situation wherein 2 or more secrets are storing data under the same key which will cause the secret values to be overidden.

Tests:

---
apiVersion: vmoperator.vmware.com/v1alpha2
kind: VirtualMachine
metadata:
  name:      win-inline-sysprep-with-cmd
  namespace: trial
spec:
  className:    best-effort-small
  imageName:    vmi-ddbfc45f73af5e7b1
  storageClass: wcpglobal-storage-profile
  powerState: PoweredOn
  bootstrap:
    sysprep:
      sysprep:
        guiRunOnce:
          commands: 
          - 'C:\sysprep\guestcustutil.exe restoreMountedDevices'
          - 'C:\sysprep\guestcustutil.exe flagComplete'
          - 'C:\sysprep\guestcustutil.exe deleteContainingFolder'
        userData:
          fullName: "First User"
          orgName: "Broadcom"

Please add a release note if necessary:

Adds inline sysprep support for VM bootstrapping

@github-actions github-actions bot added testing-needed-e2e-fast size/L Denotes a PR that changes 100-499 lines. labels Dec 11, 2023
@github-actions github-actions bot added size/XL Denotes a PR that changes 500-999 lines. and removed size/L Denotes a PR that changes 100-499 lines. labels Dec 12, 2023
@srm09 srm09 force-pushed the v1a2/sysprep-inline branch 3 times, most recently from 8e4f8b5 to a8dd2d9 Compare December 13, 2023 07:40
@srm09 srm09 changed the title WIP: Adds inline sysprep support for VM bootstrapping 🌱 Adds inline Sysprep support for VM bootstrapping Dec 13, 2023
@github-actions github-actions bot added size/XXL Denotes a PR that changes 1000+ lines. size/XL Denotes a PR that changes 500-999 lines. and removed size/XL Denotes a PR that changes 500-999 lines. size/XXL Denotes a PR that changes 1000+ lines. labels Dec 14, 2023
@github-actions github-actions bot added size/XXL Denotes a PR that changes 1000+ lines. and removed size/XL Denotes a PR that changes 500-999 lines. labels Dec 15, 2023
@srm09 srm09 force-pushed the v1a2/sysprep-inline branch 2 times, most recently from 74a2608 to 658804b Compare December 15, 2023 19:25
Copy link
Contributor

@bryanv bryanv left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM but the tests need to updated to not use prior common key selector structure.

This patch adds support for inline sysprep which was introduced in the
API in v1alpha2. For the secrets, we are currently decoding them and
adding the values SysprepSecretData field under BootstrapArgs.

This patch also adds tests for the changes to enable inline sysprep.

Instead of waiting till doBootstrap to pull the secret data for inline
sysprep, this patch adds the secret data to the BootstrapArgs earlier
for verification purposes.

It updates the API to mark certain fields as mandatory.

This patch moves the defaulting logic of the secret selector keys to the
CRDs instead of relying on a mutating webhook

Signed-off-by: Sagar Muchhal <[email protected]>
Copy link

Code Coverage

Package Line Rate Health
github.com/vmware-tanzu/vm-operator/api/utilconversion 91%
github.com/vmware-tanzu/vm-operator/api/v1alpha1 36%
github.com/vmware-tanzu/vm-operator/api/v1alpha2 28%
github.com/vmware-tanzu/vm-operator/api/v1alpha2/cloudinit 24%
github.com/vmware-tanzu/vm-operator/api/v1alpha2/common 15%
github.com/vmware-tanzu/vm-operator/api/v1alpha2/sysprep 29%
github.com/vmware-tanzu/vm-operator/controllers/contentlibrary/v1alpha1/clustercontentlibraryitem 83%
github.com/vmware-tanzu/vm-operator/controllers/contentlibrary/v1alpha1/contentlibraryitem 82%
github.com/vmware-tanzu/vm-operator/controllers/contentlibrary/v1alpha1/contentsource 87%
github.com/vmware-tanzu/vm-operator/controllers/contentlibrary/v1alpha1/utils 95%
github.com/vmware-tanzu/vm-operator/controllers/contentlibrary/v1alpha2/clustercontentlibraryitem 86%
github.com/vmware-tanzu/vm-operator/controllers/contentlibrary/v1alpha2/contentlibraryitem 85%
github.com/vmware-tanzu/vm-operator/controllers/contentlibrary/v1alpha2/utils 91%
github.com/vmware-tanzu/vm-operator/controllers/infracluster 75%
github.com/vmware-tanzu/vm-operator/controllers/infraprovider 75%
github.com/vmware-tanzu/vm-operator/controllers/providerconfigmap 74%
github.com/vmware-tanzu/vm-operator/controllers/util/encoding 73%
github.com/vmware-tanzu/vm-operator/controllers/util/remote 41%
github.com/vmware-tanzu/vm-operator/controllers/virtualmachine/v1alpha1 45%
github.com/vmware-tanzu/vm-operator/controllers/virtualmachine/v1alpha2 70%
github.com/vmware-tanzu/vm-operator/controllers/virtualmachineclass/v1alpha1 31%
github.com/vmware-tanzu/vm-operator/controllers/virtualmachineclass/v1alpha2 22%
github.com/vmware-tanzu/vm-operator/controllers/virtualmachinepublishrequest/v1alpha1 83%
github.com/vmware-tanzu/vm-operator/controllers/virtualmachinepublishrequest/v1alpha2 81%
github.com/vmware-tanzu/vm-operator/controllers/virtualmachineservice/v1alpha1 82%
github.com/vmware-tanzu/vm-operator/controllers/virtualmachineservice/v1alpha1/providers 96%
github.com/vmware-tanzu/vm-operator/controllers/virtualmachineservice/v1alpha1/providers/simplelb 66%
github.com/vmware-tanzu/vm-operator/controllers/virtualmachineservice/v1alpha1/utils 84%
github.com/vmware-tanzu/vm-operator/controllers/virtualmachineservice/v1alpha2 84%
github.com/vmware-tanzu/vm-operator/controllers/virtualmachineservice/v1alpha2/providers 96%
github.com/vmware-tanzu/vm-operator/controllers/virtualmachineservice/v1alpha2/providers/simplelb 66%
github.com/vmware-tanzu/vm-operator/controllers/virtualmachineservice/v1alpha2/utils 84%
github.com/vmware-tanzu/vm-operator/controllers/virtualmachinesetresourcepolicy/v1alpha1 80%
github.com/vmware-tanzu/vm-operator/controllers/virtualmachinesetresourcepolicy/v1alpha2 80%
github.com/vmware-tanzu/vm-operator/controllers/virtualmachinewebconsolerequest/v1alpha1 74%
github.com/vmware-tanzu/vm-operator/controllers/virtualmachinewebconsolerequest/v1alpha2 72%
github.com/vmware-tanzu/vm-operator/controllers/volume/v1alpha1 86%
github.com/vmware-tanzu/vm-operator/controllers/volume/v1alpha2 87%
github.com/vmware-tanzu/vm-operator/pkg/builder 73%
github.com/vmware-tanzu/vm-operator/pkg/conditions 90%
github.com/vmware-tanzu/vm-operator/pkg/conditions2 92%
github.com/vmware-tanzu/vm-operator/pkg/context 0%
github.com/vmware-tanzu/vm-operator/pkg/context/fake 100%
github.com/vmware-tanzu/vm-operator/pkg/lib 85%
github.com/vmware-tanzu/vm-operator/pkg/manager 78%
github.com/vmware-tanzu/vm-operator/pkg/metrics 90%
github.com/vmware-tanzu/vm-operator/pkg/metrics2 85%
github.com/vmware-tanzu/vm-operator/pkg/patch 79%
github.com/vmware-tanzu/vm-operator/pkg/patch2 78%
github.com/vmware-tanzu/vm-operator/pkg/prober 92%
github.com/vmware-tanzu/vm-operator/pkg/prober/context 100%
github.com/vmware-tanzu/vm-operator/pkg/prober/fake 85%
github.com/vmware-tanzu/vm-operator/pkg/prober/fake/probe 83%
github.com/vmware-tanzu/vm-operator/pkg/prober/fake/worker 88%
github.com/vmware-tanzu/vm-operator/pkg/prober/probe 83%
github.com/vmware-tanzu/vm-operator/pkg/prober/worker 86%
github.com/vmware-tanzu/vm-operator/pkg/prober2 91%
github.com/vmware-tanzu/vm-operator/pkg/prober2/context 100%
github.com/vmware-tanzu/vm-operator/pkg/prober2/fake 85%
github.com/vmware-tanzu/vm-operator/pkg/prober2/fake/probe 83%
github.com/vmware-tanzu/vm-operator/pkg/prober2/fake/worker 89%
github.com/vmware-tanzu/vm-operator/pkg/prober2/probe 92%
github.com/vmware-tanzu/vm-operator/pkg/prober2/worker 80%
github.com/vmware-tanzu/vm-operator/pkg/record 89%
github.com/vmware-tanzu/vm-operator/pkg/topology 85%
github.com/vmware-tanzu/vm-operator/pkg/util 86%
github.com/vmware-tanzu/vm-operator/pkg/util/cloudinit 90%
github.com/vmware-tanzu/vm-operator/pkg/util/cloudinit/schema 25%
github.com/vmware-tanzu/vm-operator/pkg/util/cloudinit/validate 92%
github.com/vmware-tanzu/vm-operator/pkg/util/kube 89%
github.com/vmware-tanzu/vm-operator/pkg/util/vsphere/vm 74%
github.com/vmware-tanzu/vm-operator/pkg/vmprovider/fake 74%
github.com/vmware-tanzu/vm-operator/pkg/vmprovider/providers/vsphere 71%
github.com/vmware-tanzu/vm-operator/pkg/vmprovider/providers/vsphere/client 49%
github.com/vmware-tanzu/vm-operator/pkg/vmprovider/providers/vsphere/clustermodules 85%
github.com/vmware-tanzu/vm-operator/pkg/vmprovider/providers/vsphere/config 85%
github.com/vmware-tanzu/vm-operator/pkg/vmprovider/providers/vsphere/contentlibrary 71%
github.com/vmware-tanzu/vm-operator/pkg/vmprovider/providers/vsphere/credentials 100%
github.com/vmware-tanzu/vm-operator/pkg/vmprovider/providers/vsphere/instancestorage 92%
github.com/vmware-tanzu/vm-operator/pkg/vmprovider/providers/vsphere/internal 0%
github.com/vmware-tanzu/vm-operator/pkg/vmprovider/providers/vsphere/network 88%
github.com/vmware-tanzu/vm-operator/pkg/vmprovider/providers/vsphere/placement 83%
github.com/vmware-tanzu/vm-operator/pkg/vmprovider/providers/vsphere/resources 47%
github.com/vmware-tanzu/vm-operator/pkg/vmprovider/providers/vsphere/session 84%
github.com/vmware-tanzu/vm-operator/pkg/vmprovider/providers/vsphere/storage 77%
github.com/vmware-tanzu/vm-operator/pkg/vmprovider/providers/vsphere/test 98%
github.com/vmware-tanzu/vm-operator/pkg/vmprovider/providers/vsphere/vcenter 80%
github.com/vmware-tanzu/vm-operator/pkg/vmprovider/providers/vsphere/virtualmachine 83%
github.com/vmware-tanzu/vm-operator/pkg/vmprovider/providers/vsphere2 70%
github.com/vmware-tanzu/vm-operator/pkg/vmprovider/providers/vsphere2/client 49%
github.com/vmware-tanzu/vm-operator/pkg/vmprovider/providers/vsphere2/clustermodules 85%
github.com/vmware-tanzu/vm-operator/pkg/vmprovider/providers/vsphere2/config 70%
github.com/vmware-tanzu/vm-operator/pkg/vmprovider/providers/vsphere2/contentlibrary 72%
github.com/vmware-tanzu/vm-operator/pkg/vmprovider/providers/vsphere2/credentials 100%
github.com/vmware-tanzu/vm-operator/pkg/vmprovider/providers/vsphere2/instancestorage 92%
github.com/vmware-tanzu/vm-operator/pkg/vmprovider/providers/vsphere2/internal 0%
github.com/vmware-tanzu/vm-operator/pkg/vmprovider/providers/vsphere2/network 85%
github.com/vmware-tanzu/vm-operator/pkg/vmprovider/providers/vsphere2/placement 70%
github.com/vmware-tanzu/vm-operator/pkg/vmprovider/providers/vsphere2/resources 38%
github.com/vmware-tanzu/vm-operator/pkg/vmprovider/providers/vsphere2/session 83%
github.com/vmware-tanzu/vm-operator/pkg/vmprovider/providers/vsphere2/storage 77%
github.com/vmware-tanzu/vm-operator/pkg/vmprovider/providers/vsphere2/sysprep 100%
github.com/vmware-tanzu/vm-operator/pkg/vmprovider/providers/vsphere2/test 98%
github.com/vmware-tanzu/vm-operator/pkg/vmprovider/providers/vsphere2/vcenter 80%
github.com/vmware-tanzu/vm-operator/pkg/vmprovider/providers/vsphere2/virtualmachine 84%
github.com/vmware-tanzu/vm-operator/pkg/vmprovider/providers/vsphere2/vmlifecycle 79%
github.com/vmware-tanzu/vm-operator/pkg/webconsolevalidation 53%
github.com/vmware-tanzu/vm-operator/webhooks/common 100%
github.com/vmware-tanzu/vm-operator/webhooks/persistentvolumeclaim/validation 95%
github.com/vmware-tanzu/vm-operator/webhooks/virtualmachine/v1alpha1/mutation 81%
github.com/vmware-tanzu/vm-operator/webhooks/virtualmachine/v1alpha1/validation 94%
github.com/vmware-tanzu/vm-operator/webhooks/virtualmachine/v1alpha2/mutation 81%
github.com/vmware-tanzu/vm-operator/webhooks/virtualmachine/v1alpha2/validation 95%
github.com/vmware-tanzu/vm-operator/webhooks/virtualmachineclass/v1alpha1/mutation 59%
github.com/vmware-tanzu/vm-operator/webhooks/virtualmachineclass/v1alpha1/validation 89%
github.com/vmware-tanzu/vm-operator/webhooks/virtualmachineclass/v1alpha2/mutation 62%
github.com/vmware-tanzu/vm-operator/webhooks/virtualmachineclass/v1alpha2/validation 89%
github.com/vmware-tanzu/vm-operator/webhooks/virtualmachinepublishrequest/v1alpha1/validation 92%
github.com/vmware-tanzu/vm-operator/webhooks/virtualmachinepublishrequest/v1alpha2/validation 92%
github.com/vmware-tanzu/vm-operator/webhooks/virtualmachineservice/v1alpha1/mutation 62%
github.com/vmware-tanzu/vm-operator/webhooks/virtualmachineservice/v1alpha1/validation 91%
github.com/vmware-tanzu/vm-operator/webhooks/virtualmachineservice/v1alpha2/mutation 67%
github.com/vmware-tanzu/vm-operator/webhooks/virtualmachineservice/v1alpha2/validation 91%
github.com/vmware-tanzu/vm-operator/webhooks/virtualmachinesetresourcepolicy/v1alpha1/mutation 62%
github.com/vmware-tanzu/vm-operator/webhooks/virtualmachinesetresourcepolicy/v1alpha1/validation 89%
github.com/vmware-tanzu/vm-operator/webhooks/virtualmachinesetresourcepolicy/v1alpha2/validation 89%
github.com/vmware-tanzu/vm-operator/webhooks/virtualmachinewebconsolerequest/v1alpha1/validation 92%
github.com/vmware-tanzu/vm-operator/webhooks/virtualmachinewebconsolerequest/v1alpha2/validation 92%
Summary 70% (13531 / 19421)

Minimum allowed line rate is 60%

@srm09 srm09 merged commit 1075cc2 into vmware-tanzu:main Dec 19, 2023
12 checks passed
@srm09 srm09 deleted the v1a2/sysprep-inline branch December 19, 2023 08:11
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
cla-not-required size/XXL Denotes a PR that changes 1000+ lines. testing-needed-e2e-fast
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants