Skip to content

Commit 28bd83f

Browse files
Merge pull request #19404 from deads2k/server-24-admission
don't block creation on lack of delete powers
2 parents d859add + 410094c commit 28bd83f

File tree

3 files changed

+36
-27
lines changed

3 files changed

+36
-27
lines changed

test/integration/ownerrefs_test.go

+13-9
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,7 @@ func TestOwnerRefRestriction(t *testing.T) {
3434
Name: "create-svc",
3535
},
3636
Rules: []authorizationapi.PolicyRule{
37-
authorizationapi.NewRule("create").Groups(kapi.GroupName).Resources("services").RuleOrDie(),
37+
authorizationapi.NewRule("create", "update").Groups(kapi.GroupName).Resources("services").RuleOrDie(),
3838
},
3939
})
4040
if err != nil {
@@ -63,24 +63,28 @@ func TestOwnerRefRestriction(t *testing.T) {
6363
t.Fatalf("unexpected error: %v", err)
6464
}
6565

66-
_, err = creatorClient.Core().Services("foo").Create(&kapi.Service{
66+
actual, err := creatorClient.Core().Services("foo").Create(&kapi.Service{
6767
ObjectMeta: metav1.ObjectMeta{
6868
Name: "my-service",
69-
OwnerReferences: []metav1.OwnerReference{{
70-
APIVersion: "foo",
71-
Kind: "bar",
72-
Name: "baz",
73-
UID: types.UID("baq"),
74-
}},
7569
},
7670
Spec: kapi.ServiceSpec{
7771
Ports: []kapi.ServicePort{
7872
{Port: 80},
7973
},
8074
},
8175
})
76+
if err != nil {
77+
t.Fatal(err)
78+
}
79+
actual.OwnerReferences = []metav1.OwnerReference{{
80+
APIVersion: "foo",
81+
Kind: "bar",
82+
Name: "baz",
83+
UID: types.UID("baq"),
84+
}}
85+
actual, err = creatorClient.Core().Services("foo").Update(actual)
8286
if err == nil {
83-
t.Fatalf("missing err")
87+
t.Fatalf("missing error")
8488
}
8589
if !kapierrors.IsForbidden(err) || !strings.Contains(err.Error(), "cannot set an ownerRef on a resource you can't delete") {
8690
t.Fatalf("expecting cannot set an ownerRef on a resource you can't delete, got %v", err)

vendor/k8s.io/kubernetes/plugin/pkg/admission/gc/gc_admission.go

+21-16
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

vendor/k8s.io/kubernetes/plugin/pkg/admission/gc/gc_admission_test.go

+2-2
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)