Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Kubevirt minimize #8

Closed
wants to merge 32 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
32 commits
Select commit Hold shift + click to select a range
896efdd
add subscription workload
Apr 30, 2024
750c8b7
update make e2e-rdr script to let rdr-e2e.sh could run directly
May 6, 2024
9ed3a8c
rename rdr-e2e.sh to e2e-rdr.sh
May 6, 2024
11b20d1
create channel and wait for subscription is ready
May 7, 2024
27273e9
adopt the latest e2e.yaml change for e2e workflow
May 7, 2024
722442b
refactor code based on review comments
May 13, 2024
97c6e61
fix lint issue
May 15, 2024
54f59d5
use viper lib to read config in env and yaml
May 16, 2024
24b60ac
wait DRPC to be deleted
May 17, 2024
d981687
Skip unneeded setup based on minikube version
nirs May 17, 2024
1cf25fb
Update minikube tested version to v1.33.1
nirs May 17, 2024
a56be4d
Remove note about --extra-disk argument
nirs May 17, 2024
e2b4d3b
Upgrade olm version from v0.22.0 to v0.27.0
abhijeet219 May 14, 2024
c159b76
Add single cluster env for olm
abhijeet219 May 14, 2024
08a376b
Use static kustomization for olm
abhijeet219 May 14, 2024
ec2118a
Cache olm resources
abhijeet219 May 14, 2024
463cfcf
Downgrade olm back to 0.22
nirs May 20, 2024
b5f8936
util: add ProtectedPVCNamespacedName func
raghavendra-talur May 13, 2024
2226128
vrg: add adminNamespaceVRG field to vshandler
raghavendra-talur May 13, 2024
edb3f16
vrg: use FindProtectedPVC and remove findFirstProtectedPVCWithName
raghavendra-talur May 13, 2024
055e866
vrg: send pvcNamespacedName everywhere instead of just name
raghavendra-talur May 13, 2024
edafd9f
volsync: skip ownerRef on pvc,RD,RS when in multinamespace mode
raghavendra-talur May 13, 2024
e481c2e
volsync: create volsync secret in the pvc ns not vrg
raghavendra-talur May 15, 2024
6057eb1
tests: fix tests for NewVSHandler
raghavendra-talur May 18, 2024
7d26db3
tests: fix test for TakePVCOwnership
raghavendra-talur May 18, 2024
a5e356f
tests: make sure protected pvc in test have ns
raghavendra-talur May 18, 2024
d93ac1f
Fail e2e workflow if tests failed
nirs May 22, 2024
691062c
Don't cleanup nil request
nirs May 22, 2024
4c943bd
Upgrade kubevirt to 1.2.1
nirs May 28, 2024
78f3c3f
Upgrade CDI to 1.59.0
nirs May 28, 2024
d35ecf0
Use single replica in virt-operator
nirs May 15, 2024
999e108
Use single replica for virt-controller
nirs May 15, 2024
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -189,7 +189,7 @@ test-ramenctl: ## Run ramenctl tests.
$(MAKE) -C ramenctl

e2e-rdr: generate manifests ## Run rdr-e2e tests.
./e2e/rdr-e2e.sh
cd e2e && ./e2e-rdr.sh

coverage:
go tool cover -html=cover.out
Expand Down
9 changes: 9 additions & 0 deletions controllers/util/objectmeta.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,9 @@
package util

import (
ramen "github.com/ramendr/ramen/api/v1alpha1"
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
"k8s.io/apimachinery/pkg/types"
"sigs.k8s.io/controller-runtime/pkg/client"
)

