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

Make virtctl console wait for console to become ready #1001

Closed
booxter opened this issue May 7, 2018 · 10 comments · Fixed by #1323
Closed

Make virtctl console wait for console to become ready #1001

booxter opened this issue May 7, 2018 · 10 comments · Fixed by #1323
Assignees
Labels
area/virtctl good-first-issue Identifies an issue that has been specifically created or selected for first-time contributors. help-wanted kind/enhancement

Comments

@booxter
Copy link
Contributor

booxter commented May 7, 2018

When I start a VM, I would like to immediately connect to its serial console to see all the output it may produce during boot. But I can't do it right away, because I get the error:

[ihar@ws kubevirt]$ ./cluster/virtctl.sh console ovm-cirros                                                                                                                                     
Escape sequence is ^]                                                                                                                                                                                       
                     Can't connect to websocket (400): Unable to connect to VM because phase is Scheduling instead of Running                                                                               

To mitigate the impact of it, I need to use a "while true; do virtctl console ...; done" command to get connected as soon as possible.

While I appreciate that the infrastructure to provide console output may be not ready at this point, I think virtctl could spin / wait for console to become ready and connect me to it at the earliest possibility, so that I don't miss some of boot messages.

@rmohr
Copy link
Member

rmohr commented May 9, 2018

hm, since the cluster will try to schedule a workload indefinitely, that could hang indefinitely too. We may be able to handle that scenario with extra timeout flags, or something like that. Thoughts?

@booxter
Copy link
Contributor Author

booxter commented May 9, 2018

Having a conservative timeout (5 minutes?) and ability to abrupt waiting (Ctrl+C) would be a good solution.

@fabiand fabiand added kind/enhancement help-wanted good-first-issue Identifies an issue that has been specifically created or selected for first-time contributors. labels May 28, 2018
@fabiand
Copy link
Member

fabiand commented May 28, 2018

Timeout sounds like a good start.
A beefed up version could use: kubectl wait --for=condition=available --timeout=60s resource-string(deployment)/foo from here

@fabiand fabiand added this to the v1 milestone Jun 7, 2018
@shiywang
Copy link

@fabiand I would like to stab at this if no one else

@fabiand
Copy link
Member

fabiand commented Jun 22, 2018

/assign @shiywang

@fabiand
Copy link
Member

fabiand commented Jun 22, 2018

Sounds good @shiywang

Do you need anything to get started?

@SchSeba
Copy link
Contributor

SchSeba commented Jul 4, 2018

Note to developer:

The command virtctl console is inside the pkg/virtcl/console
To make the console to wait until we get interrupt or time out we need to check the error coming back from the function in line 97

con, err := virtCli.VirtualMachineInstance(namespace).SerialConsole(vmi)

If the error is "Unable to connect to VM because phase is Scheduling instead of Running" wait for a few second and retry.

We also need to add a signal interrupt just like in line 109

go func() {
		interrupt := make(chan os.Signal, 1)
		signal.Notify(interrupt, os.Interrupt)
		<-interrupt
		close(stopChan)
	}()

Another thing is we need to do is create a tick object that will make the time out for our loop in case the vm is stuck in a loop and cant go up.

And the last thing is to add a --timeout=number to the console command.
We can add a default value of 5 min if the parameter is not used

@SchSeba
Copy link
Contributor

SchSeba commented Jul 12, 2018

Looks like no one take this issue so I will work on this one.

@garimavsharma
Copy link

I'm seeing the same error when running the kubevirt tutorial [1]

[root@student001 ~]# ./virtctl console testvm
Escape sequence is ^]
Can't connect to websocket (400): Unable to connect to VirtualMachineInstance because phase is Scheduling instead of Running

What release is this fixed in ?

[1] https://github.com/scollier/kubevirt-tutorial

@SchSeba
Copy link
Contributor

SchSeba commented Sep 22, 2018

Hi @garimavsharma

Please try to use the v0.8.0 release.

kubevirt-bot pushed a commit to kubevirt-bot/kubevirt that referenced this issue Nov 6, 2020
Test 2555[1] (on 'Verify DataVolume' tests) is failing on tier1 cnv 2.1 test.
The issue reproduces when using ubi8 cdi-importer container (see bz#1739149[2]).

I.e. when using 'qemu-img info' on the invalid qcow file[3] (using uni8.1, qemu-img 3.1.0):
$ qemu-img info afl1.img
image: afl1.img
file format: raw
virtual size: 9.5K (9728 bytes)
disk size: 12K
$ qemu-img --version
qemu-img version 3.1.0 (qemu-kvm-3.1.0-30.module+el8.0.1+3755+6782b0ed)

Whereas, using fedora 30 (qemu-img 4.1.0):
$ qemu-img info afl1.img
file format: qcow
virtual size: 152 TiB (167125767422464 bytes)
disk size: unavailable
cluster_size: 4096
$ qemu-img --version
qemu-img version 4.1.0 (qemu-4.1.0-4.fc30)

As 'raw' file format is returned on el8, the supported format validation
isn't failing (on 'qemu.go -> isSupportedFormat), so the import is
completed successfully instead of failing.
Hence, removing this test for now as that file can't be validated
consistently on all envs.

[1] test_id:2555 ('fail creating import dv: invalid qcow large size')
[2] https://bugzilla.redhat.com/show_bug.cgi?id=1739149#c2
[3] https://bugs.launchpad.net/ossa/+bug/1449062/+attachment/4385683/+files/afl1.img

Change-Id: Iadc7a2129cb64a97b0f55dc1553f6a03c0a66ffd
Signed-off-by: Daniel Erez <derez@redhat.com>
Signed-off-by: Fred Rolland frolland@redhat.com
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
area/virtctl good-first-issue Identifies an issue that has been specifically created or selected for first-time contributors. help-wanted kind/enhancement
Projects
None yet
Development

Successfully merging a pull request may close this issue.

6 participants