From 4dcadc3b09340103c54c99c7bd5766ddd2385b58 Mon Sep 17 00:00:00 2001 From: Arik Hadas Date: Wed, 4 Oct 2023 13:57:35 +0300 Subject: [PATCH] minor cleanup to recent OVA related changes Signed-off-by: Arik Hadas --- pkg/controller/plan/migration.go | 2 +- pkg/controller/provider/controller.go | 2 +- pkg/controller/provider/ova-setup.go | 16 ++++++++-------- 3 files changed, 10 insertions(+), 10 deletions(-) diff --git a/pkg/controller/plan/migration.go b/pkg/controller/plan/migration.go index b841a77a4..9d3cde4cb 100644 --- a/pkg/controller/plan/migration.go +++ b/pkg/controller/plan/migration.go @@ -340,7 +340,7 @@ func (r *Migration) Archive() { if r.Plan.Provider.Source.Type() == v1beta1.Ova { err = r.deletePvcPvForOva() if err != nil { - r.Log.Error(err, "Failed to cleanup the PVC and PV for OVA plan") + r.Log.Error(err, "Failed to clean up the PVC and PV for the OVA plan") return } } diff --git a/pkg/controller/provider/controller.go b/pkg/controller/provider/controller.go index 073c01e7a..3178e11f3 100644 --- a/pkg/controller/provider/controller.go +++ b/pkg/controller/provider/controller.go @@ -187,7 +187,7 @@ func (r Reconciler) Reconcile(ctx context.Context, request reconcile.Request) (r if provider.Type() == api.Ova { - deploymentName := fmt.Sprintf("%s-deployment-%s", ovaServerPrefix, provider.Name) + deploymentName := fmt.Sprintf("%s-deployment-%s", ovaServer, provider.Name) deployment := &appsv1.Deployment{} err = r.Get(context.TODO(), client.ObjectKey{ diff --git a/pkg/controller/provider/ova-setup.go b/pkg/controller/provider/ova-setup.go index 7731b551f..776b8cdf8 100644 --- a/pkg/controller/provider/ova-setup.go +++ b/pkg/controller/provider/ova-setup.go @@ -15,7 +15,7 @@ import ( ) const ( - ovaServerPrefix = "ova-server" + ovaServer = "ova-server" ovaImageVar = "OVA_PROVIDER_SERVER_IMAGE" nfsVolumeNamePrefix = "nfs-volume" mountPath = "/ova" @@ -29,21 +29,21 @@ func (r Reconciler) CreateOVAServerDeployment(provider *api.Provider, ctx contex Name: provider.Name, UID: provider.UID, } - pvName := fmt.Sprintf("%s-pv-%s-%s", ovaServerPrefix, provider.Name, provider.Namespace) + pvName := fmt.Sprintf("%s-pv-%s-%s", ovaServer, provider.Name, provider.Namespace) err := r.createPvForNfs(provider, ctx, ownerReference, pvName) if err != nil { r.Log.Error(err, "Failed to create PV for the OVA server") return } - pvcName := fmt.Sprintf("%s-pvc-%s", ovaServerPrefix, provider.Name) + pvcName := fmt.Sprintf("%s-pvc-%s", ovaServer, provider.Name) err = r.createPvcForNfs(provider, ctx, ownerReference, pvName, pvcName) if err != nil { r.Log.Error(err, "Failed to create PVC for the OVA server") return } - labels := map[string]string{"provider": provider.Name, "app": "forklift", "subapp": "ova-server"} + labels := map[string]string{"provider": provider.Name, "app": "forklift", "subapp": ovaServer} err = r.createServerDeployment(provider, ctx, ownerReference, pvcName, labels) if err != nil { r.Log.Error(err, "Failed to create OVA server deployment") @@ -61,7 +61,7 @@ func (r *Reconciler) createPvForNfs(provider *api.Provider, ctx context.Context, splitted := strings.Split(provider.Spec.URL, ":") nfsServer := splitted[0] nfsPath := splitted[1] - labels := map[string]string{"provider": provider.Name, "app": "forklift", "subapp": "ova-server"} + labels := map[string]string{"provider": provider.Name, "app": "forklift", "subapp": ovaServer} pv := &core.PersistentVolume{ ObjectMeta: metav1.ObjectMeta{ @@ -93,7 +93,7 @@ func (r *Reconciler) createPvForNfs(provider *api.Provider, ctx context.Context, func (r *Reconciler) createPvcForNfs(provider *api.Provider, ctx context.Context, ownerReference metav1.OwnerReference, pvName, pvcName string) (err error) { sc := "" - labels := map[string]string{"provider": provider.Name, "app": "forklift", "subapp": "ova-server"} + labels := map[string]string{"provider": provider.Name, "app": "forklift", "subapp": ovaServer} pvc := &core.PersistentVolumeClaim{ ObjectMeta: metav1.ObjectMeta{ Name: pvcName, @@ -122,7 +122,7 @@ func (r *Reconciler) createPvcForNfs(provider *api.Provider, ctx context.Context } func (r *Reconciler) createServerDeployment(provider *api.Provider, ctx context.Context, ownerReference metav1.OwnerReference, pvcName string, labels map[string]string) (err error) { - deploymentName := fmt.Sprintf("%s-deployment-%s", ovaServerPrefix, provider.Name) + deploymentName := fmt.Sprintf("%s-deployment-%s", ovaServer, provider.Name) annotations := make(map[string]string) var replicas int32 = 1 @@ -192,7 +192,7 @@ func (r *Reconciler) makeOvaProviderPodSpec(pvcName string, providerName string) } nfsVolumeName := fmt.Sprintf("%s-%s", nfsVolumeNamePrefix, providerName) - ovaContainerName := fmt.Sprintf("%s-pod-%s", ovaServerPrefix, providerName) + ovaContainerName := fmt.Sprintf("%s-pod-%s", ovaServer, providerName) return core.PodSpec{ Containers: []core.Container{