Skip to content

Commit 9fea7c3

Browse files
Merge pull request #17580 from adelton/issue-17359
Automatic merge from submit-queue (batch tested with PRs 17429, 17654, 17580). Address oc adm conflict. Resolve: Error from server (Conflict): Operation cannot be fulfilled on securitycontextconstraints.security.openshift.io \"anyuid\": the object has been modified; please apply your changes to the latest version and try again Fixes #17359.
2 parents d49199f + d31a4ea commit 9fea7c3

File tree

1 file changed

+13
-1
lines changed

1 file changed

+13
-1
lines changed

test/extended/security/supplemental_groups.go

+13-1
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,10 @@ import (
99
o "github.com/onsi/gomega"
1010

1111
kapiv1 "k8s.io/api/core/v1"
12+
"k8s.io/apimachinery/pkg/api/errors"
1213
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
14+
"k8s.io/apimachinery/pkg/runtime/schema"
15+
"k8s.io/client-go/util/retry"
1316
e2e "k8s.io/kubernetes/test/e2e/framework"
1417

1518
exutil "github.com/openshift/origin/test/extended/util"
@@ -33,7 +36,16 @@ var _ = g.Describe("[security] supplemental groups", func() {
3336
fsGroup := int64(1111)
3437
supGroup := int64(2222)
3538

36-
_, err := oc.AsAdmin().Run("adm").Args("policy", "add-scc-to-user", "anyuid", oc.Username()).Output()
39+
err := retry.RetryOnConflict(retry.DefaultRetry, func() error {
40+
_, err := oc.AsAdmin().Run("adm").Args("policy", "add-scc-to-user", "anyuid", oc.Username()).Output()
41+
if exitErr, ok := err.(*exutil.ExitError); ok {
42+
if strings.HasPrefix(exitErr.StdErr, "Error from server (Conflict):") {
43+
// the retry.RetryOnConflict expects "conflict" error, let's provide it with one
44+
return errors.NewConflict(schema.GroupResource{}, "", err)
45+
}
46+
}
47+
return err
48+
})
3749
o.Expect(err).NotTo(o.HaveOccurred())
3850

3951
// create a pod that is requesting supplemental groups. We request specific sup groups

0 commit comments

Comments
 (0)