Skip to content

Commit 234d5c8

Browse files
authored
Merge pull request #474 from red-hat-storage/sync_us--main
Syncing latest changes from upstream main for ramen
2 parents 4e0e00f + a53f036 commit 234d5c8

File tree

5 files changed

+105
-16
lines changed

5 files changed

+105
-16
lines changed

e2e/deployers/appset.go

+10-4
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@ import (
77
"github.com/ramendr/ramen/e2e/config"
88
"github.com/ramendr/ramen/e2e/types"
99
"github.com/ramendr/ramen/e2e/util"
10+
k8serrors "k8s.io/apimachinery/pkg/api/errors"
1011
)
1112

1213
type ApplicationSet struct{}
@@ -58,11 +59,16 @@ func (a ApplicationSet) Undeploy(ctx types.Context) error {
5859

5960
clusterName, err := util.GetCurrentCluster(util.Ctx.Hub, managementNamespace, name)
6061
if err != nil {
61-
return err
62-
}
62+
if !k8serrors.IsNotFound(err) {
63+
return err
64+
}
6365

64-
log.Infof("Undeploying applicationset app \"%s/%s\" in cluster %q",
65-
ctx.AppNamespace(), ctx.Workload().GetAppName(), clusterName)
66+
log.Debugf("Could not retrieve the cluster name: %s", err)
67+
log.Infof("Undeploying applicationset app \"%s/%s\"", ctx.AppNamespace(), ctx.Workload().GetAppName())
68+
} else {
69+
log.Infof("Undeploying applicationset app \"%s/%s\" in cluster %q",
70+
ctx.AppNamespace(), ctx.Workload().GetAppName(), clusterName)
71+
}
6672

