-
Notifications
You must be signed in to change notification settings - Fork 271
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 9 commits
68ae900
c044ed6
ccca97f
d9ed451
fa0a87a
0fe6322
49cd30f
e66b180
1120d5b
1a97ee5
488849f
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 |
---|---|---|
|
@@ -3463,6 +3463,65 @@ var _ = Describe("[vendor:[email protected]][level:component]DataVolume tests", | |
}), | ||
) | ||
}) | ||
|
||
Describe("extra configuration options for VDDK imports", func() { | ||
It("[test_id:XXXX]succeed importing VDDK data volume with extra arguments ConfigMap set", Label("VDDK"), func() { | ||
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 := 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()) | ||
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. You can use the pod logs API instead of kubectl, check this out: #3184 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. Done, the end of the log gets truncated though. I am going to try showing the whole log temporarily and see if it offers any insights. 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. So, it passes locally? 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. Yes, it passes locally. It also correctly fails if I add another ContainSubstring line, and I can see the target strings in the log output. 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. Interesting, the config argument is not getting passed to nbdkit:
I must have a mistake further up somewhere. 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. I see, I didn't get the annotations copied over correctly through the import populator stuff. The importer prime doesn't get the annotations, so I guess the pod doesn't get the ConfigMap mounted. I can reproduce this locally now. 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. I see, yeah usually the hot path is CSI storage (and thus populators). I assume you were not setting any |
||
} | ||
}) | ||
}) | ||
}) | ||
|
||
func SetFilesystemOverhead(f *framework.Framework, globalOverhead, scOverhead string) { | ||
|
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.