Skip to content

Commit

Permalink
fix(GcpNfsVolumeBackup/Restore) optional nfsvolume ref namespace
Browse files Browse the repository at this point in the history
  • Loading branch information
ravi-shankar-sap committed Sep 5, 2024
1 parent abf3e2f commit e4a874b
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 13 deletions.
11 changes: 3 additions & 8 deletions pkg/skr/gcpnfsvolumebackup/loadGcpNfsVolume.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,13 +2,11 @@ package gcpnfsvolumebackup

import (
"context"
cloudcontrolv1beta1 "github.com/kyma-project/cloud-manager/api/cloud-control/v1beta1"
cloudresourcesv1beta1 "github.com/kyma-project/cloud-manager/api/cloud-resources/v1beta1"
"github.com/kyma-project/cloud-manager/pkg/composed"
"k8s.io/apimachinery/pkg/api/meta"
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
"k8s.io/apimachinery/pkg/types"

cloudcontrolv1beta1 "github.com/kyma-project/cloud-manager/api/cloud-control/v1beta1"
"github.com/kyma-project/cloud-manager/pkg/composed"
)

func loadGcpNfsVolume(ctx context.Context, st composed.State) (error, context.Context) {
Expand All @@ -30,10 +28,7 @@ func loadGcpNfsVolume(ctx context.Context, st composed.State) (error, context.Co

//Load the nfsVolume object
nfsVolume := &cloudresourcesv1beta1.GcpNfsVolume{}
nfsVolumeKey := types.NamespacedName{
Name: backup.Spec.Source.Volume.Name,
Namespace: backup.Spec.Source.Volume.Namespace,
}
nfsVolumeKey := backup.Spec.Source.Volume.ToNamespacedName(backup.Namespace)
err := state.SkrCluster.K8sClient().Get(ctx, nfsVolumeKey, nfsVolume)
if err != nil {
backup.Status.State = cloudresourcesv1beta1.GcpNfsBackupError
Expand Down
6 changes: 1 addition & 5 deletions pkg/skr/gcpnfsvolumerestore/loadGcpNfsVolume.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@ import (
cloudresourcesv1beta1 "github.com/kyma-project/cloud-manager/api/cloud-resources/v1beta1"
"k8s.io/apimachinery/pkg/api/meta"
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
"k8s.io/apimachinery/pkg/types"
"sigs.k8s.io/controller-runtime/pkg/client"

cloudcontrolv1beta1 "github.com/kyma-project/cloud-manager/api/cloud-control/v1beta1"
Expand All @@ -26,10 +25,7 @@ func loadGcpNfsVolume(ctx context.Context, st composed.State) (error, context.Co

//Load the nfsVolume object
nfsVolume := &cloudresourcesv1beta1.GcpNfsVolume{}
nfsVolumeKey := types.NamespacedName{
Name: restore.Spec.Destination.Volume.Name,
Namespace: restore.Spec.Destination.Volume.Namespace,
}
nfsVolumeKey := restore.Spec.Destination.Volume.ToNamespacedName(restore.Namespace)
err := state.SkrCluster.K8sClient().Get(ctx, nfsVolumeKey, nfsVolume)
if client.IgnoreNotFound(err) != nil {
return composed.LogErrorAndReturn(err, "Error loading SKR GcpNfsVolume", composed.StopWithRequeue, ctx)
Expand Down

0 comments on commit e4a874b

Please sign in to comment.