6773
err = DeleteApplicationSet(ctx, a)
6874
if err != nil {

e2e/deployers/subscr.go

+10-4
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@ import (
77
"github.com/ramendr/ramen/e2e/config"
88
"github.com/ramendr/ramen/e2e/types"
99
"github.com/ramendr/ramen/e2e/util"
10+
k8serrors "k8s.io/apimachinery/pkg/api/errors"
1011
subscriptionv1 "open-cluster-management.io/multicloud-operators-subscription/pkg/apis/apps/v1"
1112
)
1213

@@ -80,12 +81,17 @@ func (s Subscription) Undeploy(ctx types.Context) error {
8081

8182
clusterName, err := util.GetCurrentCluster(util.Ctx.Hub, managementNamespace, name)
8283
if err != nil {
83-
return err
84+
if !k8serrors.IsNotFound(err) {
85+
return err
86+
}
87+
88+
log.Debugf("Could not retrieve the cluster name: %s", err)
89+
log.Infof("Undeploying subscription app \"%s/%s\"", ctx.AppNamespace(), ctx.Workload().GetAppName())
90+
} else {
91+
log.Infof("Undeploying subscription app \"%s/%s\" in cluster %q",
92+
ctx.AppNamespace(), ctx.Workload().GetAppName(), clusterName)
8493
}
8594

86-
log.Infof("Undeploying subscription app \"%s/%s\" in cluster %q",
87-
ctx.AppNamespace(), ctx.Workload().GetAppName(), clusterName)
88-
8995
err = DeleteSubscription(ctx, s)
9096
if err != nil {
9197
return err

e2e/dractions/actions.go

+10-4
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@ import (
88
"github.com/ramendr/ramen/e2e/config"
99
"github.com/ramendr/ramen/e2e/types"
1010
"github.com/ramendr/ramen/e2e/util"
11+
k8serrors "k8s.io/apimachinery/pkg/api/errors"
1112
"k8s.io/client-go/util/retry"
1213
)
1314

@@ -108,11 +109,16 @@ func DisableProtection(ctx types.Context) error {
108109

109110
clusterName, err := util.GetCurrentCluster(util.Ctx.Hub, managementNamespace, placementName)
110111
if err != nil {
111-
return err
112-
}
112+
if !k8serrors.IsNotFound(err) {
113+
return err
114+
}
113115

114-
log.Infof("Unprotecting workload \"%s/%s\" in cluster %q",
115-
appNamespace, ctx.Workload().GetAppName(), clusterName)
116+
log.Debugf("Could not retrieve the cluster name: %s", err)
117+
log.Infof("Unprotecting workload \"%s/%s\"", appNamespace, ctx.Workload().GetAppName())
118+
} else {
119+
log.Infof("Unprotecting workload \"%s/%s\" in cluster %q",
120+
appNamespace, ctx.Workload().GetAppName(), clusterName)
121+
}
116122

117123
drpcName := name
118124

e2e/dractions/disapp.go

+10-4
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@ import (
99
"github.com/ramendr/ramen/e2e/deployers"
1010
"github.com/ramendr/ramen/e2e/types"
1111
"github.com/ramendr/ramen/e2e/util"
12+
k8serrors "k8s.io/apimachinery/pkg/api/errors"
1213
)
1314

1415
func EnableProtectionDiscoveredApps(ctx types.Context) error {
@@ -73,11 +74,16 @@ func DisableProtectionDiscoveredApps(ctx types.Context) error {
7374

7475
clusterName, err := util.GetCurrentCluster(util.Ctx.Hub, managementNamespace, placementName)
7576
if err != nil {
76-
return err
77-
}
77+
if !k8serrors.IsNotFound(err) {
78+
return err
79+
}
7880

79-
log.Infof("Unprotecting workload \"%s/%s\" in cluster %q",
80-
appNamespace, ctx.Workload().GetAppName(), clusterName)
81+
log.Debugf("Could not retrieve the cluster name: %s", err)
82+
log.Infof("Unprotecting workload \"%s/%s\"", appNamespace, ctx.Workload().GetAppName())
83+
} else {
84+
log.Infof("Unprotecting workload \"%s/%s\" in cluster %q",
85+
appNamespace, ctx.Workload().GetAppName(), clusterName)
86+
}
8187

8288
if err := deleteDRPC(ctx, util.Ctx.Hub, managementNamespace, drpcName); err != nil {
8389
return err

internal/controller/hooks/json_util_test.go

+65
Original file line numberDiff line numberDiff line change
@@ -113,6 +113,49 @@ var testCasesData = []testCases{
113113
result: false,
114114
jsonText: jsonStatefulset,
115115
},
116+
/* The json expression that can be provided as a condition in the check hook spec follows the format
117+
118+
<expression1> op <expression2>
119+
With some of the conditions below:
120+
121+
1. Both the expressions should individually comply to be a valid json expression.
122+
2. An expression should be enclosed with curly braces {}.
123+
3. An expression could either be a json expression that can be evaluated from the pod/deployment/statefulset json
124+
content or a literal which can be either string or number.
125+
Some improvements needs to be done which are added as sub-issues linked to this one.
126+
127+
Adding the commented TCs which are to pass when the improvements are done.
128+
*/
129+
// {
130+
// jsonPathExprs: "{$.status.conditions[0].status} == {True}",
131+
// result: true,
132+
// jsonText: jsonStatefulset,
133+
// },
134+
// {
135+
// jsonPathExprs: "{$.spec.replicas} == {1}",
136+
// result: true,
137+
// jsonText: jsonPod,
138+
// },
139+
// {
140+
// jsonPathExprs: "{$.status.conditions[0].status} == {\"True\"}",
141+
// result: true,
142+
// jsonText: jsonStatefulset,
143+
// },
144+
// {
145+
// jsonPathExprs: "{$.status.conditions[?(@type.==\"Progressing\")].status} == {True}",
146+
// result: true,
147+
// jsonText: jsonPod,
148+
// },
149+
// {
150+
// jsonPathExprs: "{$.spec.replicas} == {1} || $.status.conditions[0].status == {True}",
151+
// result: true,
152+
// jsonText: jsonPod,
153+
// },
154+
// {
155+
// jsonPathExprs: "{$.spec.replicas} == {1} && $.status.conditions[0].status == {True}",
156+
// result: true,
157+
// jsonText: jsonPod,
158+
// },
116159
}
117160

118161
var testCasesObjectData = []testCasesObject{
@@ -200,6 +243,28 @@ func Test_isValidJsonPathExpression(t *testing.T) {
200243
args args
201244
want bool
202245
}{
246+
/* Same comments as above */
247+
// {
248+
// name: "String expression",
249+
// args: args{
250+
// expr: "{True}",
251+
// },
252+
// want: true,
253+
// },
254+
// {
255+
// name: "String expression 1",
256+
// args: args{
257+
// expr: "{\"Ready\"}",
258+
// },
259+
// want: true,
260+
// },
261+
// {
262+
// name: "Number expression",
263+
// args: args{
264+
// expr: "{10}",
265+
// },
266+
// want: true,
267+
// },
203268
{
204269
name: "Simple expression",
205270
args: args{

0 commit comments

Comments
 (0)