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

Ensuring EndpointSlice controller does not start when feature gate or API are disabled #85301

Closed
wants to merge 63 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
63 commits
Select commit Hold shift + click to select a range
765bb27
pkg/util/iptables: add Dan Winship to OWNERS
dcbw Oct 4, 2019
c396492
Drop job from scale description
soltysh Oct 23, 2019
05bb51d
Move json,yaml,jsonpath printers to correct locations
seans3 Nov 4, 2019
f0e6d8e
tests: Fixes tests for Windows (containerd, RunAsUserName)
claudiubelu Jul 5, 2019
e07402f
fix a panic when ipam tries to allocate an out of range pre-existing …
khenidak Nov 4, 2019
2de6b2e
unit tests
khenidak Nov 4, 2019
fd7eaff
kubetestgen implementation
Jefftree Oct 15, 2019
9f40e19
Add comments to explain golang.org replace directives
liggitt Nov 13, 2019
fb046f7
Continue removing file in ManagerImpl#removeContents
yutedz Nov 13, 2019
5038f80
Strip nullable for Server-side apply
Nov 13, 2019
8f32ee1
Add TODOs for removing invalid e2e dependencies
Nov 13, 2019
56fe87d
tests: Adds large requests tests
claudiubelu Oct 5, 2019
82b9cf1
pkg/client: fix staticcheck warning
hwdef Nov 2, 2019
b3377e6
pkg/kubeapiserver: fix staticcheck warning
hwdef Nov 12, 2019
2a021d0
Updating kube-proxy to support new EndpointSlice address types
robscott Nov 13, 2019
2bdd379
Correct the checking of robinIndex
yutedz Nov 14, 2019
920dbdd
refactor apparmor utils in e2e
danielqsj Oct 28, 2019
3b77bc8
Enabled discrimination on target namespace
MikeSpreitzer Nov 7, 2019
a912bd8
Identify cluster scope by a boolean field rather than a special names…
MikeSpreitzer Nov 13, 2019
bb69b93
applied gofmt
MikeSpreitzer Nov 13, 2019
1c60949
updated generated files
MikeSpreitzer Nov 13, 2019
793b5a7
Regenerated pb.go for flowcontrol/v1alpha1
MikeSpreitzer Nov 14, 2019
44f0b26
Specify a port range to ILB firewall rule create.
prameshj Nov 14, 2019
7302a98
add table convertor to componentstatus
zhouya0 Nov 13, 2019
2ecdc5e
Change globalMapPath to bind mount from symlink
mkimuram Nov 1, 2019
68be394
Make descriptor lock per pod and release it per pod
mkimuram Nov 1, 2019
8a159d7
Move MapBlockVolume call to operation_generator and add UnmapBlockVolume
mkimuram Nov 1, 2019
5a351e3
Check and return error first in IsSymlinkExist and IsBindMountExist
mkimuram Nov 4, 2019
7abb704
Improve comments for volume path hanlder and volume.go
mkimuram Nov 4, 2019
bee6514
Remove klog for output error instead return err with context
mkimuram Nov 4, 2019
dd94542
Rename IsBindMountExist to IsDeviceBindMountExist
mkimuram Nov 12, 2019
a2cbc02
Remove remaining empty file in unmapBindMountDevice
mkimuram Nov 12, 2019
aee875a
Fix error messages in operation_generator.go
mkimuram Nov 12, 2019
8a09460
Change getDeviceMajorMinor to use unix.Stat
mkimuram Nov 12, 2019
560d9c5
Change mount.NewOSExec to utilexec.New
mkimuram Nov 14, 2019
05606bb
rename PluginConfigArgs to AlgorithmConfigArgs
ahg-g Nov 14, 2019
0ac8345
Fix --resource-version handling in kubectl
liggitt Nov 14, 2019
77df6bc
Ensuring EndpointSlice controller does not start when feature gate or
robscott Nov 14, 2019
ba9f741
Merge pull request #84732 from khenidak/fix-disable-dualstack
k8s-ci-robot Nov 14, 2019
567b134
Merge pull request #85162 from apelisse/strip-nullable
k8s-ci-robot Nov 14, 2019
547fdcc
Merge pull request #85174 from zhouya0/add_table_convertor_components…
k8s-ci-robot Nov 14, 2019
9b75e36
Merge pull request #85294 from ahg-g/ahg-15k
k8s-ci-robot Nov 14, 2019
a5760de
Add support for --runtime-config=api/beta=false, --feature-gates=AllB…
liggitt Oct 12, 2019
7f7f99b
Merge pull request #83964 from Jefftree/bdd-conformance
k8s-ci-robot Nov 14, 2019
37c7c90
Merge pull request #84227 from soltysh/fix_scale_doc
k8s-ci-robot Nov 14, 2019
55cef80
Merge pull request #84439 from danielqsj/f-apparmor
k8s-ci-robot Nov 14, 2019
e03d6e2
Merge pull request #84660 from mkimuram/refactor-block-lock
k8s-ci-robot Nov 14, 2019
5c772f5
Merge pull request #84674 from hwdef/fix-staticcheck4
k8s-ci-robot Nov 14, 2019
acfc88d
Merge pull request #84752 from seans3/json_yaml_printers
k8s-ci-robot Nov 14, 2019
bfb99d8
Merge pull request #85117 from hwdef/fix-staticcheck10
k8s-ci-robot Nov 14, 2019
2433444
Merge pull request #85175 from liggitt/golang-org-comments
k8s-ci-robot Nov 14, 2019
97225e2
Merge pull request #85230 from oomichi/add-todo-issue81245
k8s-ci-robot Nov 14, 2019
2706754
Merge pull request #85246 from robscott/endpointslice-dualstack-proxy
k8s-ci-robot Nov 14, 2019
0386d76
Merge pull request #83058 from bclau/tests/windows-tests-support
k8s-ci-robot Nov 15, 2019
6c5fb3e
Merge pull request #83491 from dcbw/winship-iptables-owner
k8s-ci-robot Nov 15, 2019
b9fa6e0
Merge pull request #83680 from bclau/tests/network-large-requests
k8s-ci-robot Nov 15, 2019
f1e912c
Merge pull request #84304 from liggitt/all-beta
k8s-ci-robot Nov 15, 2019
99e18f5
Merge pull request #84900 from MikeSpreitzer/add-namespace-to-rule
k8s-ci-robot Nov 15, 2019
30e6238
Merge pull request #85147 from yutedz/devmgr-rm-contents
k8s-ci-robot Nov 15, 2019
9edcaf7
Merge pull request #85252 from prameshj/fwrules-port
k8s-ci-robot Nov 15, 2019
8dffc8d
Merge pull request #85257 from yutedz/queueset-robin-idx
k8s-ci-robot Nov 15, 2019
141329f
Merge pull request #85285 from liggitt/kubectl-resource-version
k8s-ci-robot Nov 15, 2019
12b18f2
Merge pull request #85301 from robscott/endpointslice-beta-fix
k8s-ci-robot Nov 15, 2019
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
20 changes: 16 additions & 4 deletions api/openapi-spec/swagger.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion cmd/kube-apiserver/app/options/options.go
Expand Up @@ -142,7 +142,7 @@ func (s *ServerRunOptions) Flags() (fss cliflag.NamedFlagSets) {
s.Authentication.AddFlags(fss.FlagSet("authentication"))
s.Authorization.AddFlags(fss.FlagSet("authorization"))
s.CloudProvider.AddFlags(fss.FlagSet("cloud provider"))
s.APIEnablement.AddFlags(fss.FlagSet("api enablement"))
s.APIEnablement.AddFlags(fss.FlagSet("API enablement"))
s.EgressSelector.AddFlags(fss.FlagSet("egress selector"))
s.Admission.AddFlags(fss.FlagSet("admission"))

Expand Down
1 change: 1 addition & 0 deletions cmd/kube-controller-manager/app/BUILD
Expand Up @@ -109,6 +109,7 @@ go_library(
"//pkg/volume/util:go_default_library",
"//pkg/volume/vsphere_volume:go_default_library",
"//staging/src/k8s.io/api/core/v1:go_default_library",
"//staging/src/k8s.io/api/discovery/v1beta1:go_default_library",
"//staging/src/k8s.io/apimachinery/pkg/runtime/schema:go_default_library",
"//staging/src/k8s.io/apimachinery/pkg/util/runtime:go_default_library",
"//staging/src/k8s.io/apimachinery/pkg/util/sets:go_default_library",
Expand Down
14 changes: 14 additions & 0 deletions cmd/kube-controller-manager/app/discovery.go
Expand Up @@ -23,10 +23,24 @@ package app
import (
"net/http"

discoveryv1beta1 "k8s.io/api/discovery/v1beta1"
utilfeature "k8s.io/apiserver/pkg/util/feature"
"k8s.io/klog"
endpointslicecontroller "k8s.io/kubernetes/pkg/controller/endpointslice"
"k8s.io/kubernetes/pkg/features"
)

func startEndpointSliceController(ctx ControllerContext) (http.Handler, bool, error) {
if !utilfeature.DefaultFeatureGate.Enabled(features.EndpointSlice) {
klog.V(4).Infof("Not starting endpointslice-controller since EndpointSlice feature gate is disabled")
return nil, false, nil
}

if !ctx.AvailableResources[discoveryv1beta1.SchemeGroupVersion.WithResource("endpointslices")] {
klog.Warningf("Not starting endpointslice-controller since discovery.k8s.io/v1beta1 resources are not available")
return nil, false, nil
}

go endpointslicecontroller.NewController(
ctx.InformerFactory.Core().V1().Pods(),
ctx.InformerFactory.Core().V1().Services(),
Expand Down
5 changes: 3 additions & 2 deletions go.mod
Expand Up @@ -54,6 +54,7 @@ require (
github.com/evanphx/json-patch v4.2.0+incompatible
github.com/fsnotify/fsnotify v1.4.7
github.com/go-bindata/go-bindata v3.1.1+incompatible
github.com/go-openapi/analysis v0.19.2
github.com/go-openapi/loads v0.19.2
github.com/go-openapi/spec v0.19.2
github.com/go-openapi/strfmt v0.19.0
Expand Down Expand Up @@ -488,10 +489,10 @@ replace (
golang.org/x/oauth2 => golang.org/x/oauth2 v0.0.0-20190604053449-0f29369cfe45
golang.org/x/perf => golang.org/x/perf v0.0.0-20180704124530-6e6d33e29852
golang.org/x/sync => golang.org/x/sync v0.0.0-20190911185100-cd5d95a43a6e
golang.org/x/sys => golang.org/x/sys v0.0.0-20190813064441-fde4db37ae7a
golang.org/x/sys => golang.org/x/sys v0.0.0-20190813064441-fde4db37ae7a // pinned to release-branch.go1.13
golang.org/x/text => golang.org/x/text v0.3.2
golang.org/x/time => golang.org/x/time v0.0.0-20190308202827-9d24e82272b4
golang.org/x/tools => golang.org/x/tools v0.0.0-20190821162956-65e3620a7ae7
golang.org/x/tools => golang.org/x/tools v0.0.0-20190821162956-65e3620a7ae7 // pinned to release-branch.go1.13
golang.org/x/xerrors => golang.org/x/xerrors v0.0.0-20190717185122-a985d3407aa7
gonum.org/v1/gonum => gonum.org/v1/gonum v0.0.0-20190331200053-3d26580ed485
gonum.org/v1/netlib => gonum.org/v1/netlib v0.0.0-20190331212654-76723241ea4e
Expand Down
2 changes: 0 additions & 2 deletions hack/.staticcheck_failures
Expand Up @@ -3,7 +3,6 @@ cluster/images/etcd/migrate
cmd/kube-controller-manager/app
cmd/kube-proxy/app
cmd/linkcheck
pkg/client/tests
pkg/controller/daemon
pkg/controller/deployment
pkg/controller/disruption
Expand All @@ -15,7 +14,6 @@ pkg/controller/podgc
pkg/controller/replicaset
pkg/controller/resourcequota
pkg/controller/statefulset
pkg/kubeapiserver/admission
pkg/kubelet/apis/podresources
pkg/kubelet/cm/devicemanager
pkg/kubelet/pluginmanager/operationexecutor
Expand Down
50 changes: 38 additions & 12 deletions pkg/apis/flowcontrol/types.go
Expand Up @@ -26,8 +26,9 @@ const (
ResourceAll = "*"
VerbAll = "*"
NonResourceAll = "*"
NameAll = "*"

NameAll = "*"
NamespaceEvery = "*" // matches every particular namespace
)

// System preset priority level names
Expand Down Expand Up @@ -210,28 +211,53 @@ type ServiceAccountSubject struct {
Name string
}

// ResourcePolicyRule is a predicate that matches some resource requests, testing the request's verb and the target
// resource. A ResourcePolicyRule matches a request if and only if: (a) at least one member
// of verbs matches the request, (b) at least one member of apiGroups matches the request, and (c) at least one member
// of resources matches the request.
// ResourcePolicyRule is a predicate that matches some resource
// requests, testing the request's verb and the target resource. A
// ResourcePolicyRule matches a resource request if and only if: (a)
// at least one member of verbs matches the request, (b) at least one
// member of apiGroups matches the request, (c) at least one member of
// resources matches the request, and (d) least one member of
// namespaces matches the request.
type ResourcePolicyRule struct {
// `verbs` is a list of matching verbs and may not be empty.
// "*" matches all verbs. if it is present, it must be the only entry.
// "*" matches all verbs and, if present, must be the only entry.
// +listType=set
// Required.
Verbs []string

// `apiGroups` is a list of matching API groups and may not be empty.
// "*" matches all api-groups. if it is present, it must be the only entry.
// "*" matches all API groups and, if present, must be the only entry.
// +listType=set
// Required.
APIGroups []string
// `resources` is a list of matching resources (i.e., lowercase and plural) with, if desired, subresource.
// For example, [ "services", "nodes/status" ].
// This list may not be empty.
// "*" matches all resources. if it is present, it must be the only entry.
// +listType=set

// `resources` is a list of matching resources (i.e., lowercase
// and plural) with, if desired, subresource. For example, [
// "services", "nodes/status" ]. This list may not be empty.
// "*" matches all resources and, if present, must be the only entry.
// Required.
// +listType=set
Resources []string

// `clusterScope` indicates whether to match requests that do not
// specify a namespace (which happens either because the resource
// is not namespaced or the request targets all namespaces).
// If this field is omitted or false then the `namespaces` field
// must contain a non-empty list.
// +optional
ClusterScope bool

// `namespaces` is a list of target namespaces that restricts
// matches. A request that specifies a target namespace matches
// only if either (a) this list contains that target namespace or
// (b) this list contains "*". Note that "*" matches any
// specified namespace but does not match a request that _does
// not specify_ a namespace (see the `clusterScope` field for
// that).
// This list may be empty, but only if `clusterScope` is true.
// +optional
// +listType=set
Namespaces []string
}

// NonResourcePolicyRule is a predicate that matches non-resource requests according to their verb and the
Expand Down
4 changes: 4 additions & 0 deletions pkg/apis/flowcontrol/v1alpha1/zz_generated.conversion.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

24 changes: 22 additions & 2 deletions pkg/apis/flowcontrol/validation/validation.go
Expand Up @@ -245,9 +245,25 @@ func ValidateFlowSchemaResourcePolicyRule(rule *flowcontrol.ResourcePolicyRule,
allErrs = append(allErrs, field.Invalid(fldPath.Child("resources"), rule.Resources, "if '*' is present, must not specify other resources"))
}

if len(rule.Namespaces) == 0 && !rule.ClusterScope {
allErrs = append(allErrs, field.Required(fldPath.Child("namespaces"), "resource rules that are not cluster scoped must supply at least one namespace"))
} else if hasWildcard(rule.Namespaces) {
if len(rule.Namespaces) > 1 {
allErrs = append(allErrs, field.Invalid(fldPath.Child("namespaces"), rule.Namespaces, "if '*' is present, must not specify other namespaces"))
}
} else {
for idx, tgtNS := range rule.Namespaces {
for _, msg := range apimachineryvalidation.ValidateNamespaceName(tgtNS, false) {
allErrs = append(allErrs, field.Invalid(fldPath.Child("namespaces").Index(idx), tgtNS, nsErrIntro+msg))
}
}
}

return allErrs
}

const nsErrIntro = "each member of this list must be '*' or a DNS-1123 label; "

// ValidateFlowSchemaStatus validates status for the flow-schema.
func ValidateFlowSchemaStatus(status *flowcontrol.FlowSchemaStatus, fldPath *field.Path) field.ErrorList {
var allErrs field.ErrorList
Expand Down Expand Up @@ -424,8 +440,12 @@ func ValidateNonResourceURLPath(path string, fldPath *field.Path) *field.Error {
}

func hasWildcard(operations []string) bool {
for _, o := range operations {
if o == "*" {
return memberInList("*", operations...)
}

func memberInList(seek string, a ...string) bool {
for _, ai := range a {
if ai == seek {
return true
}
}
Expand Down