Skip to content

Commit a274011

Browse files
committed
OpenShift changes after the rebase to 1.7.6
1 parent 98c2013 commit a274011

File tree

7 files changed

+60
-4
lines changed

7 files changed

+60
-4
lines changed

pkg/assets/apiserver/asset_apiserver.go

+1-1
Original file line numberDiff line numberDiff line change
@@ -155,7 +155,7 @@ func buildHandlerChainForAssets(consoleRedirectPath string) func(startingHandler
155155
handler = genericapifilters.WithAudit(handler, c.RequestContextMapper, c.AuditBackend, c.AuditPolicyChecker, c.LongRunningFunc)
156156
}
157157
handler = genericfilters.WithCORS(handler, c.CorsAllowedOriginList, nil, nil, nil, "true")
158-
handler = genericfilters.WithTimeoutForNonLongRunningRequests(handler, c.RequestContextMapper, c.LongRunningFunc)
158+
handler = genericfilters.WithTimeoutForNonLongRunningRequests(handler, c.RequestContextMapper, c.LongRunningFunc, c.RequestTimeout)
159159
handler = genericapifilters.WithRequestInfo(handler, genericapiserver.NewRequestInfoResolver(c), c.RequestContextMapper)
160160
handler = apirequest.WithRequestContext(handler, c.RequestContextMapper)
161161
handler = genericfilters.WithPanicRecovery(handler)

pkg/cmd/server/bootstrappolicy/policy.go

