Skip to content

Commit

Permalink
Merge remote-tracking branch 'origin/master'
Browse files Browse the repository at this point in the history
  • Loading branch information
Anago GCB committed Nov 17, 2021
2 parents 6e4534f + e4952f3 commit 8c7ecd9
Show file tree
Hide file tree
Showing 151 changed files with 22,285 additions and 18,983 deletions.
39 changes: 39 additions & 0 deletions .golangci.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
run:
timeout: 30m
skip-files:
- "^zz_generated.*"

issues:
max-same-issues: 0
# Excluding configuration per-path, per-linter, per-text and per-source
exclude-rules:
# exclude ineffassing linter for generated files for conversion
- path: conversion\.go
linters:
- ineffassign

linters:
disable-all: true
enable: # please keep this alphabetized
# Don't use soon to deprecated[1] linters that lead to false
# https://github.com/golangci/golangci-lint/issues/1841
# - deadcode
# - structcheck
# - varcheck
- ineffassign
- staticcheck
- unused

linters-settings: # please keep this alphabetized
staticcheck:
go: "1.17"
checks: [
"all",
"-S1*", # TODO(fix) Omit code simplifications for now.
"-ST1*", # Mostly stylistic, redundant w/ golint
"-SA5011", # TODO(fix) Possible nil pointer dereference
"-SA1019", # TODO(fix) Using a deprecated function, variable, constant or field
"-SA2002" # TODO(fix) Called testing.T.FailNow or SkipNow in a goroutine, which isn’t allowed
]
unused:
go: "1.17"
21 changes: 21 additions & 0 deletions api/openapi-spec/swagger.json

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

