Repository navigation
Closed
Description
$ oc logs machine-config-daemon-4jf24
I0905 20:35:05.283801 1 start.go:42] Version: 0.0.0-106-ge7b9b06d
I0905 20:35:05.283899 1 client_builder.go:49] Using in-cluster kube client config
I0905 20:35:05.284150 1 start.go:66] chrooting into rootMount /rootfs
I0905 20:35:05.284164 1 start.go:72] moving to / inside the chroot
panic: open /var/run/secrets/kubernetes.io/serviceaccount/ca.crt: no such file or directory
goroutine 1 [running]:
github.com/openshift/machine-config-operator/pkg/generated/clientset/versioned/typed/machineconfiguration.openshift.io/v1.NewForConfigOrDie(0xc4200f2e00, 0xc42032cfb0)
/code/go/src/github.com/openshift/machine-config-operator/pkg/generated/clientset/versioned/typed/machineconfiguration.openshift.io/v1/machineconfiguration.openshift.io_client.go:59 +0x65
github.com/openshift/machine-config-operator/pkg/generated/clientset/versioned.NewForConfigOrDie(0xc4200f2e00, 0x117d329)
/code/go/src/github.com/openshift/machine-config-operator/pkg/generated/clientset/versioned/clientset.go:69 +0x49
github.com/openshift/machine-config-operator/cmd/common.(*ClientBuilder).MachineConfigClientOrDie(0xc42009a658, 0x117d329, 0x15, 0x0, 0x0)
/code/go/src/github.com/openshift/machine-config-operator/cmd/common/client_builder.go:21 +0x50
main.runStartCmd(0x19da300, 0xc4202e6960, 0x0, 0x2)
/code/go/src/github.com/openshift/machine-config-operator/cmd/machine-config-daemon/start.go:80 +0x3de
github.com/openshift/machine-config-operator/vendor/github.com/spf13/cobra.(*Command).execute(0x19da300, 0xc4202e68c0, 0x2, 0x2, 0x19da300, 0xc4202e68c0)
/code/go/src/github.com/openshift/machine-config-operator/vendor/github.com/spf13/cobra/command.go:766 +0x2c1
github.com/openshift/machine-config-operator/vendor/github.com/spf13/cobra.(*Command).ExecuteC(0x19da0a0, 0x0, 0xc4200e1f78, 0x403dfc)
/code/go/src/github.com/openshift/machine-config-operator/vendor/github.com/spf13/cobra/command.go:852 +0x30a
github.com/openshift/machine-config-operator/vendor/github.com/spf13/cobra.(*Command).Execute(0x19da0a0, 0xc4200e1f60, 0x0)
/code/go/src/github.com/openshift/machine-config-operator/vendor/github.com/spf13/cobra/command.go:800 +0x2b
main.main()
/code/go/src/github.com/openshift/machine-config-operator/cmd/machine-config-daemon/main.go:27 +0x31
Looks like we need to copy the cert before we chroot.
Though this raises the higher level question of how much will chroot() affect how well we mesh with Kubernetes. (How common is it to do an early chroot() on the main process in Kube containers?)
Metadata
Metadata
Assignees
Labels
No labels
Activity
jlebon commentedon Sep 5, 2018
This is a bit late, though looking at the original threads that spawned this change (#17 and #24), ISTM like the main reason for doing an early
chrootwas to work around the symlink-over-bind-mount issue, right?For systemd units specifically, could we not use the systemd D-Bus API directly? And then if the need comes up otherwise to resolve symlinks, we can just do one-off
chrootinvocations instead? This is also closer to how Ignition itself works, i.e. onlychrooting when it needs to; and given that we're handling Ignition configs here too, I suspect we should be able to also do without an earlychroot, right? (Again, I should've brought this up earlier during those discussions, sorry!)sdemos commentedon Sep 5, 2018
I have to guess that it's not common at all.
Another possible solution would be to chroot after getting all the info we need from kubernetes, and right before the files and units are evaluated. Not sure which is better. Are there semantic differences between a manual symlink and calling the dbus api?
/cc @ashcrow @lucab since they were also part of the precipitating discussion on this topic.
lucab commentedon Sep 6, 2018
I'll try to answer all the questions to the best of my knowledge.
If I understood this suggestion correctly, I fear this would clone k8s objects and leak them to the host filesystem. That seems to introduce lifecycle/GC and confidentiality concerns to me.
I've never seen this. On the other hand many software are just plainly broken when doing path-resolution over a rootfs bind-mount, because they were not designed to run in a container (e.g. kubelet, node-exporter), so I wouldn't take this as a useful datapoint.
Yes. The general topic is "symlinks/path resolution over a rootfs bind-mounts".
Likely yes, for the specific case where you have a D-Bus API to perform the change you need.
You don't know beforehand if you need to "resolve symlinks". Every time you open/stat a file, its path could be crossing a number of absolute/relative symlinks; those targets are not aware of your bind-mount prefix. Also, chroot is process-wide so it will also affect other running goroutines (if any).
Likely yes, but this is a daemon design point so it should take into account what the rest of the process is doing in parallel, otherwise the same problem will exist as a race.
Also, ignition is not a heavy-parallel and long-running process and doesn't consume many external configuration files, so it is probably not a good design reference here.
Same as above, in order for this to work you need to guarantee that nothing else in your program is trying to do file accesses while you are chrooted.
I didn't check if that happens in practice, but some lazy-loading that come to mind could be around k8s config/token (e.g. if there are inotify watches for updated file), TLS CA bundle (which is read from container /etc, but I don't know at which point), procfs (e.g. if anything is trying to introspect or gather metric on the process itself, mount table, etc.).
ashcrow commentedon Sep 6, 2018
It is possible with the right mounts. But keep in mind that the MCD also drops files in different locations. We would still need to chroot (or something similar).
I'm more in favor of this path as long as we verify @lucab's notes.
ashcrow commentedon Sep 6, 2018
/assign ashcrow
jlebon commentedon Sep 6, 2018
My argument was that Ignition is also subject to this, but it has managed fine (or did this bite some users?). Of course the difference is that at the time Ignition runs, there's no live system running under
/sysroot; it's just a plain partition mount and so the state of the disk is in a much more controlled state. So overall, I do agree that the analogy doesn't apply.ashcrow commentedon Sep 6, 2018
@jlebon can you verify #46 fixed this and close this issue if so?
sdemos commentedon Sep 6, 2018
@ashcrow did you also investigate the effects of this on possible kubernetes lazy-loading and other problems that @lucab brought up in his comment? I didn't see any followups and I'm curious what the outcome was on how this change effects that.
ashcrow commentedon Sep 6, 2018
@sdemos I didn't dive into the kubernetes client code to see if it was doing anything fancy to reload itself on file changes. I can do so though. I took @lucab's note more as a 'it's a possibility that something does something fancy' though I may have misunderstood.
sdemos commentedon Sep 6, 2018
I was just wondering because you mentioned it as something to verify but I didn't see anything and was curious.
ashcrow commentedon Sep 6, 2018
@sdemos fair point. I'm taking a gander now :-)
ashcrow commentedon Sep 6, 2018
/procinapimachinery/pkg/util/net/interface.gowhich is used intransport/round_trippers.go,transport/cache.go,rest/request.go, andkubernetes/typed/core/v1/service_expansion.go. I'll check these locations and report back.ashcrow commentedon Sep 6, 2018
transport/round_trippers.gousesCloneRequestwhich isn't using mountstransport/cache.gousesSetTransportDefaultswhich isn't using mountsrest/requests.gousesIsProbableEOF,IsConnectionReset, neither of which use mountskubernetes/typed/core/v1/service_expansion.gousesJoinSchemeNamePortwhich does not use mountsOf course I can't promise this will always be the case, or that I didn't miss a call which calls a call which calls a 🐢 🐢 🐢 ... :-)
sdemos commentedon Sep 18, 2018
this was fixed in #46.
I don't have a close button though, which seems like a silly restriction.