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

Remove supported containers check at agent for machine startup #17179

Open
wants to merge 3 commits into
base: 3.4
Choose a base branch
from

Conversation

cderici
Copy link
Member

@cderici cderici commented Apr 9, 2024

The running-in-container is removed years ago, so this uses systemd-detect-virt to detect the environment we're running in.

Also the setupContainerSupport seems to have no effect on provisioning machines, so this removes the pre-checks and allows any invalid provisions to be failed dynamically.

Checklist

  • Code style: imports ordered, good names, simple structure, etc
  • Comments saying why design decisions were made
  • Go unit tests, with comments saying what you're testing

QA steps

This is used in the agent machine startup, so any newly added machine should be provisioned just fine. Also the placement should be checked as well.

juju bootstrap lxd
juju add-model
juju deploy ubuntu
juju add-machine
juju deploy ubuntu --to 1
juju bootstrap aws
juju add-model
juju deploy ubuntu
juju add-machine
juju deploy ubuntu --to 1

Links

Launchpad bug: https://bugs.launchpad.net/juju/+bug/2056200

Jira card: JUJU-5633

@cderici cderici added bug The PR addresses a bug 3.4 labels Apr 9, 2024
container/utils.go Outdated Show resolved Hide resolved
container/utils.go Outdated Show resolved Hide resolved
container/utils.go Outdated Show resolved Hide resolved
container/utils.go Outdated Show resolved Hide resolved
container/utils.go Outdated Show resolved Hide resolved
container/utils.go Outdated Show resolved Hide resolved
Copy link
Member

@SimonRichardson SimonRichardson left a comment

Choose a reason for hiding this comment

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

You're not guaranteed to return 1 and only 1 result set in the list. ParseContainerType only expects one argument.

@cderici cderici force-pushed the container-support-systemd-detect-virt branch from 5521a6f to 3a59844 Compare April 23, 2024 21:20
Comment on lines 902 to 910
var supportedContainers []instance.ContainerType
supportsContainers := container.ContainersSupported()
if supportsContainers {
supportedContainers = append(supportedContainers, instance.LXD)
supportedContainerType, err := container.ContainersSupported()
if err != nil {
logger.Warningf("determining container support: %v\nno containers possible", err)
}

if err == nil && supportedContainerType != "" {
supportedContainers = append(supportedContainers, supportedContainerType)
}
Copy link
Member

Choose a reason for hiding this comment

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

Can we just delete this and tell me what the consequences are?

I suspect this has been broken, so it was never correctly filled in and we haven't noticed till I removed KVM. Considering that, just remove it and try the following:

  • juju bootstrap lxd
  • juju bootstrap aws and juju add-machine lxd
  • juju deploy ubuntu --to lxd

This should cover the common cases to ensure this works (there are more)

Copy link
Member Author

Choose a reason for hiding this comment

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

You're right in this suspicion, removed all of these checks (including the kvm check) and everything seems to be working just fine (on both lxd and aws).

@cderici cderici force-pushed the container-support-systemd-detect-virt branch from 3a59844 to 4164811 Compare April 26, 2024 00:14
@cderici
Copy link
Member Author

cderici commented May 3, 2024

/build

1 similar comment
@cderici
Copy link
Member Author

cderici commented May 3, 2024

/build

@SimonRichardson
Copy link
Member

@cderici let's discuss this at the sprint.

@cderici cderici force-pushed the container-support-systemd-detect-virt branch from d638104 to 5ba9a64 Compare May 29, 2024 01:20
@cderici cderici changed the title Use systemd-detect-virt for detecting supported containers Remove supported containers check at agent for machine startup May 29, 2024
@cderici
Copy link
Member Author

cderici commented May 29, 2024

@SimonRichardson bootstrapping with this on lxd and aws, adding machines and deployments works just fine (also tried placement etc), but I'm gonna need extra pair of eyes on the failing test.

I'm not sure why this test depends on this check (fails without instance.LXD in there). It literally passes when I add instance.LXD unconditionally like supportedContainers = append(supportedContainers, instance.LXD) (i.e. nothing is mocking it), but it doesn't makes sense to me how it's getting true from container.ContainersSupported() in the first place since the running-in-container doesn't even exist.

Copy link
Member

@manadart manadart left a comment

Choose a reason for hiding this comment

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

Your QA steps don't check whether you can run a container on a machine.

With this change, you can't because all machines exhibit this behaviour:

machine-1: 15:22:59 INFO juju.worker.lxdprovisioner uninstalling no supported containers on "machine-1"
machine-1: 15:22:59 INFO juju.worker.kvmprovisioner uninstalling no supported containers on "machine-1"

cmd/jujud/agent/machine.go Show resolved Hide resolved
@cderici cderici force-pushed the container-support-systemd-detect-virt branch from 5ba9a64 to 16b840c Compare May 31, 2024 18:57
@cderici
Copy link
Member Author

cderici commented May 31, 2024

/build

@cderici cderici requested a review from manadart June 3, 2024 14:09
@manadart
Copy link
Member

manadart commented Jun 3, 2024

Still got failures in trackerSuite based on container support changes.

…ners

We unconditionally add the insatnce.LXD into supported containers at
the machine agent, so these tests that were originally failing won't
fail anymore.
@cderici
Copy link
Member Author

cderici commented Jun 3, 2024

Still got failures in trackerSuite based on container support changes.

Yes, I'll write down what's happening for future reference, before this change the NewTracker in the containerbroker fails with ErrUninstall -- "resource permanently unavailable" --, whenever i) the supported containers can't be determined, or ii) the instance.LXD is not found. Since we add the instance.LXD unconditionally to the supported containers, these fails never happen (which renders the check against these redundant - hence the change in the broker).

The failing tests:

  • trackerSuite.TestNewTrackerWithKVMContainers
  • trackerSuite.TestNewTrackerWithNoContainers
  • trackerSuite.TestNewTrackerWithNoDeterminedContainers

all check against those failures. The new expectation for these tests is to not fail (because the machines always support instance.LXD), which renders their scenarios identical after making changes:

_, err := s.withScenario(c,
		nil,
		s.expectMachineTag,
		s.expectMachines,
		s.expectContainerConfig,
	)

so changing the expectation and removing the redundant ones.

A side note, there's no specific check in the broker for the instance.KVM, the test trackerSuite.TestNewTrackerWithKVMContainers is written originally to fail when instance.LXD is not found, which is not happening anymore, so it's removed.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
3.4 bug The PR addresses a bug
Projects
None yet
5 participants