vmware / govmomi

Go library for the VMware vSphere API
Apache License 2.0
2.31k stars 911 forks source link

[BUG] govc import.ova give govc: file does not exist during upload of OVA file on vcenter #3087

Closed apansuria01 closed 1 year ago

apansuria01 commented 1 year ago

Describe the bug

govc import.ova give govc: file does not exist error during upload of OVA file on vcenter

To Reproduce Steps to reproduce the behavior:

  1. download and install govc govc 0.30.4 on linux
  2. copy ova file on linux system
  3. setup environment variables

    export GOVC_URL=insntdvitfarm.apac.avaya.com export GOVC_USERNAME=falcon@global.avaya.com export GOVC_PASSWORD=** export GOVC_INSECURE="true" export GOVC_DATACENTER="Pune_Shared" export GOVC_DATASTORE="SharedVol-VxFlex2-02" export GOVC_HOST="pusntesxi165.apac.avaya.com" export GOVC_RESOURCE_POOL="Cluster4_AnalyticsService_ESPLABS-2424" export GOVC_FOLDER="Cluster4_AnalyticsService_ESPLABS-2424" export GOVC_NETWORK="VMTDPG_10_133_16_X" export GOVC_DEBUG="true" export GOVC_CLUSTER=Shared_Cluster4

  4. run below command to upload ova

[root@oceanadev16 ova]# govc import.ova -options=options.json -persist-session=true -json=true -debug=true /root/amit/amit1/ccaas-analytics/kube-ansible/ova/k8s-1.23.10-tmpl.ova govc: file does not exist

Expected behavior It should upload ova file without error

Affected version govc version govc 0.30.4 [root@oceanadev16 ova]# govc about FullName: VMware vCenter Server 7.0.3 build-19480866 Name: VMware vCenter Server Vendor: VMware, Inc. Version: 7.0.3 Build: 19480866 OS type: linux-x64 API type: VirtualCenter API version: 7.0.3.0 Product ID: vpx UUID: f091a68b-21fe-455e-bd9a-0f5a4d246bcd

Screenshots/Debug Output find the attached screen shot

govc

Additional context Add any other context about the problem here.

github-actions[bot] commented 1 year ago

Howdy 🖐   apansuria01 ! Thank you for your interest in this project. We value your feedback and will respond soon.

If you want to contribute to this project, please make yourself familiar with the CONTRIBUTION guidelines.

dougm commented 1 year ago

govc: file does not exist

Could be either options.json or the .ova, but those errors would include the file name like so:

govc: open options.json: no such file or directory

govc: open /root/amit/amit1/ccaas-analytics/kube-ansible/ova/k8s-1.23.10-tmpl.ova: no such file or directory

Did you also create the file options.json ?

apansuria01 commented 1 year ago

Hi Dougm,

Thank you for your reply. actually both files are present at same location.

[root@oceanadev16 ova]# ll total 1650492 -rwxr-xr-x 1 root root 661 Mar 7 20:57 debug-xmlformat.sh drwxr-xr-x 2 root root 4096 Apr 6 15:18 env -rwxr-xr-x 1 root root 1035 Mar 8 15:44 govc-util.sh -rwxr-xr-x 1 root root 3176 Mar 8 15:41 import-ova.sh -rwxr-xr-x 1 root root 3361 Mar 8 11:25 import-ova.sh.bkp -rwxr-xr-x 1 root root 3172 Mar 7 21:57 import-ova.sh.orig -rwxr-xr-x 1 root root 1690060800 Mar 8 10:13 k8s-1.21.11-tmpl.ova -rw-r--r-- 1 root root 679 Apr 6 15:21 options.json -rw-r--r-- 1 root root 670 Mar 8 10:19 options.json.tmpl -rw-r--r-- 1 root root 822 Mar 7 20:57 README.md -rwxr-xr-x 1 root root 1146 Apr 5 12:46 test.sh

Regards, Amit

dougm commented 1 year ago

If you run the command using strace -f: strace -f govc ...

The output should show which file it can't find, for example you'd see something like:

[pid 32901] openat(AT_FDCWD, "foo.ova", O_RDONLY|O_CLOEXEC <unfinished ...>
[pid 32901] <... openat resumed>)       = -1 ENOENT (No such file or directory)
apansuria01 commented 1 year ago

Hi Dougm,

Thank you for your response.

strace -f govc import.ova -options=options.json -persist-session=true -json=true -debug=true /root/amit/amit1/kube-ansible/ova/k8s-1.23.10-tmpl.ova

