Skip to content

Commit

Permalink
Update images
Browse files Browse the repository at this point in the history
  • Loading branch information
Jont828 committed Nov 7, 2023
1 parent 4c484ee commit 0b9ed09
Show file tree
Hide file tree
Showing 13 changed files with 104 additions and 54 deletions.
19 changes: 14 additions & 5 deletions docs/proposals/20220209-machinepool-machines.md
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,7 @@ status: implementable
- [InfraMachinePoolMachine creation](#inframachinepoolmachine-creation)
- [MachinePool Machine creation](#machinepool-machine-creation)
- [InfraMachinePoolMachine deletion](#inframachinepoolmachine-deletion)
- [Machine controller](#machine-controller)
- [User Stories](#user-stories)
- [| U3 | MachinePool Machine Rolling Updates |](#-u3--machinepool-machine-rolling-updates-)
- [Story U1](#story-u1)
Expand Down Expand Up @@ -108,7 +109,7 @@ type InfraMachinePoolStatus struct {
}
```

This field is in addition to the optional status fields of `InfrastructureMachinePool` in the provider contract.
This field is in addition to the optional status fields of `InfrastructureMachinePool` in the [provider contract][].

### InfraMachinePoolMachine creation

Expand Down Expand Up @@ -142,8 +143,6 @@ infraMachinePoolMachine := &infrav1.InfraMachinePoolMachine{

**Note:** Depending on the provider specific implementation of MachinePools, it might make sense to reuse the existing InfraMachine type for both normal Machines and MachinePool Machines rather than creating a new InfraMachinePoolMachine type. This is the case for Docker as there is no difference in implementation of the instances, but most providers will still want to use a new InfraMachinePoolMachine.

![InfraMachinePool replica creation](images/machinepool-machines/inframachinepool-create-replicas.png)

### MachinePool Machine creation

The CAPI MachinePool controller is responsible for watching for the creation of InfraMachinePoolMachines and reacting by creating owner Machines for each InfraMachine. Each owner Machine will have its infrastructure reference pointing to the InfraMachinePoolMachine but will not have a bootstrap reference as the bootstrap object is shared among all instances. The MachinePool controller will also ensure each Machine has an owner reference to the MachinePool and replace it if the owner reference is removed. Similarly, Machine controller (not MachinePool) is also responsible for ensuring the the InfraMachinePoolMachine indicated by the infrastructure reference has a controller/owner reference to the Machine as well. The Machines will be created as similar to the following specification.
Expand Down Expand Up @@ -171,7 +170,7 @@ machine := &clusterv1.Machine{

To reiterate, this behavior is already implemented by the MachinePool controller, and providers are not responsible for creating/updating these Machines.

![MachinePool reconciliation](images/machinepool-machines/machinepool-machines-reconcile.png)
![MachinePool reconciliation](images/machinepool-machines/machinepool-reconcile.png)


### InfraMachinePoolMachine deletion
Expand All @@ -182,7 +181,17 @@ When the MachinePool is scaling down, the InfraMachinePool must select a replica

It is worth noting that when a MachinePool Machine is deleted manually, the Machine controller will delete the corresponding InfraMachinePoolMachine, and the InfraMachinePoolMachine will delete the provider-specific resource. On the other hand, if the provider specific instance backing a Machine and InfraMachinePoolMachine is deleted, the InfraMachinePool controller is responsible for deleting the "dangling" Machine and InfraMachinePoolMachine, and creating a new replica and InfraMachinePoolMachine to replace it.

![InfraMachinePool replica deletion](images/machinepool-machines/inframachinepool-delete-replicas.png)
All together, the InfraMachinePool reconcilation diagram (including replica creation and deletion) is as follows:

![InfraMachinePool reconcile](images/machinepool-machines/inframachinepool-reconcile.png)

### Machine controller

Once a MachinePool Machine is created, it is reconciled by the Machine controller. The Machine controller will fetch the InfraMachinePoolMachine in the Machine's infrastructure reference, and ensure the InfraMachinePoolMachine has an owner reference to the Machine. This is part of the existing behavior of the Machine controller.

When a MachinePool Machine is being deleted, the Machine controller will cordon and drain the node, delete the InfraMachinePoolMachine, and delete the node. The InfraMachinePoolMachine will then delete the provider specific instance.

![Machine reconcile](images/machinepool-machines/machinepool-machine-reconcile.png)

### User Stories

Expand Down
Original file line number Diff line number Diff line change
@@ -1,17 +1,15 @@
@startuml inframachinepool-create-replicas
:InfraMachinePool create replicas reconciliation;
:Begin reconciling InfraMachinePool;
if (status.InfrastructureMachineKind is set on InfraMachinePool) then (no)
:set status.InfrastructureMachineKind to InfraMachinePoolMachine;
else (yes)
endif
repeat
while (~# replicas < # desired replicas ?) is (yes)
:create provider specific resource representing a replica;
repeat while (~# replicas < # desired replicas ?) is (yes)
->no;
repeat
endwhile (no)
while (every replica has an InfraMachinePoolMachine?) is (no)
:create InfraMachinePoolMachine representing a replica;
repeat while (every replica has an InfraMachinePoolMachine?) is (no)
->yes;
:continue reconciling InfraMachinePool...;
endwhile (yes)
:Continue reconciling InfraMachinePool (see additional diagram below);
stop
@enduml
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Original file line number Diff line number Diff line change
@@ -1,32 +1,27 @@
@startuml inframachinepool-delete-replicas
:InfraMachinePool delete replicas reconciliation;
:fetch all InfraMachinePoolMachines;
:fetch owner Machine for each InfraMachinePoolMachine;
if (any owner Machine is missing) then
:wait for owner Machine to be created;
:requeue;
stop
else
endif
repeat
if (replica backing Machine does not exist) then (yes)
repeat :Continue reconciling InfraMachinePool;
:fetch all InfraMachinePoolMachines;
:fetch owner Machine for each InfraMachinePoolMachine;
backward:wait for owner Machine to be created;
repeat while (any owner Machine is missing) is (yes)
-> no;

while (for each Machine)
if (replica backing Machine does not exist?) then (yes)
:delete Machine;
:Machine controller deletes InfraMachinePoolMachine;
else (no)
endif
repeat while (more Machines?) is (yes)
repeat
endwhile
->no;
while (~# replicas > # desired replicas?) is (yes)
if (a Machine has clusterv1.DeleteMachineAnnotation) then (yes)
:select this Machine for deletion;
else (no)
:select any Machine using any ordering,
i.e. oldest first;
endif
:delete selected Machine;
:Machine controller cordons and drains node;
:Machine controller deletes InfraMachinePoolMachine;
:InfraMachinePoolMachine controller deletes provider instance;
repeat while (~# replicas > # desired replicas?) is (yes)
endwhile
->no;
:continue reconciling InfraMachinePool...;
stop
Expand Down
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
@startuml inframachinepool-reconcile
repeat :begin reconciling InfraMachinePool;
if (status.InfrastructureMachineKind is set on InfraMachinePool) then (no)
:set status.InfrastructureMachineKind to InfraMachinePoolMachine;
else (yes)
endif
while (~# replicas < # desired replicas ?) is (yes)
:create provider specific resource representing a replica;
endwhile (no)
while (every replica has an InfraMachinePoolMachine?) is (no)
:create InfraMachinePoolMachine representing a replica;
endwhile (yes)
' :Enter second diagram;
' stop
:fetch all InfraMachinePoolMachines;
:fetch owner Machine for each InfraMachinePoolMachine;
backward:wait for owner Machine to be created;
repeat while (any owner Machine is missing) is (yes)
-> no;
while (for each Machine)
if (replica backing Machine does not exist?) then (yes)
:delete Machine;
else (no)
endif
endwhile
->no;
while (~# replicas > # desired replicas?) is (yes)
if (a Machine has clusterv1.DeleteMachineAnnotation) then (yes)
:select this Machine for deletion;
else (no)
:select any Machine using any ordering,
i.e. oldest first;
endif
:delete selected Machine;
endwhile
->no;
:end reconciling InfraMachinePool;
stop
@enduml
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
@startuml machinepool-machine-reconcile
:begin reconciling Machine;
if (is deleting?) then (no)
:ensure InfraMachinePoolMachine has ownerRef to Machine;
else (yes)
:cordon and drain node;
:delete InfraMachinePoolMachine;
:wait for InfraMachinePoolMachine to be deleted;
:delete node;
endif
:continue reconciling Machine;
stop
@enduml
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.

This file was deleted.

Binary file not shown.
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
@startuml machinepool-reconcile
:begin reconciling MachinePool;
if (status.InfrastructureMachineKind is set on InfraMachinePool) then (no)
:reconcile MachinePool replicas without MachinePool Machines;
else (yes)
:find the InfraMachinePoolMachines matching the kind
with the matching MachinePool name and Cluster name label;
while (for each InfraMachinePoolMachines)
if (a owner Machine exists for a InfraMachinePoolMachine) then (no)
:create a Machine with infraRef pointing
to the InfraMachinePoolMachine;
else (yes)
endif
:ensure Machine has an ownerRef to the MachinePool;
endwhile
endif
:continue reconciling MachinePool...;
stop
@enduml
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.

0 comments on commit 0b9ed09

Please sign in to comment.