+1
Original file line numberDiff line numberDiff line change
@@ -693,6 +693,7 @@ func GetOpenshiftBootstrapClusterRoles() []rbac.ClusterRole {
693693
rbac.NewRule("get", "create", "delete").Groups(kapiGroup).Resources("pods").RuleOrDie(),
694694
// TODO: restrict to pods scheduled on the bound node once supported
695695
rbac.NewRule("update").Groups(kapiGroup).Resources("pods/status").RuleOrDie(),
696+
rbac.NewRule("create").Groups(kapiGroup).Resources("pods/eviction").RuleOrDie(),
696697

697698
// TODO: restrict to secrets and configmaps used by pods scheduled on bound node once supported
698699
// Needed for imagepullsecrets, rbd/ceph and secret volumes, and secrets in envs

pkg/cmd/server/kubernetes/master/master_config_test.go

+1
Original file line numberDiff line numberDiff line change
@@ -75,6 +75,7 @@ func TestAPIServerDefaults(t *testing.T) {
7575
MaxRequestsInFlight: 400,
7676
MaxMutatingRequestsInFlight: 200,
7777
MinRequestTimeout: 1800,
78+
RequestTimeout: time.Duration(60) * time.Second,
7879
},
7980
Admission: &apiserveroptions.AdmissionOptions{
8081
PluginNames: []string{"AlwaysAdmit"},

pkg/oauth/apiserver/oauth_apiserver.go

+1-1
Original file line numberDiff line numberDiff line change
@@ -200,7 +200,7 @@ func (c *OAuthServerConfig) buildHandlerChainForOAuth(startingHandler http.Handl
200200

201201
handler = genericfilters.WithMaxInFlightLimit(handler, genericConfig.MaxRequestsInFlight, genericConfig.MaxMutatingRequestsInFlight, genericConfig.RequestContextMapper, genericConfig.LongRunningFunc)
202202
handler = genericfilters.WithCORS(handler, genericConfig.CorsAllowedOriginList, nil, nil, nil, "true")
203-
handler = genericfilters.WithTimeoutForNonLongRunningRequests(handler, genericConfig.RequestContextMapper, genericConfig.LongRunningFunc)
203+
handler = genericfilters.WithTimeoutForNonLongRunningRequests(handler, genericConfig.RequestContextMapper, genericConfig.LongRunningFunc, genericConfig.RequestTimeout)
204204
handler = genericapifilters.WithRequestInfo(handler, genericapiserver.NewRequestInfoResolver(genericConfig), genericConfig.RequestContextMapper)
205205
handler = apirequest.WithRequestContext(handler, genericConfig.RequestContextMapper)
206206
handler = genericfilters.WithPanicRecovery(handler)

test/integration/node_authorizer_test.go

+43-2
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@ import (
1414
"k8s.io/apimachinery/pkg/util/wait"
1515
"k8s.io/client-go/rest"
1616
"k8s.io/kubernetes/pkg/api"
17+
"k8s.io/kubernetes/pkg/apis/policy"
1718
clientset "k8s.io/kubernetes/pkg/client/clientset_generated/internalclientset"
1819

1920
"github.com/openshift/origin/pkg/cmd/server/admin"
@@ -22,6 +23,8 @@ import (
2223
testserver "github.com/openshift/origin/test/util/server"
2324
)
2425

26+
// If this test fails make sure to update it with contents from
27+
// vendor/k8s.io/kubernetes/test/integration/auth/node_test.go#TestNodeAuthorizer
2528
func TestNodeAuthorizer(t *testing.T) {
2629
masterConfig, err := testserver.DefaultMasterOptions()
2730
if err != nil {
@@ -188,6 +191,30 @@ func TestNodeAuthorizer(t *testing.T) {
188191
deleteNode2 := func(client clientset.Interface) error {
189192
return client.Core().Nodes().Delete("node2", nil)
190193
}
194+
createNode2NormalPodEviction := func(client clientset.Interface) error {
195+
return client.Policy().Evictions("ns").Evict(&policy.Eviction{
196+
TypeMeta: metav1.TypeMeta{
197+
APIVersion: "policy/v1beta1",
198+
Kind: "Eviction",
199+
},
200+
ObjectMeta: metav1.ObjectMeta{
201+
Name: "node2normalpod",
202+
Namespace: "ns",
203+
},
204+
})
205+
}
206+
createNode2MirrorPodEviction := func(client clientset.Interface) error {
207+
return client.Policy().Evictions("ns").Evict(&policy.Eviction{
208+
TypeMeta: metav1.TypeMeta{
209+
APIVersion: "policy/v1beta1",
210+
Kind: "Eviction",
211+
},
212+
ObjectMeta: metav1.ObjectMeta{
213+
Name: "node2mirrorpod",
214+
Namespace: "ns",
215+
},
216+
})
217+
}
191218

192219
// nodeanonClient := clientsetForToken(tokenNodeUnknown, clientConfig)
193220
// node1Client := clientsetForToken(tokenNode1, clientConfig)
@@ -201,7 +228,9 @@ func TestNodeAuthorizer(t *testing.T) {
201228
expectForbidden(t, getPV(nodeanonClient))
202229
expectForbidden(t, createNode2NormalPod(nodeanonClient))
203230
expectForbidden(t, createNode2MirrorPod(nodeanonClient))
231+
expectForbidden(t, deleteNode2NormalPod(nodeanonClient))
204232
expectForbidden(t, deleteNode2MirrorPod(nodeanonClient))
233+
expectForbidden(t, createNode2MirrorPodEviction(nodeanonClient))
205234
expectForbidden(t, createNode2(nodeanonClient))
206235
expectForbidden(t, updateNode2Status(nodeanonClient))
207236
expectForbidden(t, deleteNode2(nodeanonClient))
@@ -213,7 +242,8 @@ func TestNodeAuthorizer(t *testing.T) {
213242
expectForbidden(t, getPV(node1Client))
214243
expectForbidden(t, createNode2NormalPod(nodeanonClient))
215244
expectForbidden(t, createNode2MirrorPod(node1Client))
216-
expectForbidden(t, deleteNode2MirrorPod(node1Client))
245+
expectNotFound(t, deleteNode2MirrorPod(node1Client))
246+
expectNotFound(t, createNode2MirrorPodEviction(node1Client))
217247
expectForbidden(t, createNode2(node1Client))
218248
expectForbidden(t, updateNode2Status(node1Client))
219249
expectForbidden(t, deleteNode2(node1Client))
@@ -228,6 +258,8 @@ func TestNodeAuthorizer(t *testing.T) {
228258
// mirror pod and self node lifecycle is allowed
229259
expectAllowed(t, createNode2MirrorPod(node2Client))
230260
expectAllowed(t, deleteNode2MirrorPod(node2Client))
261+
expectAllowed(t, createNode2MirrorPod(node2Client))
262+
expectAllowed(t, createNode2MirrorPodEviction(node2Client))
231263
expectAllowed(t, createNode2(node2Client))
232264
expectAllowed(t, updateNode2Status(node2Client))
233265
expectAllowed(t, deleteNode2(node2Client))
@@ -244,8 +276,10 @@ func TestNodeAuthorizer(t *testing.T) {
244276
expectForbidden(t, createNode2NormalPod(nodeanonClient))
245277
expectForbidden(t, updateNode2NormalPodStatus(nodeanonClient))
246278
expectForbidden(t, deleteNode2NormalPod(nodeanonClient))
279+
expectForbidden(t, createNode2NormalPodEviction(nodeanonClient))
247280
expectForbidden(t, createNode2MirrorPod(nodeanonClient))
248281
expectForbidden(t, deleteNode2MirrorPod(nodeanonClient))
282+
expectForbidden(t, createNode2MirrorPodEviction(nodeanonClient))
249283

250284
expectForbidden(t, getSecret(node1Client))
251285
expectForbidden(t, getPVSecret(node1Client))
@@ -255,8 +289,10 @@ func TestNodeAuthorizer(t *testing.T) {
255289
expectForbidden(t, createNode2NormalPod(node1Client))
256290
expectForbidden(t, updateNode2NormalPodStatus(node1Client))
257291
expectForbidden(t, deleteNode2NormalPod(node1Client))
292+
expectForbidden(t, createNode2NormalPodEviction(node1Client))
258293
expectForbidden(t, createNode2MirrorPod(node1Client))
259-
expectForbidden(t, deleteNode2MirrorPod(node1Client))
294+
expectNotFound(t, deleteNode2MirrorPod(node1Client))
295+
expectNotFound(t, createNode2MirrorPodEviction(node1Client))
260296

261297
// node2 can get referenced objects now
262298
expectAllowed(t, getSecret(node2Client))
@@ -269,6 +305,11 @@ func TestNodeAuthorizer(t *testing.T) {
269305
expectAllowed(t, deleteNode2NormalPod(node2Client))
270306
expectAllowed(t, createNode2MirrorPod(node2Client))
271307
expectAllowed(t, deleteNode2MirrorPod(node2Client))
308+
// recreate as an admin to test eviction
309+
expectAllowed(t, createNode2NormalPod(superuserClient))
310+
expectAllowed(t, createNode2MirrorPod(superuserClient))
311+
expectAllowed(t, createNode2NormalPodEviction(node2Client))
312+
expectAllowed(t, createNode2MirrorPodEviction(node2Client))
272313
}
273314

274315
func makeNodeClientset(t *testing.T, signer *admin.SignerCertOptions, certDir string, username string, anonymousConfig *rest.Config) clientset.Interface {

test/testdata/bootstrappolicy/bootstrap_cluster_roles.yaml

+6
Original file line numberDiff line numberDiff line change
@@ -2261,6 +2261,12 @@ items:
22612261
- pods/status
22622262
verbs:
22632263
- update
2264+
- apiGroups:
2265+
- ""
2266+
resources:
2267+
- pods/eviction
2268+
verbs:
2269+
- create
22642270
- apiGroups:
22652271
- ""
22662272
resources:

test/testdata/bootstrappolicy/bootstrap_policy_file.yaml

+7
Original file line numberDiff line numberDiff line change
@@ -2473,6 +2473,13 @@ items:
24732473
- pods/status
24742474
verbs:
24752475
- update
2476+
- apiGroups:
2477+
- ""
2478+
attributeRestrictions: null
2479+
resources:
2480+
- pods/eviction
2481+
verbs:
2482+
- create
24762483
- apiGroups:
24772484
- ""
24782485
attributeRestrictions: null

0 commit comments

Comments
 (0)