-
Notifications
You must be signed in to change notification settings - Fork 528
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
feat: assign units to machines #19459
base: main
Are you sure you want to change the base?
Conversation
8c08938
to
7e0b902
Compare
d192c7b
to
f8a406c
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.
First pass, looking good. Few questions though.
// StubService is the interface used to interact with the stub service. A special | ||
// service which collects temporary methods required to wire together together |
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.
chef's kiss
// Try and get the placement for this unit. If it doesn't exist, | ||
// then the default behaviour is to create a new machine for the | ||
// unit. | ||
var placement *instance.Placement | ||
if i < len(spec.Placement) { | ||
var err error | ||
placement, err = instance.ParsePlacement(spec.Placement[i]) | ||
if err != nil { | ||
return params.ControllersChanges{}, errors.Annotate(err, "parsing placement") | ||
} | ||
} |
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.
I know we don't want to improve existing code (outside the domains), but since this is being added now, why not put it directly into one of the service methods in the app domain?
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.
I'm actively going to remove instance placement in favour of the domain placement. For now, we need to keep it there, so we go from string on the params, to the instance placement, to the domain placement. Future patches will remove it.
55a734a
to
761ab94
Compare
0351a49
to
895979c
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.
Got a few suggestions on this one.
Lock the placement parsing logic into tests
The following adds tests to ensure that we're correctly placing the net node machines with the right sequence number.
This adds machine placement container tests. This does checking of the gaps after deletions. Another negative test round needs to be also done i.e. missing machines, etc...
When we have a parent-child relationship, the scope is put in the middle. Except that we don't correctly verify the scope until we look at the state level. With this change, we do it at the service level to prevent additional queries.
This was a bit of an oversight, at the service layer it's per unit placement, not per request placement. The state was correctly modelled out.
Some code was just not exercised as it was in an impossible state.
We can use the bootstrap worker to create the machine for us, no need for a setup phase.
If we don't pass the right container type (lxd) we can't get the machine name correct. Lastly, I fix the sequence name to build a pattern for managing namespaced sequences. This makes it easier to get right and then there is always a pattern that people follow.
There was also an extra space in the machine sql which was not required.
If an application doesn't have a lease holder, don't fail a migration. One will be selected once imported.
Now that we've wired up unit assignment to machines, we do actually need to create a machine and ensure it's correctly wired up now.
We're not bootstrapping a machine in an adhoc fashion anymore.
Now that we correctly wired up units with machines, ensure that we correctly associate with the machine, or at least create a machine if it's missing.
To allow the model to be usable after model migration, we need to transfer the sequences across. We should be able to preserve the sequencing there after.
The method was becoming too large, so farm some of the parsing out to a function.
We want to be very explicit about when importing that you're importing a machine for IAAS. We don't want to mention placement, as it gives the wrong impression. Future work will require bifurcating the import application for IAAS and CAAS, so we can drop the if statements. That's out of scope for this PR.
6cb0315
to
71ff315
Compare
We're going to have a deployment domain in the future, move the placement to the new domain.
To indicate why we only want to store provider defined scopes as a comment. Also suggest how we would implement scripts ;-)
fix the extra case, we're already dealing with uint64
The machine and application sequence names have offical constants in 3.6, so we should respect those when we import. We might need to add a parsing step on the sequence domain to convert one sequence to another. 4.0 -> 4.0 it's fine, it's when it's 3.6 -> 4.0.
9d76401
to
015ab02
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.
I think we still need some changes.
It's become clear that the import application logic needs to change. We can bifurcate when we import the model, no need to carry along types that are only for CAAS or only for IAAS. I'll set some time in the future to do that. |
934b158
to
c1ae48d
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.
Thanks for the updates. Approve contingent to Joe's changes being applied.
/build |
When creating an application or adding units for a given application, we're going to use a strategy different from the legacy state implementation. We know the charm uuid for the unit because everything is statically known upfront. This means we can have non-nullable foreign keys in the unit, which points to the charm uuid. We no longer check for the implicit setting of a charm uuid to indicate that the unit has come online. We can if required use the presence table for that. Another advantage of this changeset is that we can then remove the
unitassigner
worker once machines have been fully implemented.As part of the changeset, this removes the stub server implementation for assigning units. Removing the technical debt for scafolding units and machines.
Note
We don't correctly set the status or status-history of a machine when we create them. We'll need to record that in a future PR.
Warning
The model is usable once it's reached the destination, as the machine sequence is broken. This requires machines to be correctly migrated, which might end up being a lot of work.
This pull request includes significant changes to the Juju codebase, primarily focusing on the removal of the
StubService
and associated code cleanup. The most important changes include the removal of theStubService
from various files, updates to theAssignUnits
method, and cleanup of related tests.Removal of
StubService
:apiserver/facades/agent/unitassigner/register.go
: Removed thestubService
initialization from thenewFacade
function.apiserver/facades/agent/unitassigner/unitassigner.go
: Removed theStubService
interface and its usage in theAPI
struct andAssignUnits
method. [1] [2] [3]apiserver/facades/client/application/application.go
: Removed thestubService
from theAPIBase
struct and related functions. [1] [2] [3]Code Cleanup:
agent/agentbootstrap/bootstrap.go
: Commented out themachinebootstrap.InsertMachine
call and removed themachinebootstrap
import. [1] [2]apiserver/facades/agent/unitassigner/unitassigner_test.go
: Removed references tostubService
and cleaned up test functions. [1] [2] [3] [4]apiserver/facades/agent/uniter/uniter_legacy_test.go
: Removed thestubService
from theuniterLegacySuite
struct and related test functions. [1] [2] [3] [4]apiserver/facades/client/application/base_test.go
: Removed the entirebase_test.go
file, which included references tostubService
.Updates to
AssignUnits
Method:apiserver/facades/client/application/deploy.go
: Updated theaddUnits
function to remove the call toAssignUnitsToMachines
and handle unit placement directly. [1] [2] [3]apiserver/facades/client/application/deployrepository.go
: Updated theDeployFromRepository
function to include unit placement handling.These changes streamline the codebase by removing deprecated services and simplifying unit assignment logic.
QA steps
Important
We can place directly onto a machine
--to 0/lxd/0
, but it doesn't quite work. The sequencing isn't right because machines aren't wired correctly using the domain services.Note
Removal of a parent and child machine (the parent machine will be created first, then the child machine will be placed in the parent) using
juju deploy ubuntu --to lxd
will fail because of a foreign constraint issue. This is because the machine domain does not have the concept of themachine_parent
table. This will be fixed once we have the removal jobs for machines.$ juju bootstrap lxd test $ juju add-model default $ juju deploy ubuntu $ juju deploy ubuntu ubuntux $ juju deploy ubuntu ubuntux --to lxd
View the database to see that things are correctly sequenced.
Adding units:
Assigning to a machine
Note
This doesn't work completely as we're not watching for the unit and machine correctly, but the database for a unit is correct.
$ juju add-model test $ juju deploy ubuntu $ juju deploy ubuntu ubuntuw --to 0
The net_node_uuid is correct for the machine:
Links
Jira card: JUJU-7699