Skip to content

Commit 10c6e62

Browse files
committed
MachinePool: always patch owned conditions, fix GetTypedPhase, doc fixes
Signed-off-by: Stefan Büringer [email protected]
1 parent c36f4c0 commit 10c6e62

File tree

4 files changed

+18
-22
lines changed

4 files changed

+18
-22
lines changed

docs/book/src/tasks/experimental-features/machine-pools.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -28,12 +28,12 @@ For developer docs on the MachinePool controller, see [here](./../../developer/a
2828

2929
## MachinePools vs MachineDeployments
3030

31-
Although MachinePools provide a similar feature to MachineDeployments, MachinePools do so by leveraging an InfraMachinePool which corresponds 1:1 with a resource like VMSS on Azure or Autoscaling Groups on AWS which we treat as a black box. When a MachinePool is scaled up, the InfraMachinePool scales itself up and populates its provider ID list based on the response from the infrastructure provider. On the other hand, a when a MachineDeployment is scaled up, new Machines are created which then create an individual InfraMachine, which corresponds to a VM in any infrastructure provider.
31+
Although MachinePools provide a similar feature to MachineDeployments, MachinePools do so by leveraging an InfraMachinePool which corresponds 1:1 with a resource like VMSS on Azure or Autoscaling Groups on AWS which we treat as a black box. When a MachinePool is scaled up, the InfraMachinePool scales itself up and populates its provider ID list based on the response from the infrastructure provider. On the other hand, when a MachineDeployment is scaled up, new Machines are created which then create an individual InfraMachine, which corresponds to a VM in any infrastructure provider.
3232

3333
| MachinePools | MachineDeployments |
3434
| ------------------------------------------------------------------------------------------------------------------------------------------------------------------- | -------------------------------------------------------------------------------------------------------------------------------------- |
3535
| Creates new instances through a single infrastructure resource like VMSS in Azure or Autoscaling Groups in AWS. | Creates new instances by creating new Machines, which create individual VM instances on the infra provider. |
3636
| Set of instances is orchestrated by the infrastructure provider. | Set of instances is orchestrated by Cluster API using a MachineSet. |
3737
| Each MachinePool corresponds 1:1 with an associated InfraMachinePool. | Each MachineDeployment includes a MachineSet, and for each replica, it creates a Machine and InfraMachine. |
3838
| Each MachinePool requires only a single BootstrapConfig. | Each MachineDeployment uses an InfraMachineTemplate and a BootstrapConfigTemplate, and each Machine requires a unique BootstrapConfig. |
39-
| Maintains a list of instances in the `providerIDList` field in the MachinePool spec. This list is populated based on the response from the infrastructure provider. | Maintains a list of instances through the Machine resources owned by the MachineSet. |
39+
| Maintains a list of instances in the `providerIDList` field in the MachinePool spec. This list is populated based on the response from the infrastructure provider. | Maintains a list of instances through the Machine resources owned by the MachineSet. |

docs/proposals/20190919-machinepool-api.md

Lines changed: 6 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -176,9 +176,6 @@ type MachinePoolSpec struct
176176
- Type: `MachineTemplateSpec`
177177
- Description: Machine Template that describes the configuration of each machine instance in a
178178
machine pool.
179-
- **Strategy [optional]**
180-
- Type: `*MachineDeploymentStrategy`
181-
- Description: Strategy to employ in replacing existing machine instances in a machine pool.
182179
- **MinReadySeconds [optional]**
183180
- Type: `*int32`
184181
- Description: Minimum number of seconds for which a newly created machine should be ready.
@@ -246,13 +243,13 @@ MachinePoolPhasePending = MachinePoolPhase("pending")
246243

247244
###### Expectations
248245

249-
- When MachinePool.Spec.Template.Spec.Bootstrap.Data is:
250-
- <nil>, expect the field to be set by an external controller.
246+
- When MachinePool.Spec.Template.Spec.Bootstrap.DataSecretName is:
247+
- \<nil\>, expect the field to be set by an external controller.
251248
- “” (empty string), expect the bootstrap step to be ignored.
252249
- “...” (populated by user or from the bootstrap provider), expect the contents to be used by a
253250
bootstrap or infra provider.
254251
- When MachinePool.Spec.Template.Spec.InfrastructureRef is:
255-
- <nil> or not found, expect InfrastructureRef will be set/found during subsequent requeue.
252+
- \<nil\> or not found, expect InfrastructureRef will be set/found during subsequent requeue.
256253
- “...” (populated by user) and found, expect the infrastructure provider is waiting for bootstrap
257254
data to be ready.
258255
- Found, expect InfrastructureRef to reference an object such as GoogleManagedInstanceGroup,
@@ -269,7 +266,7 @@ MachinePoolPhaseProvisioning = MachinePoolPhase("provisioning")
269266
###### Transition Conditions
270267

271268
- MachinePool.Spec.Template.Spec.Bootstrap.ConfigRef -> Status.Ready is true
272-
- MachinePool.Spec.Template.Spec.Bootstrap.Data is not <nil>
269+
- MachinePool.Spec.Template.Spec.Bootstrap.DataSecretName is not \<nil\>
273270

274271
###### Expectations
275272

@@ -302,7 +299,7 @@ MachinePoolPhaseRunning = MachinePoolPhase("running")
302299

303300
###### Transition Conditions
304301

305-
- Number of Kubernetes Nodes in a Ready state matching MachinePool.Spec.Selector equal MachinePool.Status.Replicas.
302+
- Number of Kubernetes Nodes matching MachinePool.Spec.ProviderIDList in a Ready state equal to MachinePool.Spec.Replicas.
306303

307304
###### Expectations
308305

@@ -319,7 +316,7 @@ MachinePoolPhaseDeleting = MachinePoolPhase("deleting")
319316

320317
###### Transition Conditions
321318

322-
- MachinePool.ObjectMeta.DeletionTimestamp is not <nil>
319+
- MachinePool.ObjectMeta.DeletionTimestamp is not \<nil\>
323320

324321
###### Expectations
325322

exp/api/v1beta1/machinepool_types.go

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -197,6 +197,7 @@ func (m *MachinePoolStatus) GetTypedPhase() MachinePoolPhase {
197197
MachinePoolPhaseRunning,
198198
MachinePoolPhaseScalingUp,
199199
MachinePoolPhaseScalingDown,
200+
MachinePoolPhaseScaling,
200201
MachinePoolPhaseDeleting,
201202
MachinePoolPhaseFailed:
202203
return phase

exp/internal/controllers/machinepool_controller.go

Lines changed: 9 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -157,18 +157,16 @@ func (r *MachinePoolReconciler) Reconcile(ctx context.Context, req ctrl.Request)
157157

158158
// Always attempt to patch the object and status after each reconciliation.
159159
// Patch ObservedGeneration only if the reconciliation completed successfully
160-
patchOpts := []patch.Option{}
160+
patchOpts := []patch.Option{
161+
patch.WithOwnedConditions{Conditions: []clusterv1.ConditionType{
162+
clusterv1.ReadyCondition,
163+
clusterv1.BootstrapReadyCondition,
164+
clusterv1.InfrastructureReadyCondition,
165+
expv1.ReplicasReadyCondition,
166+
}},
167+
}
161168
if reterr == nil {
162-
patchOpts = append(
163-
patchOpts,
164-
patch.WithStatusObservedGeneration{},
165-
patch.WithOwnedConditions{Conditions: []clusterv1.ConditionType{
166-
clusterv1.ReadyCondition,
167-
clusterv1.BootstrapReadyCondition,
168-
clusterv1.InfrastructureReadyCondition,
169-
expv1.ReplicasReadyCondition,
170-
}},
171-
)
169+
patchOpts = append(patchOpts, patch.WithStatusObservedGeneration{})
172170
}
173171
if err := patchHelper.Patch(ctx, mp, patchOpts...); err != nil {
174172
reterr = kerrors.NewAggregate([]error{reterr, err})

0 commit comments

Comments
 (0)