Skip to content

Commit

Permalink
minor cleanup to recent OVA related changes
Browse files Browse the repository at this point in the history
Signed-off-by: Arik Hadas <[email protected]>
  • Loading branch information
ahadas committed Oct 4, 2023
1 parent 88ed5c7 commit 4dcadc3
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 10 deletions.
2 changes: 1 addition & 1 deletion pkg/controller/plan/migration.go
Original file line number Diff line number Diff line change
Expand Up @@ -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
}
}
Expand Down
2 changes: 1 addition & 1 deletion pkg/controller/provider/controller.go
Original file line number Diff line number Diff line change
Expand Up @@ -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{
Expand Down
16 changes: 8 additions & 8 deletions pkg/controller/provider/ova-setup.go
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ import (
)

const (
ovaServerPrefix = "ova-server"
ovaServer = "ova-server"
ovaImageVar = "OVA_PROVIDER_SERVER_IMAGE"
nfsVolumeNamePrefix = "nfs-volume"
mountPath = "/ova"
Expand All @@ -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")
Expand All @@ -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{
Expand Down Expand Up @@ -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,
Expand Down Expand Up @@ -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

Expand Down Expand Up @@ -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{
Expand Down

0 comments on commit 4dcadc3

Please sign in to comment.