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
[JUJU-2030]Kill unconverted api workers 2 9 #14834
Conversation
Due to unconverted-api-worker refactor into workers using manifolds, WatchAllContainers is no longer used by the provisioner.
A step in refactoring the unconverted-api-workers into pieces using individual manifolds. MachineStartup will handle machine setup necessary but requiring an API Connection. The actual work is part of the machine agent and will be done via a config method.
A step in refactoring the unconverted-api-worker manifold into individual pieces. These will hold a container provisioner based on container type.
The unconverted-api-worker is being split into three pieces. machine-setup is short lived and does setup on the machine which required an API Connection. The other two are container provisioner workers for lxd and kvm. The functionality of the container-watcher for setup is placed into the container provisioner worker. It waits for a container to be provisioned, configures the container system on the machine and starts an container provisioner worker.
Always verify LXD and KVM in setupContainerSupport.
Renamed ContainerWorker to containerSetupAndProvisioner for understandability. Updated unit tests for container setup.
Change Report() results to make tests easier. Remove unused code from unit tests. Change capitalization of ContainerSetupAndProvisioner.
Changes to code to faciliate mocks, including adding a couple of interfaces and a shim. Moved code out of start to a new method for same. This can be resolved once we have good mocking in this package.
df1ccae
to
9af39de
Compare
"machine-action-runner", | ||
//"machine-setup", exits when done |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can we remove ?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This one I left on purpose to explain that the machine-setup manifold isn't running when at first glance it should be.
} | ||
|
||
if err := a.setupContainerSupport(apiConn, logger); err != nil { | ||
return err |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Should we annotate this?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This method can return errors from the dependency pkg. I've noticed that if wrapped, the dependency engine doesn't handle them as expected. I added logging messages to explain why we were calling ErrUninstall. Check that they make sense so we can find answers in the future.
cmd/jujud/agent/machine.go
Outdated
} | ||
if result.Code != 0 { | ||
return nil, errors.New(fmt.Sprintf("cannot patch /etc/update-manager/release-upgrades: %s", result.Stderr)) | ||
return errors.New(fmt.Sprintf("cannot patch /etc/update-manager/release-upgrades: %s", result.Stderr)) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This would be better as an fmt.Errorf call
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
very old juju 1 code, will do
cmd/jujud/agent/machine.go
Outdated
if len(result) != 1 { | ||
return errors.Errorf("expected 1 result, got %d", len(result)) | ||
} | ||
if errors.IsNotFound(result[0].Err) || (result[0].Err == nil && result[0].Machine.Life() == life.Dead) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
errors.Is(err, errors.NotFound)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
done
func (cs *ContainerSetup) initialiseContainerProvisioner() (Provisioner, error) { | ||
cs.logger.Debugf("setup provisioner for %s containers", cs.containerType) | ||
if cs.managerConfig == nil { | ||
return nil, errors.New("Programming error, manager config not setup") |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Should this be a notvalid ?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
done
} | ||
|
||
var _ = gc.Suite(&containerSetupSuite{}) | ||
|
||
func (s *containerSetupSuite) TestStartContainerStartsContainerProvisioner(c *gc.C) { | ||
defer s.patch(c).Finish() | ||
func (s *containerSetupSuite) TestInitialiseContainersLXD(c *gc.C) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Think these are around the wrong way.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
done
|
||
// Adding one new container machine. | ||
s.notify([]string{"0/lxd/0"}) | ||
func (s *containerSetupSuite) TestInitialiseContainersKVM(c *gc.C) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Same again
|
||
s.cleanKill(c, runner) | ||
func (s *containerSetupSuite) TestInitialiseContainerProvisionerLXD(c *gc.C) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Around the wrong way.
s.testInitialiseContainers(c, instance.KVM) | ||
} | ||
|
||
func (s *containerSetupSuite) TestInitialiseContainerProvisonerKVM(c *gc.C) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Around the wrong way.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
done
} | ||
pr := apiprovisioner.NewState(apiCaller) | ||
|
||
m, err := cfg.machineSupportsContainers(&containerShim{api: pr}, mTag) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
nit can we name m to something better?
typeSet.Add(string(v)) | ||
} | ||
if !typeSet.Contains(string(cfg.ContainerType)) { | ||
cfg.Logger.Infof("%s does not support %s containers", mTag, string(cfg.ContainerType)) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
s/containers/container
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
done
"github.com/juju/juju/core/watcher" | ||
) | ||
|
||
// NewContainerSetupAndProvisioner return a ContainerSetupAndProvisioner. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
s/return/returns
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
done
Use errors.Is rather than deprecated methods and update very old style messages.
The kvm-container-provisioner is only running on hardware which supports kvm. Thus the test is hardware dependent and gives different results. Allow for this by specifying optional workers. Startup of kvm-container-provisioner is tested in the provisioner worker.
a6d3c7f
to
9f7bea7
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
lgtm
/merge |
of unconverted-api-workers to manifold workers.
/merge |
1 similar comment
/merge |
#14862 Merge Conflicts (which I resolved): - .github/workflows/smoke.yml - cmd/jujud/agent/machine/manifolds_test.go - cmd/jujud/agent/machine_test.go - go.mod - go.sum - scripts/win-installer/setup.iss - snap/snapcraft.yaml - tests/suites/manual/deploy_manual.sh - version/version.go Merges: - #14837 - #14846 - #14834 - #14851 - #14857 - #14853
#15042 The kvm-provisioner worker is expected to run in all machine manifolds, but uninstalls itself if KVM support is not detected. #14834 Softened the check for the worker by adding optional workers to the engine test logic. #14862 was merged incorrectly resulting in an extra worker assertion before including the kvm-provisioner was added as an optional worker. This causes tests to fail depending on where they are run. Here we remove the duplicate assertion along with the optional worker logic. Instead we just patch `IsKVMSupported` to return true and use a hard expectation that the working is running. ## QA steps `go test -v ./cmd/jujud/agent/ -check.v -check.f=MachineSuite.TestMachineWorkers` ## Documentation changes None. ## Bug reference N/A
Split the unconverted-api-workers into two new workers and remove.
machine-setup runs setup on machines which require an API Connection. Once setup is done it can be uninstalled.
kvm-container-provisioner and lxd-container-provisioner both wait for a machine of their container type to be provisioned if the machine supports their container type. If it doesn't, the worker uninstalls. The first container provisioned of their type will cause setup for the container systems to run, then a container provisioner is started.
QA steps
Bug reference
https://bugs.launchpad.net/juju/+bug/1994488
https://bugs.launchpad.net/juju/+bug/1983140