Skip to content

Commit

Permalink
Do not set owner for PV of OVA provider
Browse files Browse the repository at this point in the history
There is no point in setting the OVA provider as the owner of the PV we
create for it since the PV is not namespace-scoped and thus, it is not
removed when the OVA provider is removed.

Signed-off-by: Arik Hadas <[email protected]>
  • Loading branch information
ahadas committed Dec 19, 2023
1 parent 742b4f2 commit 12740eb
Showing 1 changed file with 10 additions and 11 deletions.
21 changes: 10 additions & 11 deletions pkg/controller/provider/ova-setup.go
Original file line number Diff line number Diff line change
Expand Up @@ -27,19 +27,19 @@ const (
)

func (r Reconciler) CreateOVAServerDeployment(provider *api.Provider, ctx context.Context) {
ownerReference := metav1.OwnerReference{
APIVersion: "forklift.konveyor.io/v1beta1",
Kind: "Provider",
Name: provider.Name,
UID: provider.UID,
}
pvName := fmt.Sprintf("%s-pv-%s-%s", ovaServer, provider.Name, provider.Namespace)
err := r.createPvForNfs(provider, ctx, ownerReference, pvName)
err := r.createPvForNfs(provider, ctx, pvName)
if err != nil {
r.Log.Error(err, "Failed to create PV for the OVA server")
return
}

ownerReference := metav1.OwnerReference{
APIVersion: "forklift.konveyor.io/v1beta1",
Kind: "Provider",
Name: provider.Name,
UID: provider.UID,
}
pvcName := fmt.Sprintf("%s-pvc-%s", ovaServer, provider.Name)
err = r.createPvcForNfs(provider, ctx, ownerReference, pvName, pvcName)
if err != nil {
Expand All @@ -61,17 +61,16 @@ func (r Reconciler) CreateOVAServerDeployment(provider *api.Provider, ctx contex
}
}

func (r *Reconciler) createPvForNfs(provider *api.Provider, ctx context.Context, ownerReference metav1.OwnerReference, pvName string) (err error) {
func (r *Reconciler) createPvForNfs(provider *api.Provider, ctx context.Context, pvName string) (err error) {
splitted := strings.Split(provider.Spec.URL, ":")
nfsServer := splitted[0]
nfsPath := splitted[1]
labels := map[string]string{"provider": provider.Name, "app": "forklift", "subapp": ovaServer}

pv := &core.PersistentVolume{
ObjectMeta: metav1.ObjectMeta{
Name: pvName,
OwnerReferences: []metav1.OwnerReference{ownerReference},
Labels: labels,
Name: pvName,
Labels: labels,
},
Spec: core.PersistentVolumeSpec{
Capacity: core.ResourceList{
Expand Down

0 comments on commit 12740eb

Please sign in to comment.