Skip to content

Commit

Permalink
fix: add move label to BMC secrets
Browse files Browse the repository at this point in the history
This PR fixes a bug where BMC secrets weren't getting moved when using
`clusterctl move`. We'll now add the "move" label to the BMC secrets
when they're created so we can be sure they come for the ride.

Signed-off-by: Spencer Smith <spencer.smith@talos-systems.com>
  • Loading branch information
rsmitty committed Jan 31, 2022
1 parent f28d7b0 commit 5e3f68d
Showing 1 changed file with 6 additions and 2 deletions.
8 changes: 6 additions & 2 deletions app/sidero-controller-manager/internal/server/server.go
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ import (
"k8s.io/client-go/tools/record"
"k8s.io/client-go/tools/reference"
clusterv1 "sigs.k8s.io/cluster-api/api/v1beta1"
clusterctl "sigs.k8s.io/cluster-api/cmd/clusterctl/api/v1alpha3"
"sigs.k8s.io/cluster-api/util/conditions"
"sigs.k8s.io/cluster-api/util/patch"
controllerclient "sigs.k8s.io/controller-runtime/pkg/client"
Expand Down Expand Up @@ -301,8 +302,8 @@ func (s *server) UpdateBMCInfo(ctx context.Context, in *api.UpdateBMCInfoRequest
credsSecret := &corev1.Secret{}
exists := true

// For auto-created BMC info, we will *always* drop the creds in default namespace
// This ensures they'll come along for the ride in a "default" clusterctl move based on our cluster templates.
// For auto-created BMC info, we will add the "move" label from clusterctl's labels.
// This ensures they'll come along for the ride in a clusterctl move.
bmcSecretName := in.GetUuid() + "-bmc"

if err := s.c.Get(ctx, types.NamespacedName{Namespace: corev1.NamespaceDefault, Name: bmcSecretName}, credsSecret); err != nil {
Expand All @@ -318,6 +319,9 @@ func (s *server) UpdateBMCInfo(ctx context.Context, in *api.UpdateBMCInfoRequest
OwnerReferences: []metav1.OwnerReference{
*metav1.NewControllerRef(obj, metalv1alpha1.GroupVersion.WithKind("Server")),
},
Labels: map[string]string{
clusterctl.ClusterctlMoveLabelName: "",
},
}

exists = false
Expand Down

0 comments on commit 5e3f68d

Please sign in to comment.