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

Bug fixes for timeout #1654

Draft
wants to merge 4 commits into
base: main
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
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 @@ -33,7 +33,7 @@ endif
BUNDLE_METADATA_OPTS ?= $(BUNDLE_CHANNELS) $(BUNDLE_DEFAULT_CHANNEL)

IMAGE_REGISTRY ?= quay.io
IMAGE_REPOSITORY ?= ramendr
IMAGE_REPOSITORY ?= anarasag
IMAGE_NAME ?= ramen
IMAGE_TAG ?= latest
PLATFORM ?= k8s
Expand Down
7 changes: 7 additions & 0 deletions e2e/config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -7,3 +7,10 @@ pvcspecs:
accessmodes: ReadWriteMany
- storageclassname: rook-ceph-block
accessmodes: ReadWriteOnce
Clusters:
hub:
kubeconfigpath: /home/asn/.config/drenv/rdr/kubeconfigs/hub
c1:
kubeconfigpath: /home/asn/.config/drenv/rdr/kubeconfigs/dr1
c2:
kubeconfigpath: /home/asn/.config/drenv/rdr/kubeconfigs/dr2
13 changes: 13 additions & 0 deletions e2e/dractions/actionsdiscoveredapps.go
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,11 @@ func EnableProtectionDiscoveredApps(w workloads.Workload, d deployers.Deployer)
return err
}

// create recipe
if err := createRecipe(name, namespace); err != nil {
return err
}

// create drpc
drpolicy, err := util.GetDRPolicy(util.Ctx.Hub.CtrlClient, drPolicyName)
if err != nil {
Expand All @@ -44,6 +49,10 @@ func EnableProtectionDiscoveredApps(w workloads.Workload, d deployers.Deployer)

drpc := generateDRPCDiscoveredApps(
name, namespace, clusterName, drPolicyName, placementName, appname, namespaceInDrCluster)
drpc.Spec.KubeObjectProtection.RecipeRef = &ramen.RecipeRef{
Namespace: namespace,
Name: name,
}
if err = createDRPC(util.Ctx.Hub.CtrlClient, drpc); err != nil {
return err
}
Expand Down Expand Up @@ -75,6 +84,10 @@ func DisableProtectionDiscoveredApps(w workloads.Workload, d deployers.Deployer)
return err
}

if err := deleteRecipe(client, name, namespace); err != nil {
return err
}

