Skip to content

Commit e95f4ae

Browse files
guettlibuhodev
andauthored
🌱 rename and document annotations. (#1458)
Fixes #1457 Co-authored-by: Carlos Ivanchuk <[email protected]>
1 parent ddcac0a commit e95f4ae

8 files changed

+66
-25
lines changed

api/v1beta1/hcloudremediation_types.go

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -21,11 +21,6 @@ import (
2121
clusterv1 "sigs.k8s.io/cluster-api/api/v1beta1"
2222
)
2323

24-
const (
25-
// HCloudRebootAnnotation indicates that a bare metal host object should be rebooted.
26-
HCloudRebootAnnotation = "reboot.hcloud.infrastructure.cluster.x-k8s.io"
27-
)
28-
2924
// HCloudRemediationSpec defines the desired state of HCloudRemediation.
3025
type HCloudRemediationSpec struct {
3126
// Strategy field defines remediation strategy.

api/v1beta1/hetznerbaremetalhost_types.go

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,6 @@ import (
2121
"crypto/sha256"
2222
"encoding/json"
2323
"fmt"
24-
"strings"
2524
"time"
2625

2726
corev1 "k8s.io/api/core/v1"
@@ -46,10 +45,10 @@ const (
4645

4746
// WipeDiskAnnotation indicates which Disks (WWNs) to erase before provisioning
4847
// The value is a list of WWNS or "all".
49-
WipeDiskAnnotation = "wipedisk.hetznerbaremetalhost.infrastructure.cluster.x-k8s.io"
48+
WipeDiskAnnotation = "capi.syself.com/wipe-disk"
5049

5150
// IgnoreCheckDiskAnnotation indicates that the machine should get provisioned, even if CheckDisk fails.
52-
IgnoreCheckDiskAnnotation = "ignore-cd.hetznerbaremetalhost.infrastructure.cluster.x-k8s.io" // max length is 63 chars.
51+
IgnoreCheckDiskAnnotation = "capi.syself.com/ignore-check-disk"
5352
)
5453

5554
// RootDeviceHints holds the hints for specifying the storage location
@@ -602,7 +601,7 @@ func (host *HetznerBareMetalHost) ClearRebootAnnotations() {
602601
}
603602

604603
func isRebootAnnotation(annotation string) bool {
605-
return strings.HasPrefix(annotation, RebootAnnotation+"/") || annotation == RebootAnnotation
604+
return annotation == RebootAnnotation
606605
}
607606

608607
//+kubebuilder:object:root=true

api/v1beta1/hetznerbaremetalhost_types_test.go

Lines changed: 2 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -406,8 +406,6 @@ var _ = Describe("Test ClearRebootAnnotations", func() {
406406
expectAnnotations map[string]string
407407
}
408408

409-
secondRebootAnnotation := RebootAnnotation + "/"
410-
411409
DescribeTable("Test ClearRebootAnnotations",
412410
func(tc testCaseClearRebootAnnotations) {
413411
host := HetznerBareMetalHost{}
@@ -417,10 +415,6 @@ var _ = Describe("Test ClearRebootAnnotations", func() {
417415

418416
Expect(host.Annotations).Should(Equal(tc.expectAnnotations))
419417
},
420-
Entry("has reboot annotation - one annotation in list", testCaseClearRebootAnnotations{
421-
currentAnnotations: map[string]string{secondRebootAnnotation: "reboot", RebootAnnotation: "reboot"},
422-
expectAnnotations: map[string]string{},
423-
}),
424418
Entry("has multiple reboot annotations - no other annotation in list", testCaseClearRebootAnnotations{
425419
currentAnnotations: map[string]string{RebootAnnotation: "reboot"},
426420
expectAnnotations: map[string]string{},
@@ -430,7 +424,7 @@ var _ = Describe("Test ClearRebootAnnotations", func() {
430424
expectAnnotations: map[string]string{"other": "annotation"},
431425
}),
432426
Entry("has multiple reboot annotations - multiple annotations in list", testCaseClearRebootAnnotations{
433-
currentAnnotations: map[string]string{secondRebootAnnotation: "reboot", "other": "annotation", RebootAnnotation: "reboot"},
427+
currentAnnotations: map[string]string{"other": "annotation", RebootAnnotation: "reboot"},
434428
expectAnnotations: map[string]string{"other": "annotation"},
435429
}),
436430
Entry("has no reboot annotation", testCaseClearRebootAnnotations{
@@ -456,7 +450,7 @@ var _ = Describe("Test ClearRebootAnnotations", func() {
456450
}),
457451
Entry("reboot prefix", testCaseClearRebootAnnotations{
458452
annotation: RebootAnnotation + "/" + "suffix",
459-
expectBool: true,
453+
expectBool: false,
460454
}),
461455
Entry("other annotation", testCaseClearRebootAnnotations{
462456
annotation: "different/annotation",

api/v1beta1/hetznerbaremetalremediation_types.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -22,12 +22,12 @@ import (
2222

2323
const (
2424
// RebootAnnotation indicates that a bare metal host object should be rebooted.
25-
RebootAnnotation = "reboot.hetznerbaremetalhost.infrastructure.cluster.x-k8s.io"
25+
RebootAnnotation = "capi.syself.com/reboot"
2626

2727
// PermanentErrorAnnotation indicates that the bare metal host has an error which needs to be resolved manually.
2828
// After the permanent error the annotation got removed (usually by a human), the controller removes
2929
// ErrorType, ErrorCount and ErrorMessages, so that the hbmh will be usable again.
30-
PermanentErrorAnnotation = "error.hetznerbaremetalhost.infrastructure.cluster.x-k8s.io"
30+
PermanentErrorAnnotation = "capi.syself.com/permanent-error"
3131
)
3232

3333
// HetznerBareMetalRemediationSpec defines the desired state of HetznerBareMetalRemediation.

api/v1beta1/hetznercluster_webhook.go

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -74,10 +74,7 @@ func (r *HetznerCluster) ValidateCreate() (admission.Warnings, error) {
7474
hetznerclusterlog.V(1).Info("validate create", "name", r.Name)
7575
var allErrs field.ErrorList
7676

77-
allowEmptyControlPlaneAddress := false
78-
if r.Annotations != nil {
79-
allowEmptyControlPlaneAddress = r.Annotations[AllowEmptyControlPlaneAddressAnnotation] == "true"
80-
}
77+
allowEmptyControlPlaneAddress := r.Annotations[AllowEmptyControlPlaneAddressAnnotation] == "true"
8178

8279
if !allowEmptyControlPlaneAddress && len(r.Spec.ControlPlaneRegions) == 0 {
8380
allErrs = append(allErrs, field.Invalid(

controllers/hetznerbaremetalremediation_controller_test.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -252,7 +252,7 @@ var _ = Describe("HetznerBareMetalRemediationReconciler", func() {
252252
Expect(testEnv.Cleanup(ctx, testNs, hetznerSecret, osSSHSecret, rescueSSHSecret, bootstrapSecret)).To(Succeed())
253253
})
254254

255-
Context("HetznerBaremetalHost doesn't exist", func() {
255+
Context("HetznerBareMetalHost doesn't exist", func() {
256256
AfterEach(func() {
257257
Expect(testEnv.Cleanup(ctx, hetznerBareMetalRemediation, hetznerBaremetalMachine)).To(Succeed())
258258
})
@@ -287,7 +287,7 @@ var _ = Describe("HetznerBareMetalRemediationReconciler", func() {
287287
})
288288
})
289289

290-
Context("HetznerBaremetalHost exist", func() {
290+
Context("HetznerBareMetalHost exist", func() {
291291
BeforeEach(func() {
292292
hostKey = client.ObjectKey{Name: hostName, Namespace: testNs.Name}
293293

docs/README.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,7 @@ This is the official documentation of Cluster API Provider Hetzner. Before start
2626
- [HetznerBareMetalHost](/docs/caph/03-reference/05-hetzner-bare-metal-host.md)
2727
- [HetznerBareMetalMachineTemplate](/docs/caph/03-reference/06-hetzner-bare-metal-machine-template.md)
2828
- [HetznerBareMetalRemediationTemplate](/docs/caph/03-reference/07-hetzner-bare-metal-remediation-template.md)
29+
- [Annotations](/docs/caph/03-reference/08-annotations.md)
2930

3031
## Development
3132

Lines changed: 55 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,55 @@
1+
---
2+
3+
title: Annotations
4+
5+
---
6+
7+
You can set [Kubernetes Annotations](https://kubernetes.io/docs/concepts/overview/working-with-objects/annotations/) to instruct the Syself CAPH Controller to modify its behavior.
8+
9+
## Overview of Annotations
10+
11+
### capi.syself.com/wipe-disk
12+
13+
| **Resource** | [HetznerBareMetalHost](/docs/caph/03-reference/05-hetzner-bare-metal-host.md) |
14+
| --------------- | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
15+
| **Description** | This annotation instructs the Syself CAPH Controller to wipe the disk before provisioning the machine. |
16+
| **Value** | You can use the string `"all"` or a space-separated list of WWNs. For example, `"10:00:00:05:1e:7a:7a:00 eui.00253885910c8cec 0x500a07511bb48b25"`. If the value is empty, no disks will be wiped. The value `"all"` will wipe all disks on the bare-metal machine (not just the one given in the rootDeviceHints). |
17+
| **Auto-Remove** | Enabled: The annotation is removed after the disks are wiped. |
18+
19+
### capi.syself.com/ignore-check-disk
20+
21+
| **Resource** | [HetznerBareMetalHost](/docs/caph/03-reference/05-hetzner-bare-metal-host.md) |
22+
| --------------- | ----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
23+
| **Description** | This annotation instructs the Syself CAPH Controller to ignore the results of the check-disk step during machine provisioning. The check will be performed, and a Kubernetes Event will be created. However, if this annotation is set, provisioning will continue even if a faulty disk is detected. |
24+
| **Value** | The value is ignored. If the annotation exists, this feature is enabled. |
25+
| **Auto-Remove** | Disabled: The annotation remains on the resource. It is up to the user to remove it. |
26+
27+
### capi.syself.com/allow-empty-control-plane-address
28+
29+
| **Resource** | [HetznerCluster](/docs/caph/03-reference/02-hetzner-cluster.md) |
30+
| --------------- | -------------------------------------------------------------------------------------------------------------------------- |
31+
| **Description** | This annotation allows the Syself CAPH Controller to create HetznerCluster resources with an empty `controlPlaneEndpoint`. This is useful to support externally managed control planes ([PR 1106](https://github.com/syself/cluster-api-provider-hetzner/pull/1106)) |
32+
| **Value** | `"true"` enables this feature. All other strings are considered `"false"`. |
33+
| **Auto-Remove** | Disabled: The annotation remains on the resource. |
34+
35+
### capi.syself.com/constant-bare-metal-hostname
36+
37+
| **Resource** | Cluster (CRD of Cluster-API), HetznerBareMetalMachine |
38+
| --------------- | ------------------------------------------------------------------------------------------------------------ |
39+
| **Description** | See [Using constant hostnames](/docs/caph/02-topics/05-baremetal/04-constant-hostnames.md) for more details. |
40+
| **Auto-Remove** | Disabled: The annotation remains on the resource. |
41+
42+
### capi.syself.com/reboot
43+
44+
| **Resource** | [HetznerBareMetalHost](/docs/caph/03-reference/05-hetzner-bare-metal-host.md) |
45+
| --------------- | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
46+
| **Description** | If this annotation is present, the bare-metal machine will be rebooted. This annotation is used by `HetznerBareMetalRemediation` (see [Machine Health Checks with Custom Remediation Template](/docs/caph/02-topics/06-advanced/04-custom-templates-mhc.md)). |
47+
| **Value** | The value is ignored. If the annotation exists, this feature is enabled. |
48+
| **Auto-Remove** | Enabled: The annotation is removed after the reboot. |
49+
50+
### capi.syself.com/permanent-error
51+
52+
| **Resource** | [HetznerBareMetalHost](/docs/caph/03-reference/05-hetzner-bare-metal-host.md) |
53+
| --------------- | -------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
54+
| **Description** | This annotation is set by the Syself CAPH Controller when a bare-metal machine enters the "permanent error" state. This indicates that human intervention is required (e.g., to fix a broken disk). After the root cause is resolved, the user must remove this annotation to allow the Controller to manage the HetznerBareMetalHost again. |
55+
| **Auto-Remove** | Disabled: The annotation must be removed by the user. |

0 commit comments

Comments
 (0)