Skip to content

Commit

Permalink
WIP: Update provider contract to account for the paused condition
Browse files Browse the repository at this point in the history
  • Loading branch information
theobarberbany committed Apr 25, 2024
1 parent a076444 commit 285b232
Show file tree
Hide file tree
Showing 3 changed files with 38 additions and 1 deletion.
14 changes: 14 additions & 0 deletions docs/book/src/developer/providers/bootstrap.md
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,20 @@ A bootstrap provider must define an API type for bootstrap resources. The type:
meant to be suitable for programmatic interpretation
2. `failureMessage` (string): indicates there is a fatal problem reconciling the bootstrap data;
meant to be a more descriptive value than `failureReason`
7. Should have a conditions field with the following:
1. A Paused condition 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.
```go
// Return early and set the paused condition to True if the object or Cluster
// is paused.
if annotations.IsPaused(cluster, m) {
log.Info("Reconciliation is paused for this object, setting Paused condition")
conditions.MarkTrue(m, clusterv1.PausedCondition)
return ctrl.Result{}, nil
}

conditions.MarkFalse(m, clusterv1.PausedCondition, clusterv1.ResourceNotPausedReason, clusterv1.ConditionSeverityInfo, "Resource is operating as expected")
```


Note: because the `dataSecretName` is part of `status`, this value must be deterministically recreatable from the data in the
`Cluster`, `Machine`, and/or bootstrap resource. If the name is randomly generated, it is not always possible to move
Expand Down
12 changes: 12 additions & 0 deletions docs/book/src/developer/providers/cluster-infrastructure.md
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,18 @@ A cluster infrastructure provider must define an API type for "infrastructure cl
`FailureDomainSpec` is defined as:
- `controlPlane` (bool): indicates if failure domain is appropriate for running control plane instances.
- `attributes` (`map[string]string`): arbitrary attributes for users to apply to a failure domain.
7. Should have a conditions field with the following:
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.
```go
// Return early and set the paused condition to True if the object or Cluster
// is paused.
if annotations.IsPaused(cluster, m) {
log.Info("Reconciliation is paused for this object, setting Paused condition")
conditions.MarkTrue(m, clusterv1.PausedCondition)
return ctrl.Result{}, nil
}

conditions.MarkFalse(m, clusterv1.PausedCondition, clusterv1.ResourceNotPausedReason, clusterv1.ConditionSeverityInfo, "Resource is operating as expected")

### InfraClusterTemplate Resources

Expand Down
13 changes: 12 additions & 1 deletion docs/book/src/developer/providers/machine-infrastructure.md
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,18 @@ A machine infrastructure provider must define an API type for "infrastructure ma
- `address` (string)
7. Should have a conditions field with the following:
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.

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.
```go
// Return early and set the paused condition to True if the object or Cluster
// is paused.
if annotations.IsPaused(cluster, m) {
log.Info("Reconciliation is paused for this object, setting Paused condition")
conditions.MarkTrue(m, clusterv1.PausedCondition)
return ctrl.Result{}, nil
}

conditions.MarkFalse(m, clusterv1.PausedCondition, clusterv1.ResourceNotPausedReason, clusterv1.ConditionSeverityInfo, "Resource is operating as expected")
```

### InfraMachineTemplate Resources

Expand Down

0 comments on commit 285b232

Please sign in to comment.