23 changes: 23 additions & 0 deletions api/openapi-spec/v3/api__v1_openapi.json
Original file line number Diff line number Diff line change
Expand Up @@ -24507,6 +24507,25 @@
}
}
},
"io.k8s.api.core.v1.GRPCAction": {
"type": "object",
"required": [
"port"
],
"properties": {
"port": {
"description": "Port number of the gRPC service. Number must be in the range 1 to 65535.",
"type": "integer",
"format": "int32",
"default": 0
},
"service": {
"description": "Service is the name of the service to place in the gRPC HealthCheckRequest (see https://github.com/grpc/grpc/blob/master/doc/health-checking.md).\n\nIf this is not specified, the default behavior is defined by gRPC.",
"type": "string",
"default": ""
}
}
},
"io.k8s.api.core.v1.GitRepoVolumeSource": {
"description": "Represents a volume that is populated with the contents of a git repository. Git repo volumes do not support ownership management. Git repo volumes support SELinux relabeling.\n\nDEPRECATED: GitRepo is deprecated. To provision a container with a git repo, mount an EmptyDir into an InitContainer that clones the repo using git, then mount the EmptyDir into the Pod's container.",
"type": "object",
Expand Down Expand Up @@ -27113,6 +27132,10 @@
"type": "integer",
"format": "int32"
},
"gRPC": {
"description": "GRPC specifies an action involving a GRPC port. This is an alpha field and requires enabling GRPCContainerProbe feature gate.",
"$ref": "#/components/schemas/io.k8s.api.core.v1.GRPCAction"
},
"httpGet": {
"description": "HTTPGet specifies the http request to perform.",
"$ref": "#/components/schemas/io.k8s.api.core.v1.HTTPGetAction"
Expand Down
23 changes: 23 additions & 0 deletions api/openapi-spec/v3/apis__apps__v1_openapi.json
Original file line number Diff line number Diff line change
Expand Up @@ -9952,6 +9952,25 @@
}
}
},
"io.k8s.api.core.v1.GRPCAction": {
"type": "object",
"required": [
"port"
],
"properties": {
"port": {
"description": "Port number of the gRPC service. Number must be in the range 1 to 65535.",
"type": "integer",
"format": "int32",
"default": 0
},
"service": {
"description": "Service is the name of the service to place in the gRPC HealthCheckRequest (see https://github.com/grpc/grpc/blob/master/doc/health-checking.md).\n\nIf this is not specified, the default behavior is defined by gRPC.",
"type": "string",
"default": ""
}
}
},
"io.k8s.api.core.v1.GitRepoVolumeSource": {
"description": "Represents a volume that is populated with the contents of a git repository. Git repo volumes do not support ownership management. Git repo volumes support SELinux relabeling.\n\nDEPRECATED: GitRepo is deprecated. To provision a container with a git repo, mount an EmptyDir into an InitContainer that clones the repo using git, then mount the EmptyDir into the Pod's container.",
"type": "object",
Expand Down Expand Up @@ -11101,6 +11120,10 @@
"type": "integer",
"format": "int32"
},
"gRPC": {
"description": "GRPC specifies an action involving a GRPC port. This is an alpha field and requires enabling GRPCContainerProbe feature gate.",
"$ref": "#/components/schemas/io.k8s.api.core.v1.GRPCAction"
},
"httpGet": {
"description": "HTTPGet specifies the http request to perform.",
"$ref": "#/components/schemas/io.k8s.api.core.v1.HTTPGetAction"
Expand Down
23 changes: 23 additions & 0 deletions api/openapi-spec/v3/apis__batch__v1_openapi.json
Original file line number Diff line number Diff line change
Expand Up @@ -4355,6 +4355,25 @@
}
}
},
"io.k8s.api.core.v1.GRPCAction": {
"type": "object",
"required": [
"port"
],
"properties": {
"port": {
"description": "Port number of the gRPC service. Number must be in the range 1 to 65535.",
"type": "integer",
"format": "int32",
"default": 0
},
"service": {
"description": "Service is the name of the service to place in the gRPC HealthCheckRequest (see https://github.com/grpc/grpc/blob/master/doc/health-checking.md).\n\nIf this is not specified, the default behavior is defined by gRPC.",
"type": "string",
"default": ""
}
}
},
"io.k8s.api.core.v1.GitRepoVolumeSource": {
"description": "Represents a volume that is populated with the contents of a git repository. Git repo volumes do not support ownership management. Git repo volumes support SELinux relabeling.\n\nDEPRECATED: GitRepo is deprecated. To provision a container with a git repo, mount an EmptyDir into an InitContainer that clones the repo using git, then mount the EmptyDir into the Pod's container.",
"type": "object",
Expand Down Expand Up @@ -5409,6 +5428,10 @@
"type": "integer",
"format": "int32"
},
"gRPC": {
"description": "GRPC specifies an action involving a GRPC port. This is an alpha field and requires enabling GRPCContainerProbe feature gate.",
"$ref": "#/components/schemas/io.k8s.api.core.v1.GRPCAction"
},
"httpGet": {
"description": "HTTPGet specifies the http request to perform.",
"$ref": "#/components/schemas/io.k8s.api.core.v1.HTTPGetAction"
Expand Down
23 changes: 23 additions & 0 deletions api/openapi-spec/v3/apis__batch__v1beta1_openapi.json
Original file line number Diff line number Diff line change
Expand Up @@ -2663,6 +2663,25 @@
}
}
},
"io.k8s.api.core.v1.GRPCAction": {
"type": "object",
"required": [
"port"
],
"properties": {
"port": {
"description": "Port number of the gRPC service. Number must be in the range 1 to 65535.",
"type": "integer",
"format": "int32",
"default": 0
},
"service": {
"description": "Service is the name of the service to place in the gRPC HealthCheckRequest (see https://github.com/grpc/grpc/blob/master/doc/health-checking.md).\n\nIf this is not specified, the default behavior is defined by gRPC.",
"type": "string",
"default": ""
}
}
},
"io.k8s.api.core.v1.GitRepoVolumeSource": {
"description": "Represents a volume that is populated with the contents of a git repository. Git repo volumes do not support ownership management. Git repo volumes support SELinux relabeling.\n\nDEPRECATED: GitRepo is deprecated. To provision a container with a git repo, mount an EmptyDir into an InitContainer that clones the repo using git, then mount the EmptyDir into the Pod's container.",
"type": "object",
Expand Down Expand Up @@ -3717,6 +3736,10 @@
"type": "integer",
"format": "int32"
},
"gRPC": {
"description": "GRPC specifies an action involving a GRPC port. This is an alpha field and requires enabling GRPCContainerProbe feature gate.",
"$ref": "#/components/schemas/io.k8s.api.core.v1.GRPCAction"
},
"httpGet": {
"description": "HTTPGet specifies the http request to perform.",
"$ref": "#/components/schemas/io.k8s.api.core.v1.HTTPGetAction"
Expand Down
8 changes: 4 additions & 4 deletions cmd/kube-proxy/app/server.go
Original file line number Diff line number Diff line change
Expand Up @@ -165,9 +165,9 @@ func (o *Options) AddFlags(fs *pflag.FlagSet) {

fs.BoolVar(&o.CleanupAndExit, "cleanup", o.CleanupAndExit, "If true cleanup iptables and ipvs rules and exit.")

fs.Var(utilflag.IPVar{Val: &o.config.BindAddress}, "bind-address", "The IP address for the proxy server to serve on (set to '0.0.0.0' for all IPv4 interfaces and '::' for all IPv6 interfaces)")
fs.Var(utilflag.IPPortVar{Val: &o.config.HealthzBindAddress}, "healthz-bind-address", "The IP address with port for the health check server to serve on (set to '0.0.0.0:10256' for all IPv4 interfaces and '[::]:10256' for all IPv6 interfaces). Set empty to disable.")
fs.Var(utilflag.IPPortVar{Val: &o.config.MetricsBindAddress}, "metrics-bind-address", "The IP address with port for the metrics server to serve on (set to '0.0.0.0:10249' for all IPv4 interfaces and '[::]:10249' for all IPv6 interfaces). Set empty to disable.")
fs.Var(&utilflag.IPVar{Val: &o.config.BindAddress}, "bind-address", "The IP address for the proxy server to serve on (set to '0.0.0.0' for all IPv4 interfaces and '::' for all IPv6 interfaces)")
fs.Var(&utilflag.IPPortVar{Val: &o.config.HealthzBindAddress}, "healthz-bind-address", "The IP address with port for the health check server to serve on (set to '0.0.0.0:10256' for all IPv4 interfaces and '[::]:10256' for all IPv6 interfaces). Set empty to disable.")
fs.Var(&utilflag.IPPortVar{Val: &o.config.MetricsBindAddress}, "metrics-bind-address", "The IP address with port for the metrics server to serve on (set to '0.0.0.0:10249' for all IPv4 interfaces and '[::]:10249' for all IPv6 interfaces). Set empty to disable.")
fs.BoolVar(&o.config.BindAddressHardFail, "bind-address-hard-fail", o.config.BindAddressHardFail, "If true kube-proxy will treat failure to bind to a port as fatal and exit")
fs.Var(utilflag.PortRangeVar{Val: &o.config.PortRange}, "proxy-port-range", "Range of host ports (beginPort-endPort, single port or beginPort+offset, inclusive) that may be consumed in order to proxy service traffic. If (unspecified, 0, or 0-0) then ports will be randomly chosen.")
fs.Var(&o.config.Mode, "proxy-mode", "Which proxy mode to use: 'userspace' (older) or 'iptables' (faster) or 'ipvs' or 'kernelspace' (windows). If blank, use the best-available proxy (currently iptables). If the iptables proxy is selected, regardless of how, but the system's kernel or iptables versions are insufficient, this always falls back to the userspace proxy.")
Expand Down Expand Up @@ -623,7 +623,7 @@ func serveMetrics(bindAddress, proxyMode string, enableProfiling bool, errCh cha
fmt.Fprintf(w, "%s", proxyMode)
})

//lint:ignore SA1019 See the Metrics Stability Migration KEP
//nolint:staticcheck // SA1019 See the Metrics Stability Migration KEP
proxyMux.Handle("/metrics", legacyregistry.Handler())

if enableProfiling {
Expand Down
2 changes: 1 addition & 1 deletion cmd/kube-scheduler/app/config/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ type Config struct {
InformerFactory informers.SharedInformerFactory
DynInformerFactory dynamicinformer.DynamicSharedInformerFactory

//lint:ignore SA1019 this deprecated field still needs to be used for now. It will be removed once the migration is done.
//nolint:staticcheck // SA1019 this deprecated field still needs to be used for now. It will be removed once the migration is done.
EventBroadcaster events.EventBroadcasterAdapter

// LeaderElection is optional.
Expand Down
3 changes: 1 addition & 2 deletions cmd/kubeadm/app/preflight/checks.go
Original file line number Diff line number Diff line change
Expand Up @@ -808,10 +808,9 @@ func getEtcdVersionResponse(client *http.Client, url string, target interface{})
loopCount--
return false, err
}
//lint:ignore SA5011 If err != nil we are already returning.
defer r.Body.Close()

if r != nil && r.StatusCode >= 500 && r.StatusCode <= 599 {
if r.StatusCode >= 500 && r.StatusCode <= 599 {
loopCount--
return false, errors.Errorf("server responded with non-successful status: %s", r.Status)
}
Expand Down
4 changes: 2 additions & 2 deletions cmd/kubelet/app/options/options.go
Original file line number Diff line number Diff line change
Expand Up @@ -405,7 +405,7 @@ func AddKubeletConfigFlags(mainfs *pflag.FlagSet, c *kubeletconfig.KubeletConfig
fs.DurationVar(&c.HTTPCheckFrequency.Duration, "http-check-frequency", c.HTTPCheckFrequency.Duration, "Duration between checking http for new data")
fs.StringVar(&c.StaticPodURL, "manifest-url", c.StaticPodURL, "URL for accessing additional Pod specifications to run")
fs.Var(cliflag.NewColonSeparatedMultimapStringString(&c.StaticPodURLHeader), "manifest-url-header", "Comma-separated list of HTTP headers to use when accessing the url provided to --manifest-url. Multiple headers with the same name will be added in the same order provided. This flag can be repeatedly invoked. For example: --manifest-url-header 'a:hello,b:again,c:world' --manifest-url-header 'b:beautiful'")
fs.Var(utilflag.IPVar{Val: &c.Address}, "address", "The IP address for the Kubelet to serve on (set to '0.0.0.0' or '::' for listening in all interfaces and IP families)")
fs.Var(&utilflag.IPVar{Val: &c.Address}, "address", "The IP address for the Kubelet to serve on (set to '0.0.0.0' or '::' for listening in all interfaces and IP families)")
fs.Int32Var(&c.Port, "port", c.Port, "The port for the Kubelet to serve on.")
fs.Int32Var(&c.ReadOnlyPort, "read-only-port", c.ReadOnlyPort, "The read-only port for the Kubelet to serve on with no authentication/authorization (set to 0 to disable)")

Expand Down Expand Up @@ -459,7 +459,7 @@ func AddKubeletConfigFlags(mainfs *pflag.FlagSet, c *kubeletconfig.KubeletConfig
fs.BoolVar(&c.EnableDebuggingHandlers, "enable-debugging-handlers", c.EnableDebuggingHandlers, "Enables server endpoints for log collection and local running of containers and commands")
fs.BoolVar(&c.EnableContentionProfiling, "contention-profiling", c.EnableContentionProfiling, "Enable lock contention profiling, if profiling is enabled")
fs.Int32Var(&c.HealthzPort, "healthz-port", c.HealthzPort, "The port of the localhost healthz endpoint (set to 0 to disable)")
fs.Var(utilflag.IPVar{Val: &c.HealthzBindAddress}, "healthz-bind-address", "The IP address for the healthz server to serve on (set to '0.0.0.0' or '::' for listening in all interfaces and IP families)")
fs.Var(&utilflag.IPVar{Val: &c.HealthzBindAddress}, "healthz-bind-address", "The IP address for the healthz server to serve on (set to '0.0.0.0' or '::' for listening in all interfaces and IP families)")
fs.Int32Var(&c.OOMScoreAdj, "oom-score-adj", c.OOMScoreAdj, "The oom-score-adj value for kubelet process. Values must be within the range [-1000, 1000]")
fs.StringVar(&c.ClusterDomain, "cluster-domain", c.ClusterDomain, "Domain for this cluster. If set, kubelet will configure all containers to search this domain in addition to the host's search domains")

Expand Down
11 changes: 11 additions & 0 deletions hack/.structured_logging
Original file line number Diff line number Diff line change
@@ -1,4 +1,15 @@
cmd/kube-proxy/...
cmd/kube-scheduler/app/config/...
cmd/kube-scheduler/app/testing/...
cmd/kubelet/...
pkg/kubelet/...
pkg/proxy/...
pkg/scheduler/apis/...
pkg/scheduler/framework/...
pkg/scheduler/internal/cache/fake/...
pkg/scheduler/internal/heap/...
pkg/scheduler/internal/queue/...
pkg/scheduler/metrics/...
pkg/scheduler/profile/...
pkg/scheduler/testing/...
pkg/scheduler/util/...
43 changes: 35 additions & 8 deletions hack/verify-golangci-lint.sh
Original file line number Diff line number Diff line change
Expand Up @@ -43,11 +43,38 @@ popd >/dev/null

cd "${KUBE_ROOT}"

echo 'running golangci-lint '
golangci-lint run \
--timeout 30m \
--disable-all \
-E deadcode \
-E unused \
-E varcheck \
-E ineffassign
# The config is in ${KUBE_ROOT}/.golangci.yaml
echo 'running golangci-lint ' >&2
res=0
if [[ "$#" -gt 0 ]]; then
golangci-lint run "$@" >&2 || res=$?
else
golangci-lint run ./... >&2 || res=$?
for d in staging/src/k8s.io/*; do
MODPATH="staging/src/k8s.io/$(basename "${d}")"
echo "running golangci-lint for ${KUBE_ROOT}/${MODPATH}"
pushd "${KUBE_ROOT}/${MODPATH}" >/dev/null
golangci-lint --path-prefix "${MODPATH}" run ./... >&2 || res=$?
popd >/dev/null
done
fi

# print a message based on the result
if [ "$res" -eq 0 ]; then
echo 'Congratulations! All files are passing lint :-)'
else
{
echo
echo 'Please review the above warnings. You can test via "./hack/verify-golangci-lint.sh"'
echo 'If the above warnings do not make sense, you can exempt this warning with a comment'
echo ' (if your reviewer is okay with it).'
echo 'In general please prefer to fix the error, we have already disabled specific lints'
echo ' that the project chooses to ignore.'
echo 'See: https://golangci-lint.run/usage/false-positives/'
echo
} >&2
exit 1
fi

# preserve the result
exit "$res"

0 comments on commit 8c7ecd9

Please sign in to comment.