diff --git a/controller/linodemachine_controller_helpers.go b/controller/linodemachine_controller_helpers.go index 0bd8d8579..66b2d801f 100644 --- a/controller/linodemachine_controller_helpers.go +++ b/controller/linodemachine_controller_helpers.go @@ -28,7 +28,6 @@ import ( "github.com/go-logr/logr" "github.com/google/uuid" "github.com/linode/cluster-api-provider-linode/cloud/scope" - "github.com/linode/cluster-api-provider-linode/util" "github.com/linode/cluster-api-provider-linode/util/reconciler" "github.com/linode/linodego" apierrors "k8s.io/apimachinery/pkg/api/errors" @@ -81,7 +80,7 @@ func (*LinodeMachineReconciler) newCreateConfig(ctx context.Context, machineScop createConfig.Tags = append(createConfig.Tags, tags...) if createConfig.Label == "" { - createConfig.Label = util.RenderObjectLabel(machineScope.LinodeMachine.UID) + createConfig.Label = machineScope.LinodeMachine.Name } if createConfig.Image == "" { diff --git a/controller/linodevpc_controller_helpers.go b/controller/linodevpc_controller_helpers.go index bb3606a93..2c168bb85 100644 --- a/controller/linodevpc_controller_helpers.go +++ b/controller/linodevpc_controller_helpers.go @@ -41,7 +41,7 @@ func (r *LinodeVPCReconciler) reconcileVPC(ctx context.Context, vpcScope *scope. } if createConfig.Label == "" { - createConfig.Label = util.RenderObjectLabel(vpcScope.LinodeVPC.UID) + createConfig.Label = vpcScope.LinodeVPC.Name } if vpcs, err := vpcScope.LinodeClient.ListVPCs(ctx, linodego.NewListOptions(1, util.CreateLinodeAPIFilter(createConfig.Label, nil))); err != nil { diff --git a/e2e/Makefile b/e2e/Makefile index f7237cd25..5ca1917a7 100644 --- a/e2e/Makefile +++ b/e2e/Makefile @@ -17,6 +17,9 @@ _runThisTest: getKubeUid: @kubectl get -o jsonpath='{.metadata.uid}' -n "$$NAMESPACE" "$$OBJ" +getKubeLabel: + @kubectl get -o jsonpath='{.spec.label}' -n "$$NAMESPACE" "$$OBJ" + patchKubeObj: @kubectl patch --type=merge -p "$$PATCH" -n "$$NAMESPACE" "$$OBJ" diff --git a/e2e/linodevpc-controller/minimal/03-verify-vpc.yaml b/e2e/linodevpc-controller/minimal/03-verify-vpc.yaml index 3bba71c50..d9a05761a 100644 --- a/e2e/linodevpc-controller/minimal/03-verify-vpc.yaml +++ b/e2e/linodevpc-controller/minimal/03-verify-vpc.yaml @@ -2,4 +2,4 @@ apiVersion: kuttl.dev/v1beta1 kind: TestStep commands: - script: |- - URI="vpcs" FILTER="{\"label\":\"cli-$(OBJ=linodevpcs/linodevpc-sample make getKubeUid | sed 's/-//g')\"}" make callLinodeApiGet | grep 'results": 0' + URI="vpcs" FILTER="{\"label\":\"$(OBJ=linodevpcs/linodevpc-sample make getKubeLabel)\"}" make callLinodeApiGet | grep 'results": 0' diff --git a/util/helpers.go b/util/helpers.go index 25c0b2403..86f472dd2 100644 --- a/util/helpers.go +++ b/util/helpers.go @@ -2,11 +2,9 @@ package util import ( "encoding/json" - "fmt" "strings" "github.com/linode/linodego" - "k8s.io/apimachinery/pkg/types" ) // Pointer returns the pointer of any type @@ -14,11 +12,6 @@ func Pointer[T any](t T) *T { return &t } -// RenderObjectLabel renders a 63 charater long unique label -func RenderObjectLabel(i types.UID) string { - return fmt.Sprintf("cli-%s", strings.ReplaceAll(string(i), "-", "")) -} - // CreateLinodeAPIFilter converts variables to API filter string func CreateLinodeAPIFilter(label string, tags []string) string { filter := map[string]string{}