Expand All @@ -23,3 +25,10 @@ func ObjectMetaEmbedded(objectMeta *metav1.ObjectMeta) metav1.ObjectMeta {
func ResourceIsDeleted(obj client.Object) bool {
return !obj.GetDeletionTimestamp().IsZero()
}

func ProtectedPVCNamespacedName(pvc ramen.ProtectedPVC) types.NamespacedName {
return types.NamespacedName{
Namespace: pvc.Namespace,
Name: pvc.Name,
}
}
270 changes: 176 additions & 94 deletions controllers/volsync/vshandler.go

Large diffs are not rendered by default.

39 changes: 29 additions & 10 deletions controllers/volsync/vshandler_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -87,7 +87,7 @@ var _ = Describe("VolSync Handler - Volume Replication Class tests", func() {
var vsHandler *volsync.VSHandler

BeforeEach(func() {
vsHandler = volsync.NewVSHandler(ctx, k8sClient, logger, nil, asyncSpec, "none", "Snapshot")
vsHandler = volsync.NewVSHandler(ctx, k8sClient, logger, nil, asyncSpec, "none", "Snapshot", false)
})

It("GetVolumeSnapshotClasses() should find all volume snapshot classes", func() {
Expand Down Expand Up @@ -116,7 +116,7 @@ var _ = Describe("VolSync Handler - Volume Replication Class tests", func() {
},
}

vsHandler = volsync.NewVSHandler(ctx, k8sClient, logger, nil, asyncSpec, "none", "Snapshot")
vsHandler = volsync.NewVSHandler(ctx, k8sClient, logger, nil, asyncSpec, "none", "Snapshot", false)
})

It("GetVolumeSnapshotClasses() should find matching volume snapshot classes", func() {
Expand Down Expand Up @@ -159,7 +159,7 @@ var _ = Describe("VolSync Handler - Volume Replication Class tests", func() {
},
}

vsHandler = volsync.NewVSHandler(ctx, k8sClient, logger, nil, asyncSpec, "none", "Snapshot")
vsHandler = volsync.NewVSHandler(ctx, k8sClient, logger, nil, asyncSpec, "none", "Snapshot", false)
})

It("GetVolumeSnapshotClasses() should find matching volume snapshot classes", func() {
Expand Down Expand Up @@ -216,7 +216,7 @@ var _ = Describe("VolSync Handler - Volume Replication Class tests", func() {

// Initialize a vshandler
vsHandler = volsync.NewVSHandler(ctx, k8sClient, logger, nil, asyncSpec,
"openshift-storage.cephfs.csi.ceph.com", "Snapshot")
"openshift-storage.cephfs.csi.ceph.com", "Snapshot", false)
})

JustBeforeEach(func() {
Expand Down Expand Up @@ -431,7 +431,7 @@ var _ = Describe("VolSync_Handler", func() {
Expect(ownerCm.GetName()).NotTo(BeEmpty())
owner = ownerCm

vsHandler = volsync.NewVSHandler(ctx, k8sClient, logger, owner, asyncSpec, "none", "Snapshot")
vsHandler = volsync.NewVSHandler(ctx, k8sClient, logger, owner, asyncSpec, "none", "Snapshot", false)
})

AfterEach(func() {
Expand Down Expand Up @@ -465,6 +465,7 @@ var _ = Describe("VolSync_Handler", func() {
JustBeforeEach(func() {
// Run ReconcileRD
var err error
rdSpec.ProtectedPVC.Namespace = testNamespace.GetName()
returnedRD, err = vsHandler.ReconcileRD(rdSpec)
Expect(err).ToNot(HaveOccurred())
})
Expand All @@ -483,6 +484,7 @@ var _ = Describe("VolSync_Handler", func() {
Context("When the psk secret for volsync exists (will be pushed down by drpc from hub", func() {
var dummyPSKSecret *corev1.Secret
JustBeforeEach(func() {
rdSpec.ProtectedPVC.Namespace = testNamespace.GetName()
// Create a dummy volsync psk secret so the reconcile can proceed properly
dummyPSKSecret = &corev1.Secret{
ObjectMeta: metav1.ObjectMeta{
Expand Down Expand Up @@ -653,7 +655,8 @@ var _ = Describe("VolSync_Handler", func() {
var vsHandler *volsync.VSHandler

BeforeEach(func() {
vsHandler = volsync.NewVSHandler(ctx, k8sClient, logger, owner, asyncSpec, "none", "Direct")
rdSpec.ProtectedPVC.Namespace = testNamespace.GetName()
vsHandler = volsync.NewVSHandler(ctx, k8sClient, logger, owner, asyncSpec, "none", "Direct", false)
})

It("PrecreateDestPVCIfEnabled() should return CopyMethod Snapshot and App PVC name", func() {
Expand Down Expand Up @@ -703,6 +706,7 @@ var _ = Describe("VolSync_Handler", func() {
// Run ReconcileRD
var err error
var finalSyncCompl bool
rsSpec.ProtectedPVC.Namespace = testNamespace.GetName()
finalSyncCompl, returnedRS, err = vsHandler.ReconcileRS(rsSpec, false)
Expect(err).ToNot(HaveOccurred())
Expect(finalSyncCompl).To(BeFalse())
Expand All @@ -722,6 +726,7 @@ var _ = Describe("VolSync_Handler", func() {
Context("When the psk secret for volsync exists (will be pushed down by drpc from hub", func() {
var dummyPSKSecret *corev1.Secret
JustBeforeEach(func() {
rsSpec.ProtectedPVC.Namespace = testNamespace.GetName()
// Create a dummy volsync psk secret so the reconcile can proceed properly
dummyPSKSecret = &corev1.Secret{
ObjectMeta: metav1.ObjectMeta{
Expand Down Expand Up @@ -1102,6 +1107,7 @@ var _ = Describe("VolSync_Handler", func() {
rdSpec = ramendrv1alpha1.VolSyncReplicationDestinationSpec{
ProtectedPVC: ramendrv1alpha1.ProtectedPVC{
Name: pvcName,
Namespace: testNamespace.GetName(),
ProtectedByVolSync: true,
StorageClassName: &testStorageClassName,
Resources: corev1.VolumeResourceRequirements{
Expand Down Expand Up @@ -1438,6 +1444,7 @@ var _ = Describe("VolSync_Handler", func() {
rdSpec := ramendrv1alpha1.VolSyncReplicationDestinationSpec{
ProtectedPVC: ramendrv1alpha1.ProtectedPVC{
Name: pvcNamePrefix + strconv.Itoa(i),
Namespace: testNamespace.GetName(),
ProtectedByVolSync: true,
StorageClassName: &testStorageClassName,
Resources: corev1.VolumeResourceRequirements{
Expand All @@ -1461,12 +1468,13 @@ var _ = Describe("VolSync_Handler", func() {
Expect(k8sClient.Create(ctx, otherOwnerCm)).To(Succeed())
Expect(otherOwnerCm.GetName()).NotTo(BeEmpty())
otherVSHandler := volsync.NewVSHandler(ctx, k8sClient, logger, otherOwnerCm, asyncSpec,
"none", "Snapshot")
"none", "Snapshot", false)

for i := 0; i < 2; i++ {
otherOwnerRdSpec := ramendrv1alpha1.VolSyncReplicationDestinationSpec{
ProtectedPVC: ramendrv1alpha1.ProtectedPVC{
Name: pvcNamePrefixOtherOwner + strconv.Itoa(i),
Namespace: testNamespace.GetName(),
ProtectedByVolSync: true,
StorageClassName: &testStorageClassName,
Resources: corev1.VolumeResourceRequirements{
Expand Down Expand Up @@ -1632,6 +1640,7 @@ var _ = Describe("VolSync_Handler", func() {
rsSpec := ramendrv1alpha1.VolSyncReplicationSourceSpec{
ProtectedPVC: ramendrv1alpha1.ProtectedPVC{
Name: pvcNamePrefix + strconv.Itoa(i),
Namespace: testNamespace.GetName(),
ProtectedByVolSync: true,
StorageClassName: &testStorageClassName,
},
Expand All @@ -1651,12 +1660,13 @@ var _ = Describe("VolSync_Handler", func() {
Expect(k8sClient.Create(ctx, otherOwnerCm)).To(Succeed())
Expect(otherOwnerCm.GetName()).NotTo(BeEmpty())
otherVSHandler := volsync.NewVSHandler(ctx, k8sClient, logger, otherOwnerCm, asyncSpec,
"none", "Snapshot")
"none", "Snapshot", false)

for i := 0; i < 2; i++ {
otherOwnerRsSpec := ramendrv1alpha1.VolSyncReplicationSourceSpec{
ProtectedPVC: ramendrv1alpha1.ProtectedPVC{
Name: pvcNamePrefixOtherOwner + strconv.Itoa(i),
Namespace: testNamespace.GetName(),
ProtectedByVolSync: true,
StorageClassName: &testStorageClassName,
},
Expand Down Expand Up @@ -1764,7 +1774,11 @@ var _ = Describe("VolSync_Handler", func() {
Describe("Prepare PVC for final sync", func() {
Context("When the PVC does not exist", func() {
It("Should assume preparationForFinalSync is complete", func() {
pvcPreparationComplete, err := vsHandler.TakePVCOwnership("this-pvc-does-not-exist")
pvcNamespacedName := types.NamespacedName{
Name: "this-pvc-does-not-exist",
Namespace: testNamespace.GetName(),
}
pvcPreparationComplete, err := vsHandler.TakePVCOwnership(pvcNamespacedName)
Expect(err).To(HaveOccurred())
Expect(kerrors.IsNotFound(err)).To(BeTrue())
Expect(pvcPreparationComplete).To(BeFalse())
Expand All @@ -1791,7 +1805,12 @@ var _ = Describe("VolSync_Handler", func() {
var pvcPreparationErr error

JustBeforeEach(func() {
pvcPreparationComplete, pvcPreparationErr = vsHandler.TakePVCOwnership(testPVC.GetName())
pvcNamespacedName := types.NamespacedName{
Name: testPVC.GetName(),
Namespace: testPVC.GetNamespace(),
}

pvcPreparationComplete, pvcPreparationErr = vsHandler.TakePVCOwnership(pvcNamespacedName)

// In all cases at this point we should expect that the PVC has ownership taken over by our owner VRG
Eventually(func() bool {
Expand Down
4 changes: 3 additions & 1 deletion controllers/volumereplicationgroup_controller.go
Original file line number Diff line number Diff line change
Expand Up @@ -427,9 +427,11 @@ func (r *VolumeReplicationGroupReconciler) Reconcile(ctx context.Context, req ct
}

v.ramenConfig = ramenConfig
adminNamespaceVRG := vrgInAdminNamespace(v.instance, v.ramenConfig)

v.volSyncHandler = volsync.NewVSHandler(ctx, r.Client, log, v.instance,
v.instance.Spec.Async, cephFSCSIDriverNameOrDefault(v.ramenConfig),
volSyncDestinationCopyMethodOrDefault(v.ramenConfig))
volSyncDestinationCopyMethodOrDefault(v.ramenConfig), adminNamespaceVRG)

if v.instance.Status.ProtectedPVCs == nil {
v.instance.Status.ProtectedPVCs = []ramendrv1alpha1.ProtectedPVC{}
Expand Down
5 changes: 4 additions & 1 deletion controllers/vrg_kubeobjects.go
Original file line number Diff line number Diff line change
Expand Up @@ -609,7 +609,10 @@ func (v *VRGInstance) kubeObjectsRecoveryStartOrResume(
}

log1.Error(err, "Kube objects group recover error")
cleanup(request)

if ok {
cleanup(request)
}

result.Requeue = true

Expand Down
11 changes: 0 additions & 11 deletions controllers/vrg_status_pvcs.go
Original file line number Diff line number Diff line change
Expand Up @@ -50,17 +50,6 @@ func FindProtectedPvcAndIndex(
return nil, len(vrg.Status.ProtectedPVCs)
}

func (v *VRGInstance) findFirstProtectedPVCWithName(pvcName string) *ramen.ProtectedPVC {
for index := range v.instance.Status.ProtectedPVCs {
protectedPVC := &v.instance.Status.ProtectedPVCs[index]
if protectedPVC.Name == pvcName {
return protectedPVC
}
}

return nil
}

func (v *VRGInstance) vrgStatusPvcNamespacesSetIfUnset() {
vrg := v.instance

Expand Down
12 changes: 7 additions & 5 deletions controllers/vrg_volsync.go
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ import (

"github.com/go-logr/logr"
ramendrv1alpha1 "github.com/ramendr/ramen/api/v1alpha1"
"github.com/ramendr/ramen/controllers/util"
"github.com/ramendr/ramen/controllers/volsync"
corev1 "k8s.io/api/core/v1"
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
Expand All @@ -33,7 +34,7 @@ func (v *VRGInstance) restorePVsAndPVCsForVolSync() (int, error) {
if err != nil {
v.log.Info(fmt.Sprintf("Unable to ensure PVC %v -- err: %v", rdSpec, err))

protectedPVC := v.findFirstProtectedPVCWithName(rdSpec.ProtectedPVC.Name)
protectedPVC := FindProtectedPVC(v.instance, rdSpec.ProtectedPVC.Namespace, rdSpec.ProtectedPVC.Name)
if protectedPVC == nil {
protectedPVC = &ramendrv1alpha1.ProtectedPVC{}
rdSpec.ProtectedPVC.DeepCopyInto(protectedPVC)
Expand All @@ -48,7 +49,7 @@ func (v *VRGInstance) restorePVsAndPVCsForVolSync() (int, error) {

numPVsRestored++

protectedPVC := v.findFirstProtectedPVCWithName(rdSpec.ProtectedPVC.Name)
protectedPVC := FindProtectedPVC(v.instance, rdSpec.ProtectedPVC.Namespace, rdSpec.ProtectedPVC.Name)
if protectedPVC == nil {
protectedPVC = &ramendrv1alpha1.ProtectedPVC{}
rdSpec.ProtectedPVC.DeepCopyInto(protectedPVC)
Expand Down Expand Up @@ -123,7 +124,7 @@ func (v *VRGInstance) reconcilePVCAsVolSyncPrimary(pvc corev1.PersistentVolumeCl
Resources: pvc.Spec.Resources,
}

protectedPVC := v.findFirstProtectedPVCWithName(pvc.Name)
protectedPVC := FindProtectedPVC(v.instance, pvc.Namespace, pvc.Name)
if protectedPVC == nil {
protectedPVC = newProtectedPVC
v.instance.Status.ProtectedPVCs = append(v.instance.Status.ProtectedPVCs, *protectedPVC)
Expand All @@ -138,7 +139,8 @@ func (v *VRGInstance) reconcilePVCAsVolSyncPrimary(pvc corev1.PersistentVolumeCl
ProtectedPVC: *protectedPVC,
}

err := v.volSyncHandler.PreparePVC(pvc.Name, v.instance.Spec.PrepareForFinalSync,
err := v.volSyncHandler.PreparePVC(util.ProtectedPVCNamespacedName(*protectedPVC),
v.instance.Spec.PrepareForFinalSync,
v.volSyncHandler.IsCopyMethodDirect())
if err != nil {
return true
Expand Down Expand Up @@ -321,7 +323,7 @@ func (v *VRGInstance) buildDataProtectedCondition() *metav1.Condition {
}

// Check now if we have synced up at least once for this PVC
rsDataProtected, err := v.volSyncHandler.IsRSDataProtected(protectedPVC.Name)
rsDataProtected, err := v.volSyncHandler.IsRSDataProtected(protectedPVC.Name, protectedPVC.Namespace)
if err != nil || !rsDataProtected {
ready = false

Expand Down
2 changes: 2 additions & 0 deletions controllers/vrg_volsync_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -281,6 +281,7 @@ var _ = Describe("VolumeReplicationGroupVolSyncController", func() {
{
ProtectedPVC: ramendrv1alpha1.ProtectedPVC{
Name: "testingpvc-a",
Namespace: testNamespace.GetName(),
ProtectedByVolSync: true,
StorageClassName: &storageClassName,
AccessModes: testAccessModes,
Expand All @@ -291,6 +292,7 @@ var _ = Describe("VolumeReplicationGroupVolSyncController", func() {
{
ProtectedPVC: ramendrv1alpha1.ProtectedPVC{
Name: "testingpvc-b",
Namespace: testNamespace.GetName(),
ProtectedByVolSync: true,
StorageClassName: &storageClassName,
AccessModes: testAccessModes,
Expand Down
4 changes: 2 additions & 2 deletions docs/user-quick-start.md
Original file line number Diff line number Diff line change
Expand Up @@ -97,7 +97,7 @@ enough resources:
sudo dnf install https://storage.googleapis.com/minikube/releases/latest/minikube-latest.x86_64.rpm
```

Tested with version v1.33.0.
Tested with version v1.33.1.

1. Validate the installation

Expand Down Expand Up @@ -152,7 +152,7 @@ enough resources:
1. Install the `virtctl` tool.

```
curl -L -o virtctl https://github.com/kubevirt/kubevirt/releases/download/v1.2.0/virtctl-v1.2.0-linux-amd64
curl -L -o virtctl https://github.com/kubevirt/kubevirt/releases/download/v1.2.1/virtctl-v1.2.1-linux-amd64
sudo install virtctl /usr/local/bin
rm virtctl
```
Expand Down
4 changes: 4 additions & 0 deletions e2e/config.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
---
channelname: "ramen-gitops"
channelnamespace: "ramen-samples"
giturl: "https://github.com/RamenDR/ocm-ramen-samples.git"
4 changes: 2 additions & 2 deletions e2e/deployers/applicationset.go
Original file line number Diff line number Diff line change
Expand Up @@ -10,8 +10,8 @@ import (

type ApplicationSet struct{}

func (a *ApplicationSet) Init() {
}
// func (a *ApplicationSet) Init() {
// }

func (a ApplicationSet) Deploy(w workloads.Workload) error {
util.Ctx.Log.Info("enter Deploy " + w.GetName() + "/Appset")
Expand Down
Loading
Loading