Skip to content

Commit 4d6f9c2

Browse files
Update provider contract to account for the paused condition
This change updates the provider contract to account for a new paused condition. It is intended to start as an optional condition, but then become required at a later date.
1 parent d79694c commit 4d6f9c2

File tree

4 files changed

+59
-2
lines changed

4 files changed

+59
-2
lines changed

docs/book/src/developer/architecture/controllers/control-plane.md

+12
Original file line numberDiff line numberDiff line change
@@ -264,6 +264,18 @@ The `status` object **may** define several fields:
264264
* `externalManagedControlPlane` - is a bool that should be set to true if the Node objects do not
265265
exist in the cluster. For example, managed control plane providers for AKS, EKS, GKE, etc, should
266266
set this to `true`. Leaving the field undefined is equivalent to setting the value to `false`.
267+
* `.Conditions[Paused]` - is a condition that reports if the cluster or control plane resource is paused. It should check if 'spec.paused' is set on the cluster, and for the paused annotation on the resource. This is currently optional, but will become required in future.
268+
```go
269+
// Return early and set the paused condition to True if the object or Cluster
270+
// is paused.
271+
if annotations.IsPaused(cluster, m) {
272+
log.Info("Reconciliation is paused for this object")
273+
conditions.MarkTrue(m, clusterv1.PausedCondition)
274+
return ctrl.Result{}, nil
275+
}
276+
277+
conditions.MarkFalse(m, clusterv1.PausedCondition, clusterv1.ResourceNotPausedReason, clusterv1.ConditionSeverityInfo, "Resource is operating as expected")
278+
```
267279

268280
Note: once any of `failureReason` or `failureMessage` surface on the cluster who is referencing the control plane object,
269281
they cannot be restored anymore (it is considered a terminal error; the only way to recover is to delete and recreate the cluster).

docs/book/src/developer/providers/bootstrap.md

+16
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,22 @@ A bootstrap provider must define an API type for bootstrap resources. The type:
2626
meant to be suitable for programmatic interpretation
2727
2. `failureMessage` (string): indicates there is a fatal problem reconciling the bootstrap data;
2828
meant to be a more descriptive value than `failureReason`
29+
7. Should have `Status.Conditions` with the following:
30+
1. A `Status.Conditions[Paused]` to report if the cluster or bootstrap resource is paused. It should check if 'spec.paused' is set on the cluster, and for the paused annotation on the resource. This is currently optional, but will be required in the future.
31+
```go
32+
// Return early and set the paused condition to True if the object or Cluster
33+
// is paused.
34+
// We assume that the change to the object has to be written, e.g. via the
35+
// patchHelper in defer.
36+
if annotations.IsPaused(cluster, m) {
37+
log.Info("Reconciliation is paused for this object")
38+
conditions.MarkTrue(m, clusterv1.PausedCondition)
39+
return ctrl.Result{}, nil
40+
}
41+
42+
conditions.MarkFalse(m, clusterv1.PausedCondition, clusterv1.ResourceNotPausedReason, clusterv1.ConditionSeverityInfo, "Resource is operating as expected")
43+
```
44+
2945

3046
Note: once any of `failureReason` or `failureMessage` surface on the machine/machine pool who is referencing the bootstrap config object,
3147
they cannot be restored anymore (it is considered a terminal error; the only way to recover is to delete and recreate the machine/machine pool).

docs/book/src/developer/providers/cluster-infrastructure.md

+14
Original file line numberDiff line numberDiff line change
@@ -35,6 +35,20 @@ A cluster infrastructure provider must define an API type for "infrastructure cl
3535
`FailureDomainSpec` is defined as:
3636
- `controlPlane` (bool): indicates if failure domain is appropriate for running control plane instances.
3737
- `attributes` (`map[string]string`): arbitrary attributes for users to apply to a failure domain.
38+
7. Should have a `Status.Conditions` with the following:
39+
1. A `Paused` condition to report if the cluster or cluster infrastructure is paused. It should check if 'spec.paused' is set on the cluster, and for the paused annotation on the infrastructure. This is currently optional, but will be required in the future.
40+
```go
41+
// Return early and set the paused condition to True if the object or Cluster
42+
// is paused.
43+
// We assume that the change to the object has to be written, e.g. via the
44+
// patchHelper in defer.
45+
if annotations.IsPaused(cluster, m) {
46+
log.Info("Reconciliation is paused for this object")
47+
conditions.MarkTrue(m, clusterv1.PausedCondition)
48+
return ctrl.Result{}, nil
49+
}
50+
51+
conditions.MarkFalse(m, clusterv1.PausedCondition, clusterv1.ResourceNotPausedReason, clusterv1.ConditionSeverityInfo, "Resource is operating as expected")
3852

3953
Note: once any of `failureReason` or `failureMessage` surface on the cluster who is referencing the infrastructureCluster object,
4054
they cannot be restored anymore (it is considered a terminal error; the only way to recover is to delete and recreate the cluster).

docs/book/src/developer/providers/machine-infrastructure.md

+17-2
Original file line numberDiff line numberDiff line change
@@ -42,8 +42,23 @@ A machine infrastructure provider must define an API type for "infrastructure ma
4242
defined as:
4343
- `type` (string): one of `Hostname`, `ExternalIP`, `InternalIP`, `ExternalDNS`, `InternalDNS`
4444
- `address` (string)
45-
7. Should have a conditions field with the following:
46-
1. A Ready condition to represent the overall operational state of the component. It can be based on the summary of more detailed conditions existing on the same object, e.g. instanceReady, SecurityGroupsReady conditions.
45+
7. Should have a `Status.Conditions` field with the following:
46+
1. A `Ready` condition to represent the overall operational state of the component. It can be based on the summary of more detailed conditions existing on the same object, e.g. instanceReady, SecurityGroupsReady conditions.
47+
2. A `Paused` condition to report if the cluster or infrastructure machine is paused. It should check if 'spec.paused' is set on the cluster, and for the paused annotation on the infrastructure. This is currently optional, but will be required in the future.
48+
```go
49+
// Return early and set the paused condition to True if the object or Cluster
50+
// is paused.
51+
// We assume that the change to the object has to be written, e.g. via the
52+
// patchHelper in defer.
53+
if annotations.IsPaused(cluster, m) {
54+
log.Info("Reconciliation is paused for this object")
55+
conditions.MarkTrue(m, clusterv1.PausedCondition)
56+
return ctrl.Result{}, nil
57+
}
58+
59+
conditions.MarkFalse(m, clusterv1.PausedCondition, clusterv1.ResourceNotPausedReason, clusterv1.ConditionSeverityInfo, "Resource is operating as expected")
60+
```
61+
4762

4863
Note: once any of `failureReason` or `failureMessage` surface on the machine who is referencing the infrastructureMachine object,
4964
they cannot be restored anymore (it is considered a terminal error; the only way to recover is to delete and recreate the machine).

0 commit comments

Comments
 (0)