// delete placement
if err := deployers.DeletePlacement(placementName, namespace); err != nil {
return err
Expand Down
129 changes: 129 additions & 0 deletions e2e/dractions/crud.go
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ import (
ramen "github.com/ramendr/ramen/api/v1alpha1"
"github.com/ramendr/ramen/e2e/deployers"
"github.com/ramendr/ramen/e2e/util"
recipe "github.com/ramendr/recipe/api/v1alpha1"
v1 "k8s.io/api/core/v1"
"k8s.io/apimachinery/pkg/api/errors"
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
Expand Down Expand Up @@ -182,3 +183,131 @@ func generateDRPCDiscoveredApps(name, namespace, clusterName, drPolicyName, plac

return drpc
}

func createRecipe(name, namespace string) error {
err := util.Ctx.C1.CtrlClient.Create(context.Background(), getRecipe(name, namespace))
if err != nil {
if !errors.IsAlreadyExists(err) {
return err
}

util.Ctx.Log.Info("recipe " + name + " already exists" + " in the cluster " + "C1")
}

err = util.Ctx.C2.CtrlClient.Create(context.Background(), getRecipe(name, namespace))
if err != nil {
if !errors.IsAlreadyExists(err) {
return err
}

util.Ctx.Log.Info("recipe " + name + " already exists" + " in the cluster " + "C2")
}

return nil
}

func getRecipe(name, namespace string) *recipe.Recipe {
return &recipe.Recipe{
TypeMeta: metav1.TypeMeta{
Kind: "Recipe",
APIVersion: "ramendr.openshift.io/v1alpha1",
},
ObjectMeta: metav1.ObjectMeta{
Name: name,
Namespace: namespace,
},
Spec: recipe.RecipeSpec{
AppType: "busybox",
Groups: []*recipe.Group{
{
Name: "rg1",
Type: "resource",
IncludedNamespaces: []string{
namespace,
},
},
{
Name: "rg2",
Type: "resource",
IncludedNamespaces: []string{
namespace,
},
// select resource for pod
},
},
Hooks: []*recipe.Hook{
{
Name: "backup",
Type: "check",
Namespace: name,
NameSelector: "busybox",
SelectResource: "deployment",
Timeout: 300,
Chks: []*recipe.Check{
{
Name: "check-replicas",
Condition: "{$.spec.replicas} == {$.status.readyReplicas}",
},
},
},
{
Name: "restore",
Type: "check",
Namespace: name,
NameSelector: "busybox-recipe",
SelectResource: "deployment",
Timeout: 300,
Chks: []*recipe.Check{
{
Name: "check-replicas",
Condition: "{$.spec.replicas} == {$.status.readyReplicas}",
},
},
},
},
Workflows: []*recipe.Workflow{
{
Name: "backup",
Sequence: []map[string]string{
{
"group": "rg2",
},
{
"hook": "backup/check-replicas",
},
{
"group": "rg1",
},
},
},
{
Name: "restore",
Sequence: []map[string]string{
{
"group": "rg1",
},
{
"hook": "restore/check-replicas",
},
},
},
},
},
}
}

func deleteRecipe(client client.Client, name, namespace string) error {
r := &recipe.Recipe{}
key := types.NamespacedName{Namespace: namespace, Name: name}

err := client.Get(context.Background(), key, r)
if err != nil {
if !errors.IsNotFound(err) {
return err
}

return nil
}

return client.Delete(context.Background(), r)
}
10 changes: 5 additions & 5 deletions e2e/exhaustive_suite_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -70,11 +70,11 @@ func Exhaustive(t *testing.T) {
t.Fatalf("failed to ensure channel: %v", err)
}

t.Cleanup(func() {
if err := util.EnsureChannelDeleted(); err != nil {
t.Fatalf("failed to ensure channel deleted: %v", err)
}
})
// t.Cleanup(func() {
// if err := util.EnsureChannelDeleted(); err != nil {
// t.Fatalf("failed to ensure channel deleted: %v", err)
// }
// })

generateWorkloads(Workloads)

Expand Down
53 changes: 28 additions & 25 deletions e2e/go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -5,38 +5,41 @@ go 1.22.5
toolchain go1.22.7

require (
github.com/go-logr/logr v1.4.1
github.com/go-logr/logr v1.4.2
github.com/ramendr/ramen/api v0.0.0-00010101000000-000000000000
github.com/ramendr/recipe v0.0.0-20241009174526-5cecfd571447
github.com/spf13/viper v1.18.2
go.uber.org/zap v1.27.0
k8s.io/api v0.29.3
k8s.io/apimachinery v0.29.3
k8s.io/api v0.31.2
k8s.io/apimachinery v0.31.2
k8s.io/client-go v12.0.0+incompatible
k8s.io/kubectl v0.29.3
open-cluster-management.io/api v0.13.0
open-cluster-management.io/multicloud-operators-channel v0.10.1-0.20230316173315-10f48e51f3aa
open-cluster-management.io/multicloud-operators-subscription v0.13.0
sigs.k8s.io/controller-runtime v0.17.3
sigs.k8s.io/controller-runtime v0.19.0
sigs.k8s.io/yaml v1.4.0
)

require (
github.com/davecgh/go-spew v1.1.2-0.20180830191138-d8f796af33cc // indirect
github.com/emicklei/go-restful/v3 v3.11.0 // indirect
github.com/evanphx/json-patch/v5 v5.8.0 // indirect
github.com/emicklei/go-restful/v3 v3.12.1 // indirect
github.com/evanphx/json-patch/v5 v5.9.0 // indirect
github.com/fsnotify/fsnotify v1.7.0 // indirect
github.com/fxamacker/cbor/v2 v2.7.0 // indirect
github.com/ghodss/yaml v1.0.1-0.20190212211648-25d852aebe32 // indirect
github.com/go-logr/zapr v1.3.0 // indirect
github.com/go-openapi/jsonpointer v0.19.6 // indirect
github.com/go-openapi/jsonreference v0.20.2 // indirect
github.com/go-openapi/swag v0.22.3 // indirect
github.com/go-openapi/jsonpointer v0.21.0 // indirect
github.com/go-openapi/jsonreference v0.21.0 // indirect
github.com/go-openapi/swag v0.23.0 // indirect
github.com/gogo/protobuf v1.3.2 // indirect
github.com/golang/protobuf v1.5.4 // indirect
github.com/google/gnostic-models v0.6.8 // indirect
github.com/google/go-cmp v0.6.0 // indirect
github.com/google/gofuzz v1.2.0 // indirect
github.com/google/uuid v1.5.0 // indirect
github.com/google/uuid v1.6.0 // indirect
github.com/hashicorp/hcl v1.0.0 // indirect
github.com/imdario/mergo v0.3.13 // indirect
github.com/imdario/mergo v0.3.16 // indirect
github.com/josharian/intern v1.0.0 // indirect
github.com/json-iterator/go v1.1.12 // indirect
github.com/magiconair/properties v1.8.7 // indirect
Expand All @@ -54,28 +57,28 @@ require (
github.com/spf13/cast v1.6.0 // indirect
github.com/spf13/pflag v1.0.5 // indirect
github.com/subosito/gotenv v1.6.0 // indirect
github.com/x448/float16 v0.8.4 // indirect
go.uber.org/multierr v1.11.0 // indirect
golang.org/x/exp v0.0.0-20230905200255-921286631fa9 // indirect
golang.org/x/net v0.20.0 // indirect
golang.org/x/oauth2 v0.15.0 // indirect
golang.org/x/sys v0.16.0 // indirect
golang.org/x/term v0.16.0 // indirect
golang.org/x/text v0.14.0 // indirect
golang.org/x/time v0.5.0 // indirect
google.golang.org/appengine v1.6.8 // indirect
google.golang.org/protobuf v1.33.0 // indirect
golang.org/x/exp v0.0.0-20240909161429-701f63a606c0 // indirect
golang.org/x/net v0.29.0 // indirect
golang.org/x/oauth2 v0.23.0 // indirect
golang.org/x/sys v0.25.0 // indirect
golang.org/x/term v0.24.0 // indirect
golang.org/x/text v0.18.0 // indirect
golang.org/x/time v0.6.0 // indirect
google.golang.org/protobuf v1.34.2 // indirect
gopkg.in/inf.v0 v0.9.1 // indirect
gopkg.in/ini.v1 v1.67.0 // indirect
gopkg.in/yaml.v2 v2.4.0 // indirect
gopkg.in/yaml.v3 v3.0.1 // indirect
k8s.io/component-base v0.29.3 // indirect
k8s.io/klog/v2 v2.110.1 // indirect
k8s.io/kube-openapi v0.0.0-20231010175941-2dd684a91f00 // indirect
k8s.io/utils v0.0.0-20230726121419-3b25d923346b // indirect
k8s.io/component-base v0.31.0 // indirect
k8s.io/klog/v2 v2.130.1 // indirect
k8s.io/kube-openapi v0.0.0-20240903163716-9e1beecbcb38 // indirect
k8s.io/utils v0.0.0-20240921022957-49e7df575cb6 // indirect
sigs.k8s.io/json v0.0.0-20221116044647-bc3834ca7abd // indirect
sigs.k8s.io/structured-merge-diff/v4 v4.4.1 // indirect
)

replace github.com/ramendr/ramen/api => ../api

replace k8s.io/client-go v12.0.0+incompatible => k8s.io/client-go v0.29.0
replace k8s.io/client-go v12.0.0+incompatible => k8s.io/client-go v0.31.2
Loading