From 285b232785cd679706ce0d1fbe503fe657e37561 Mon Sep 17 00:00:00 2001 From: Theo Barber-Bany Date: Thu, 25 Apr 2024 16:45:08 +0100 Subject: [PATCH] WIP: Update provider contract to account for the paused condition --- docs/book/src/developer/providers/bootstrap.md | 14 ++++++++++++++ .../developer/providers/cluster-infrastructure.md | 12 ++++++++++++ .../developer/providers/machine-infrastructure.md | 13 ++++++++++++- 3 files changed, 38 insertions(+), 1 deletion(-) diff --git a/docs/book/src/developer/providers/bootstrap.md b/docs/book/src/developer/providers/bootstrap.md index 21ef14cf4d8a..c120d8caf4ed 100644 --- a/docs/book/src/developer/providers/bootstrap.md +++ b/docs/book/src/developer/providers/bootstrap.md @@ -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 diff --git a/docs/book/src/developer/providers/cluster-infrastructure.md b/docs/book/src/developer/providers/cluster-infrastructure.md index 907ca246fd59..72a2b8a1839c 100644 --- a/docs/book/src/developer/providers/cluster-infrastructure.md +++ b/docs/book/src/developer/providers/cluster-infrastructure.md @@ -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 diff --git a/docs/book/src/developer/providers/machine-infrastructure.md b/docs/book/src/developer/providers/machine-infrastructure.md index db4cae023a14..39322d909b2a 100644 --- a/docs/book/src/developer/providers/machine-infrastructure.md +++ b/docs/book/src/developer/providers/machine-infrastructure.md @@ -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