[pid 10192] nanosleep({tv_sec=0, tv_nsec=20000}, <unfinished ...> [pid 10197] futex(0xc000088148, FUTEX_WAKE_PRIVATE, 1) = 1 [pid 10195] <... futex resumed>) = 0 [pid 10195] nanosleep({tv_sec=0, tv_nsec=3000}, <unfinished ...> [pid 10197] write(2, "govc: file does not exist\n", 26 <unfinished ...> [pid 10192] <... nanosleep resumed>NULL) = 0 govc: file does not exist [pid 10197] <... write resumed>) = 26 [pid 10192] nanosleep({tv_sec=0, tv_nsec=20000}, <unfinished ...> [pid 10197] exit_group(1 <unfinished ...> [pid 10195] <... nanosleep resumed>NULL) = 0 [pid 10198] <... futex resumed>) = ? [pid 10197] <... exit_group resumed>) = ? [pid 10192] <... nanosleep resumed> <unfinished ...>) = ? [pid 10191] <... epoll_pwait resumed> <unfinished ...>) = ? [pid 10194] <... futex resumed>) = ? [pid 10193] <... futex resumed>) = ? [pid 10198] +++ exited with 1 +++ [pid 10195] +++ exited with 1 +++ [pid 10197] +++ exited with 1 +++ [pid 10194] +++ exited with 1 +++ [pid 10192] +++ exited with 1 +++ [pid 10193] +++ exited with 1 +++ +++ exited with 1 +++

Regards, Amit

dougm commented 1 year ago

That's not the entire strace output, just what's visible in your term window? You can use the strace -o to write to a file instead: strace -f -o strace.log govc ...

apansuria01 commented 1 year ago

Hi Dougm,

I agreed with you it is not entire strace output.I redirect the output to log file as per your suggestion. please find the attached "stage.log" file.

strace.log

Regards, Amit

dougm commented 1 year ago

Thanks, I can see from the strace govc has opened the .ova file and is searching for a file within the archive. It can't find the file and returns the error here: https://github.com/vmware/govmomi/blob/aae3b7bf6426cf6eec9ed4b5b21b5090390ac283/govc/importx/archive.go#L143

os.ErrNotExist is where the "file does not exist" message comes from. We can change govc to include the file name with that error message. In the meantime, you can extract the archive:

tar -xvf k8s-1.23.10-tmpl.ova

Then instead of govc import.ova, use govc import.ovf ... with the same options, but change k8s-1.23.10-tmpl.ova to k8s-1.23.10-tmpl.ovf that was extracted from the ova. Since import.ovf reads files from disk, rather than the ova/tar, the filename will be included in the error message.

Are you able to deploy this .ova using the vCenter UI?

apansuria01 commented 1 year ago

Hi Dougm,

Thank you for your reply.I am not able to deploy this ova from UI. also I am confuse what to do next now? Do I need to re-package OVA? or what? kindly request you to provide clear step.

Regards, Amit

dougm commented 1 year ago

What was the UI error? And did you try with govc import.ovf instead of ova? In any case, sounds like an issue with the ova itself.

apansuria01 commented 1 year ago

Hi Dougm,

when I try to upload ova from UI it say "Selected OVA file is not a valid template."

If I try using ovf instead of ova using govc it uploaded successfully as below

[root@oceanadev16 ova]# govc import.ovf -options=options.json -persist-session=true -json=true -debug=true test/k8s-1.23.10-tmpl.ovf [root@oceanadev16 ova]# echo $? 0

However if I run below it does not return any thing

[root@oceanadev16 ova]# govc vm.info k8s-1.23.10-tmpl.ovf

Regards, Amit

dougm commented 1 year ago

ok, if the UI says its not valid, then not an issue with govc, but the ova itself. I don't know what the ova issue is. As for import.ovf, I would expect the VM name to not have the .ovf extension, so vm.info isn't finding your vm with that name. Did you see a new vm/task after the import.ovf in the UI? Or with govc:

% govc tasks
% govc find / -type m
apansuria01 commented 1 year ago

Hi Dougm,

I am getting below output after upload of .ovf using govc

[root@oceanadev16 ova]# govc tasks Task Target Initiator Queued Started Completed Result

[root@oceanadev16 ova]# govc find / -type m | grep k8s-1.23 /Pune_Shared/vm/Cluster4_AnalyticsService_ESPLABS-2424/k8s-1.23.10-tmpl [root@oceanadev16 ova]#

However govc vm.info does not provide any output.

Regards, Amit

github-actions[bot] commented 1 year ago

This issue is stale because it has been open for 90 days with no activity. It will automatically close after 30 more days of inactivity. Mark as fresh by adding the comment /remove-lifecycle stale.