-
Notifications
You must be signed in to change notification settings - Fork 270
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
CNV-52722: Pass through extra VDDK configuration options to importer pod. #3572
base: main
Are you sure you want to change the base?
Changes from all commits
68ae900
c044ed6
ccca97f
d9ed451
fa0a87a
0fe6322
49cd30f
e66b180
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
apiVersion: cdi.kubevirt.io/v1beta1 | ||
kind: DataVolume | ||
metadata: | ||
name: "vddk-dv" | ||
namespace: "cdi" | ||
annotations: | ||
cdi.kubevirt.io/storage.pod.vddk.extraargs: vddk-arguments | ||
spec: | ||
source: | ||
vddk: | ||
backingFile: "[iSCSI_Datastore] vm/vm_1.vmdk" # From 'Hard disk'/'Disk File' in vCenter/ESX VM settings | ||
url: "https://vcenter.corp.com" | ||
uuid: "52260566-b032-36cb-55b1-79bf29e30490" | ||
thumbprint: "20:6C:8A:5D:44:40:B3:79:4B:28:EA:76:13:60:90:6E:49:D9:D9:A3" # SSL fingerprint of vCenter/ESX host | ||
secretRef: "vddk-credentials" | ||
initImageURL: "registry:5000/vddk-init:latest" | ||
storage: | ||
accessModes: | ||
- ReadWriteOnce | ||
resources: | ||
requests: | ||
storage: "32Gi" |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
apiVersion: v1 | ||
kind: ConfigMap | ||
metadata: | ||
namespace: cdi | ||
name: vddk-arguments | ||
data: | ||
vddk-config-file: -| | ||
VixDiskLib.nfcAio.Session.BufSizeIn64KB=16 | ||
VixDiskLib.nfcAio.Session.BufCount=4 |
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -168,6 +168,13 @@ func NewNbdkitVddk(nbdkitPidFile, socket string, args NbdKitVddkPluginArgs) (Nbd | |
pluginArgs = append(pluginArgs, "-D", "nbdkit.backend.datapath=0") | ||
pluginArgs = append(pluginArgs, "-D", "vddk.datapath=0") | ||
pluginArgs = append(pluginArgs, "-D", "vddk.stats=1") | ||
config, err := getVddkConfig() | ||
if err != nil { | ||
return nil, err | ||
} | ||
if config != "" { | ||
pluginArgs = append(pluginArgs, "config="+config) | ||
} | ||
p := getVddkPluginPath() | ||
n := &Nbdkit{ | ||
NbdPidFile: nbdkitPidFile, | ||
|
@@ -228,6 +235,22 @@ func getVddkPluginPath() NbdkitPlugin { | |
return NbdkitVddkPlugin | ||
} | ||
|
||
// Extra VDDK configuration options are stored in a ConfigMap mounted to the | ||
// importer pod. Just look for the first file in the mounted directory, and | ||
// pass that through nbdkit via the "config=" option. | ||
func getVddkConfig() (string, error) { | ||
path := filepath.Join(common.VddkArgsDir, common.VddkArgsKeyName) | ||
_, err := os.Stat(path) | ||
if err != nil { | ||
if os.IsNotExist(err) { // No configuration file found, so no extra arguments to give to VDDK | ||
return "", nil | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. NP: Please add a comment that the user did not specify the vddk additional config |
||
} | ||
return "", err | ||
} | ||
|
||
return path, nil | ||
} | ||
|
||
func (n *Nbdkit) getSourceArg(s string) string { | ||
var source string | ||
switch n.plugin { | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -12,6 +12,38 @@ import ( | |
"kubevirt.io/containerized-data-importer/tests/utils" | ||
) | ||
|
||
// CreateVddkDataVolume returns a VDDK data volume | ||
func (f *Framework) CreateVddkDataVolume(dataVolumeName, size, url string) *cdiv1.DataVolume { | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. How come something like this didn't already exist? |
||
// Find vcenter-simulator pod | ||
pod, err := utils.FindPodByPrefix(f.K8sClient, f.CdiInstallNs, "vcenter-deployment", "app=vcenter") | ||
gomega.Expect(err).ToNot(gomega.HaveOccurred()) | ||
gomega.Expect(pod).ToNot(gomega.BeNil()) | ||
|
||
// Get test VM UUID | ||
id, err := f.RunKubectlCommand("exec", "-n", pod.Namespace, pod.Name, "--", "cat", "/tmp/vmid") | ||
gomega.Expect(err).ToNot(gomega.HaveOccurred()) | ||
vmid, err := uuid.Parse(strings.TrimSpace(id)) | ||
gomega.Expect(err).ToNot(gomega.HaveOccurred()) | ||
|
||
// Get disk name | ||
disk, err := f.RunKubectlCommand("exec", "-n", pod.Namespace, pod.Name, "--", "cat", "/tmp/vmdisk") | ||
gomega.Expect(err).ToNot(gomega.HaveOccurred()) | ||
disk = strings.TrimSpace(disk) | ||
gomega.Expect(err).ToNot(gomega.HaveOccurred()) | ||
|
||
// Create VDDK login secret | ||
stringData := map[string]string{ | ||
common.KeyAccess: "user", | ||
common.KeySecret: "pass", | ||
} | ||
backingFile := disk | ||
secretRef := "vddksecret" | ||
thumbprint := "testprint" | ||
s, _ := utils.CreateSecretFromDefinition(f.K8sClient, utils.NewSecretDefinition(nil, stringData, nil, f.Namespace.Name, secretRef)) | ||
|
||
return utils.NewDataVolumeWithVddkImport(dataVolumeName, size, backingFile, s.Name, thumbprint, url, vmid.String()) | ||
} | ||
|
||
// CreateVddkWarmImportDataVolume fetches snapshot information from vcsim and returns a multi-stage VDDK data volume | ||
func (f *Framework) CreateVddkWarmImportDataVolume(dataVolumeName, size, url string) *cdiv1.DataVolume { | ||
// Find vcenter-simulator pod | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -189,6 +189,63 @@ var _ = Describe("[rfe_id:1115][crit:high][vendor:[email protected]][level:compo | |
Expect(importer.DeletionTimestamp).To(BeNil()) | ||
} | ||
}) | ||
|
||
It("[test_id:6689]succeed importing VDDK data volume with extra arguments ConfigMap set", Label("VDDK"), func() { | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Would you mind putting this under a separate describe so it doesn't inherit the "Serial" part? You can also change |
||
vddkConfigOptions := []string{ | ||
"VixDiskLib.nfcAio.Session.BufSizeIn64KB=16", | ||
"vixDiskLib.nfcAio.Session.BufCount=4", | ||
} | ||
|
||
vddkConfigMap := &v1.ConfigMap{ | ||
ObjectMeta: metav1.ObjectMeta{ | ||
Name: "vddk-extras", | ||
}, | ||
Data: map[string]string{ | ||
common.VddkArgsKeyName: strings.Join(vddkConfigOptions, "\n"), | ||
}, | ||
} | ||
|
||
_, err := f.K8sClient.CoreV1().ConfigMaps(f.Namespace.Name).Create(context.TODO(), vddkConfigMap, metav1.CreateOptions{}) | ||
if !k8serrors.IsAlreadyExists(err) { | ||
Expect(err).ToNot(HaveOccurred()) | ||
} | ||
|
||
vcenterURL := fmt.Sprintf(utils.VcenterURL, f.CdiInstallNs) | ||
dataVolume := f.CreateVddkDataVolume("import-pod-vddk-config-test", "100Mi", vcenterURL) | ||
|
||
By(fmt.Sprintf("Create new DataVolume %s", dataVolume.Name)) | ||
controller.AddAnnotation(dataVolume, controller.AnnPodRetainAfterCompletion, "true") | ||
controller.AddAnnotation(dataVolume, controller.AnnVddkExtraArgs, "vddk-extras") | ||
dataVolume, err = utils.CreateDataVolumeFromDefinition(f.CdiClient, f.Namespace.Name, dataVolume) | ||
Expect(err).ToNot(HaveOccurred()) | ||
|
||
By("Verify PVC was created") | ||
pvc, err := utils.WaitForPVC(f.K8sClient, dataVolume.Namespace, dataVolume.Name) | ||
Expect(err).ToNot(HaveOccurred()) | ||
f.ForceBindIfWaitForFirstConsumer(pvc) | ||
|
||
By("Wait for import to be completed") | ||
err = utils.WaitForDataVolumePhase(f, dataVolume.Namespace, cdiv1.Succeeded, dataVolume.Name) | ||
Expect(err).ToNot(HaveOccurred(), "DataVolume not in phase succeeded in time") | ||
|
||
By("Find importer pods after completion") | ||
pvcName := dataVolume.Name | ||
// When using populators, the PVC Prime name is used to build the importer pod | ||
if usePopulator, _ := dvc.CheckPVCUsingPopulators(pvc); usePopulator { | ||
pvcName = populators.PVCPrimeName(pvc) | ||
} | ||
By("Find importer pod " + pvcName) | ||
importer, err := utils.FindPodByPrefixOnce(f.K8sClient, dataVolume.Namespace, common.ImporterPodName, common.CDILabelSelector) | ||
Expect(err).ToNot(HaveOccurred()) | ||
Expect(importer.DeletionTimestamp).To(BeNil()) | ||
|
||
logs, err := f.RunKubectlCommand("logs", "-n", dataVolume.Namespace, importer.Name) | ||
Expect(err).ToNot(HaveOccurred()) | ||
for _, option := range vddkConfigOptions { | ||
By(fmt.Sprintf("Check for configuration value %s in nbdkit logs", option)) | ||
Expect(strings.Contains(logs, option)).To(BeTrue()) | ||
} | ||
}) | ||
}) | ||
|
||
var _ = Describe("[Istio] Namespace sidecar injection", Serial, func() { | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Just look for the first file
just note we need to be sure to document this so user does not chain the configs to separate configmaps.