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

Add support for serial consoles #436

Closed
wants to merge 1 commit into from
Closed

Add support for serial consoles #436

wants to merge 1 commit into from

Conversation

Bischoff
Copy link
Contributor

(extracted from #432 from @MalloZup )

This PR adds a serial console to our VMs. It enables:

  • to use virsh console to connect to a VM, especially when network is unavailable
  • to avoid Ubuntu to run at 100% CPU and become unusable

Copy link
Contributor

@MalloZup MalloZup left a comment

Choose a reason for hiding this comment

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

as i did it i am not against it 😄 this should be ok for all host afaik

Copy link
Contributor

@moio moio left a comment

Choose a reason for hiding this comment

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

Please test at least once with CentOS, fix the travis build and merge.

Thanks a lot, I can't count the number of times this can save us time!

@Bischoff
Copy link
Contributor Author

Bischoff commented Oct 10, 2018

There are two ways to do this, through a kernel parameter or through a systemd service.

For the moment i'm doing it the easy way, through the service, but on the long term the kernel parameter approach could give us access to the VM earlier during the boot process.

Yes, I will test CentOS as well and consider what Travis has to say.

@Bischoff Bischoff self-assigned this Oct 10, 2018
@Bischoff
Copy link
Contributor Author

Bischoff commented Oct 10, 2018

To anyone interested, the magic kernel parameter is console=ttyS0,9600.

@Bischoff
Copy link
Contributor Author

Bischoff commented Oct 10, 2018

I don't know why, the deployment fails with:

* libvirt_domain.domain: timeout while waiting for state to become
  'all-addresses-obtained' (last state: 'waiting-addresses', timeout: 5m0s)
* module.client.module.client.libvirt_domain.domain: 1 error(s) occurred:

is this linked to some other change of you, or do I miss something, @MalloZup? Does it ring a bell?

@MalloZup
Copy link
Contributor

MalloZup commented Oct 11, 2018

That failure is because sumaform has the variabile wait_for_lease enabled true. This variable basicaly make a for loop over 5 min and wait for ip of the domain(in bridge or not bridge network ) .this is the failure. So in your case the client had pb getting the ip. Can you reproduce it always ? In maybe your client, the os. Image has pb with that kernel arg.it can be the diff img

@Bischoff
Copy link
Contributor Author

Bischoff commented Oct 11, 2018

@MalloZup I'm not even using the kernel arg, I'm trying with systemd.

I'll try to run without this patch and see if I get an IP. It could be sumaform is trying to use the system console that is now on another tty. @moio, does that hypothesis sound realistic?

I suppose I just have the standard images. I use a fresh sumaform and my usual main.tf.

@moio
Copy link
Contributor

moio commented Oct 11, 2018

terraform-provider-libvirt gets the VM's IP address(es) via the QEMU guest agent (typically after they have been assigned by the DHCP). I have just checked and yes, the communication with the guest agent uses a serial console, so that sounds like the culprit

https://wiki.qemu.org/Features/GuestAgent

@Bischoff
Copy link
Contributor Author

Thanks @moio, that's probably the explanation.

Did you get same problem in your own PR @MalloZup ? You define more "terminal"s but I tried to do the same, and it does not solve the problem. Are you doing some other magic I missed?

@Bischoff
Copy link
Contributor Author

I might have the solution. The problem might be that qemu-agent is detecting the serial console and tries to use it, but there's no login on it yet.

I will use the kernel parameter approach. With that one, you get a longin prompt very early.

@MalloZup
Copy link
Contributor

@Bischoff i think i tested only with the ubuntu and there was no problem i could log in with the qemu-agent
It might be specific issues with SLES images used by sumaform or SLES maybe generic

@MalloZup
Copy link
Contributor

MalloZup commented Oct 11, 2018

but take care that the ubuntu tf has other consoles, this would be your problem imho ( i would try it ou)
https://github.com/moio/sumaform/pull/432/files#diff-299bef565123dc0baa9415daf859349fR72

@Bischoff
Copy link
Contributor Author

Bischoff commented Oct 11, 2018

As i said, I already tried it out with the other consoles, and it did not help.

In this PR I address only the serial console feature, but feel free to add other consoles to solve ubuntu problems.

@Bischoff
Copy link
Contributor Author

There is some progress: I can now see the kernel booting in my virsh console.

However the boot is broken, I probably need some more kernel arguments 😸 .

@Bischoff
Copy link
Contributor Author

It does not work, I was not able to make "Direct kernel boot" feature work.

However, I don't think that's the good strategy. I realized that the good strategy is to add console=ttyS0,115200 inside grub configuration, on the image.

Which means image rebuilding. Given my past experience with that, I will stop at this point.

@MalloZup
Copy link
Contributor

@Bischoff what is the 2nd parameter mean?

@Bischoff
Copy link
Contributor Author

@MalloZup The baud rate. This was at the origin on serial telephone lines. As this is now virtualized, you can take the highest speed.

Any will to make images, Dario ⛑️ ?

@MalloZup
Copy link
Contributor

@Bischoff i am still on Ubunt patch waiting on review there, i might help once i have finised.

Is really making images the only solution ? 📛

@moio
Copy link
Contributor

moio commented Oct 12, 2018

@Bischoff JFYI kernel parameters can be specified in Terraform, as terraform-provider-libvirt supports them IIUC

https://github.com/dmacvicar/terraform-provider-libvirt/blob/master/website/docs/r/domain.html.markdown

search for "params"

@Bischoff
Copy link
Contributor Author

Bischoff commented Oct 12, 2018

@moio as you might see above, dario already gave the pointer, it's what I tried and it does not work. You will see the corresponding code in this PR.

Furthermore, it's bad because:

  • it uses the "external kernel" feature of libvirt that I kind of dislike
    (I'm not comfortable bypassing grub)
  • you can't just add a parameter, you have to specify all of kernel, initrd, and all boot parameters
    (as a side effect, you might need to distinguish SLES / CentOS / etc.)

The correct solution is really to put it into the image.

@moio
Copy link
Contributor

moio commented Oct 16, 2018

The correct solution is really to put it into the image.

OK. Do we want to keep this PR open then?

This sounds like we want to change all images, and at that point, I wonder if it would make sense to switch to JeOS/upstream + cloud init for most of them.

@MalloZup
Copy link
Contributor

The switch to jeos will take more time. E.g JeOs need to be resized root partition is to small. I would do first ubuntu the jeos

@Bischoff
Copy link
Contributor Author

OK. Do we want to keep this PR open then?

This sounds like we want to change all images, and at that point, I wonder if it would make sense
to switch to JeOS/upstream + cloud init for most of them.

It's independant problems, no? I would keep it open.

@moio
Copy link
Contributor

moio commented Oct 17, 2018

The second sentence was a remark, but the question was relative to the quote. Quoting again:

The correct solution is really to put it into the image.
OK. Do we want to keep this PR open then?

@Bischoff
Copy link
Contributor Author

@moio we still need the consoleblock for the virtualization, even if we move the "listening" part to the image.

If you create an image that listens on the console, I will refactor this by pruning the unneeded parts.

So yes, please keep it open.

@moio
Copy link
Contributor

moio commented Oct 26, 2018

What changes are needed exactly on which images?

@Bischoff
Copy link
Contributor Author

@moio Add console=ttyS0,115200 to kernel command line parameters on all images.

@moio
Copy link
Contributor

moio commented Nov 6, 2018

OpenSUSE images rebuilt, SLE images are building (to be ready at 10am), CentOS images within the day. Please rebase, test and merge - let me know if something does not work as expected.

@Bischoff
Copy link
Contributor Author

Bischoff commented Nov 6, 2018

Thanks so much @moio !!!

@Bischoff
Copy link
Contributor Author

Bischoff commented Nov 7, 2018

  1. apparently, there is nothing to merge anymore, since @MalloZup's code for cloudinit has been merged, so we have a serial console already...

  2. but apparently you do not pass correct options on kernel's command line :

ebi3-minion:~ # cat /proc/cmdline
BOOT_IMAGE=/boot/linux.vmx root=/dev/vda1 disk=/dev/vda nomodeset elevator=noop showopts
ebi3-minion:~ # grep PRETTY /etc/os-release
PRETTY_NAME="SUSE Linux Enterprise Server 12 SP3"

so it does not work

@moio
Copy link
Contributor

moio commented Nov 9, 2018

Right, there was a problem with OBS publishing, now fixed. I tested both SLES and openSUSE and they do the right thing now.

New CentOS images will be provided via the sumaform-images project and they are ready, including console support.

Only problem is a slight incompatibility of GitHub Releases with terraform-provider-libvirt, solved in this PR currently pending:

dmacvicar/terraform-provider-libvirt#472

Plan:

In future, we will not have hosting problems any more as GitHub releases are publicly available. Moreover, maintenance of Packer images will be easier as all needed software is containerized, so reproducing the build is not machine dependent any more.

@moio moio closed this Nov 9, 2018
@Bischoff
Copy link
Contributor Author

All clear, thanks Silvio for your help on this long-awaited feature of using virsh console 😃 .

@Bischoff Bischoff deleted the console branch November 30, 2018 14:42
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants