Skip to content

🏃 Release v0.5.2 #865

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

Merged
merged 25 commits into from
Mar 18, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
25 commits
Select commit Hold shift + click to select a range
9ed6d0a
Flags supported added
bharathi-tenneti Jan 10, 2020
c9a71ba
stracktrace flag added - not working
bharathi-tenneti Jan 15, 2020
7943096
Working flags added
bharathi-tenneti Jan 16, 2020
3b28488
Cleaned up commets
bharathi-tenneti Jan 20, 2020
6567aca
Addressing PR coments
bharathi-tenneti Feb 21, 2020
334ea25
Merge branch 'upstream-master'
bharathi-tenneti Mar 2, 2020
435f612
Zap levels added, and custom log levels added
bharathi-tenneti Mar 4, 2020
dd4c92b
map added for levelStrings replacing switch, and formatting changes
bharathi-tenneti Mar 5, 2020
d17d9c9
Fixing few Error messaages
bharathi-tenneti Mar 5, 2020
b38979d
🐛 expose DefaultKubeAPIServerFlags in envtest
djzager Mar 9, 2020
e7d7f4c
Update pkg/log/zap/zap.go
bharathi-tenneti Mar 10, 2020
a1ebd06
Header comments fixed for godoc
bharathi-tenneti Mar 10, 2020
06787b6
Merge branch 'master' of github.com:bharathi-tenneti/controller-runtime
bharathi-tenneti Mar 10, 2020
4ced175
Merge branch 'master' of github.com:kubernetes-sigs/controller-runtime
bharathi-tenneti Mar 10, 2020
0d82d12
:running: fetch_ext_bins now checks existing version before downloading
vincepri Feb 28, 2020
5aca8b7
Merge pull request #767 from bharathi-tenneti/master
k8s-ci-robot Mar 11, 2020
edf7177
Merge pull request #846 from djzager/envtestAPIServer
k8s-ci-robot Mar 12, 2020
843039b
fix: conservative delay in rate limiter
alexeldeib Mar 15, 2020
7ce02a0
Add joelanford to approvers
joelanford Mar 16, 2020
d286bb5
Merge pull request #859 from alexeldeib/ace/limiter
k8s-ci-robot Mar 17, 2020
734df2a
Merge pull request #862 from joelanford/joelanford-approver
k8s-ci-robot Mar 17, 2020
3ce25e2
Merge pull request #834 from vincepri/fetch-improve
k8s-ci-robot Mar 18, 2020
2ea8546
Tolerate (more) merge commits in release notes
DirectXMan12 Mar 18, 2020
29e923a
Merge pull request #864 from DirectXMan12/infra/tolerate-extra-rel-no…
k8s-ci-robot Mar 18, 2020
2faccfc
Merge branch 'master' into release-0.5
DirectXMan12 Mar 18, 2020
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion OWNERS_ALIASES
Original file line number Diff line number Diff line change
Expand Up @@ -16,13 +16,13 @@ aliases:
controller-runtime-approvers:
- gerred
- shawn-hurley
- joelanford

# folks who can review and LGTM any PRs in the repo (doesn't
# include approvers & admins -- those count too via the OWNERS
# file)
controller-runtime-reviewers:
- alvaroaleman
- joelanford
- alenkacz
- vincepri

Expand Down
2 changes: 1 addition & 1 deletion go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ require (
github.com/onsi/gomega v1.8.1
github.com/prometheus/client_golang v1.0.0
github.com/prometheus/client_model v0.0.0-20190129233127-fd36f4220a90
go.uber.org/atomic v1.4.0 // indirect
github.com/spf13/pflag v1.0.5
go.uber.org/zap v1.10.0
golang.org/x/crypto v0.0.0-20191011191535-87dc89f01550 // indirect
golang.org/x/sys v0.0.0-20190922100055-0a153f010e69 // indirect
Expand Down
2 changes: 0 additions & 2 deletions go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -319,8 +319,6 @@ go.mongodb.org/mongo-driver v1.1.2/go.mod h1:u7ryQJ+DOzQmeO7zB6MHyr8jkEQvC8vH7qL
go.opencensus.io v0.21.0/go.mod h1:mSImk1erAIZhrmZN+AvHh14ztQfjbGwt4TtuofqLduU=
go.uber.org/atomic v1.3.2 h1:2Oa65PReHzfn29GpvgsYwloV9AVFHPDk8tYxt2c2tr4=
go.uber.org/atomic v1.3.2/go.mod h1:gD2HeocX3+yG+ygLZcrzQJaqmWj9AIm7n08wl/qW/PE=
go.uber.org/atomic v1.4.0 h1:cxzIVoETapQEqDhQu3QfnvXAV4AlzcvUCxkVUFw3+EU=
go.uber.org/atomic v1.4.0/go.mod h1:gD2HeocX3+yG+ygLZcrzQJaqmWj9AIm7n08wl/qW/PE=
go.uber.org/multierr v1.1.0 h1:HoEmRHQPVSqub6w2z2d2EOVs2fjyFRGyofhKuyDq0QI=
go.uber.org/multierr v1.1.0/go.mod h1:wR5kodmAFQ0UK8QlbwjlSNy0Z68gJhDJUG5sjR94q/0=
go.uber.org/zap v1.10.0 h1:ORx85nbTijNz8ljznvCMR1ZBIPKFn3jQrag10X2AsuM=
Expand Down
9 changes: 9 additions & 0 deletions hack/check-everything.sh
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,15 @@ SKIP_FETCH_TOOLS=${SKIP_FETCH_TOOLS:-""}
function fetch_kb_tools {
local dest_dir="${1}"

# use the pre-existing version in the temporary folder if it matches our k8s version
if [[ -x "${dest_dir}/kubebuilder/bin/kube-apiserver" ]]; then
version=$("${dest_dir}"/kubebuilder/bin/kube-apiserver --version)
if [[ $version == *"${k8s_version}"* ]]; then
header_text "Using cached kubebuilder-tools from ${dest_dir}"
return 0
fi
fi

header_text "fetching tools (into '${dest_dir}')"
kb_tools_archive_name="kubebuilder-tools-$k8s_version-$goos-$goarch.tar.gz"
kb_tools_download_url="https://storage.googleapis.com/kubebuilder-tools/$kb_tools_archive_name"
Expand Down
5 changes: 5 additions & 0 deletions hack/release/release-notes.sh
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,11 @@ while read commit_word commit; do
# skip temporary merge commits and accidental merge commit inclusion
# for calcuating release notes.
continue
elif [[ ${title} == "Merge branch '"*"'"* ]]; then
# skip for accidental merge commit inclusion for calculating release notes
# NB(directxman12): it's not clear what tool generates this style, but we've
# got some now, so tolerate them.
continue
fi

read # skip the blank line
Expand Down
1 change: 1 addition & 0 deletions pkg/client/apiutil/dynamicrestmapper.go
Original file line number Diff line number Diff line change
Expand Up @@ -318,5 +318,6 @@ func (b *dynamicLimiter) checkRate() error {
if res.Delay() == 0 {
return nil
}
res.Cancel()
return ErrRateLimited{res.Delay()}
}
20 changes: 20 additions & 0 deletions pkg/client/apiutil/dynamicrestmapper_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -86,6 +86,26 @@ var _ = Describe("Dynamic REST Mapper", func() {
}, "10s").Should(BeTrue())
})

It("should rate-limit then allow more at 1rps", func() {
By("setting a small limit")
*lim = *rate.NewLimiter(rate.Limit(1), 1)

By("forcing a reload after changing the mapper")
addToMapper = func(baseMapper *meta.DefaultRESTMapper) {
baseMapper.Add(secondGVK, meta.RESTScopeNamespace)
}

By("calling twice to trigger rate limiting")
Expect(callWithOther()).To(Succeed())
Expect(callWithTarget()).NotTo(Succeed())

// by 2nd call loop should succeed because we canceled our 1st rate-limited token, then waited a full second
By("calling until no longer rate-limited, 2nd call should succeed")
Eventually(func() bool {
return errors.As(callWithTarget(), &apiutil.ErrRateLimited{})
}, "2.5s", "1s").Should(BeFalse())
})

It("should avoid reloading twice if two requests for the same thing come in", func() {
count := 0
// we use sleeps here to simulate two simulataneous requests by slowing things down
Expand Down
4 changes: 4 additions & 0 deletions pkg/envtest/server.go
Original file line number Diff line number Diff line change
Expand Up @@ -307,3 +307,7 @@ func (te *Environment) useExistingCluster() bool {
}
return *te.UseExistingCluster
}

// DefaultKubeAPIServerFlags exposes the default args for the APIServer so that
// you can use those to append your own additional arguments.
var DefaultKubeAPIServerFlags = integration.APIServerDefaultArgs
140 changes: 140 additions & 0 deletions pkg/log/zap/flags.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,140 @@
/*
Copyright 2020 The Kubernetes Authors.

Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at

http://www.apache.org/licenses/LICENSE-2.0

Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
*/

// Package zap contains helpers for setting up a new logr.Logger instance
// using the Zap logging framework.
package zap

import (
"fmt"
"strconv"
"strings"

"github.com/spf13/pflag"
"go.uber.org/zap"
"go.uber.org/zap/zapcore"
)

var levelStrings = map[string]zapcore.Level{
"debug": zap.DebugLevel,
"-1": zap.DebugLevel,
"info": zap.InfoLevel,
"0": zap.InfoLevel,
"error": zap.ErrorLevel,
"2": zap.ErrorLevel,
"dpanic": zap.DPanicLevel,
"panic": zap.PanicLevel,
"warn": zap.WarnLevel,
"fatal": zap.FatalLevel,
}

type encoderFlag struct {
setFunc func(zapcore.Encoder)
value string
}

var _ pflag.Value = &encoderFlag{}

func (ev *encoderFlag) String() string {
return ev.value
}

func (ev *encoderFlag) Type() string {
return "encoder"
}

func (ev *encoderFlag) Set(flagValue string) error {
val := strings.ToLower(flagValue)
switch val {
case "json":
ev.setFunc(newJSONEncoder())
case "console":
ev.setFunc(newConsoleEncoder())
default:
return fmt.Errorf("invalid encoder value \"%s\"", flagValue)
}
ev.value = flagValue
return nil
}

func newJSONEncoder() zapcore.Encoder {
encoderConfig := zap.NewProductionEncoderConfig()
return zapcore.NewJSONEncoder(encoderConfig)
}

func newConsoleEncoder() zapcore.Encoder {
encoderConfig := zap.NewDevelopmentEncoderConfig()
return zapcore.NewConsoleEncoder(encoderConfig)
}

type levelFlag struct {
setFunc func(zap.AtomicLevel)
value string
}

var _ pflag.Value = &levelFlag{}

func (ev *levelFlag) Set(flagValue string) error {
level, validLevel := levelStrings[strings.ToLower(flagValue)]
if !validLevel {
logLevel, err := strconv.Atoi(flagValue)
if err != nil {
return fmt.Errorf("invalid log level \"%s\"", flagValue)
}
if logLevel > 0 {
intLevel := -1 * logLevel
ev.setFunc(zap.NewAtomicLevelAt(zapcore.Level(int8(intLevel))))
} else {
return fmt.Errorf("invalid log level \"%s\"", flagValue)
}
}
ev.setFunc(zap.NewAtomicLevelAt(level))
ev.value = flagValue
return nil
}

func (ev *levelFlag) String() string {
return ev.value
}

func (ev *levelFlag) Type() string {
return "level"
}

type stackTraceFlag struct {
setFunc func(zap.AtomicLevel)
value string
}

var _ pflag.Value = &stackTraceFlag{}

func (ev *stackTraceFlag) Set(flagValue string) error {
level, validLevel := levelStrings[strings.ToLower(flagValue)]
if !validLevel {
return fmt.Errorf("invalid stacktrace level \"%s\"", flagValue)
}
ev.setFunc(zap.NewAtomicLevelAt(level))
ev.value = flagValue
return nil
}

func (ev *stackTraceFlag) String() string {
return ev.value
}

func (ev *stackTraceFlag) Type() string {
return "level"
}
51 changes: 51 additions & 0 deletions pkg/log/zap/zap.go
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ limitations under the License.
package zap

import (
"flag"
"io"
"os"
"time"
Expand Down Expand Up @@ -207,3 +208,53 @@ func NewRaw(opts ...Opts) *zap.Logger {
log = log.WithOptions(o.ZapOpts...)
return log
}

// BindFlags will parse the given flagset for zap option flags and set the log options accordingly
// zap-devel: Development Mode defaults(encoder=consoleEncoder,logLevel=Debug,stackTraceLevel=Warn)
// Production Mode defaults(encoder=jsonEncoder,logLevel=Info,stackTraceLevel=Error)
// zap-encoder: Zap log encoding ('json' or 'console')
// zap-log-level: Zap Level to configure the verbosity of logging. Can be one of 'debug', 'info', 'error',
// or any integer value > 0 which corresponds to custom debug levels of increasing verbosity")
// zap-stacktrace-level: Zap Level at and above which stacktraces are captured (one of 'warn' or 'error')
func (o *Options) BindFlags(fs *flag.FlagSet) {

// Set Development mode value
fs.BoolVar(&o.Development, "zap-devel", false,
"Development Mode defaults(encoder=consoleEncoder,logLevel=Debug,stackTraceLevel=Warn). "+
"Production Mode defaults(encoder=jsonEncoder,logLevel=Info,stackTraceLevel=Error)")

// Set Encoder value
var encVal encoderFlag
encVal.setFunc = func(fromFlag zapcore.Encoder) {
o.Encoder = fromFlag
}
fs.Var(&encVal, "zap-encoder", "Zap log encoding ('json' or 'console')")

// Set the Log Level
var levelVal levelFlag
levelVal.setFunc = func(fromFlag zap.AtomicLevel) {
o.Level = &fromFlag
}
fs.Var(&levelVal, "zap-log-level",
"Zap Level to configure the verbosity of logging. Can be one of 'debug', 'info', 'error', "+
"or any integer value > 0 which corresponds to custom debug levels of increasing verbosity")

// Set the StrackTrace Level
var stackVal stackTraceFlag
stackVal.setFunc = func(fromFlag zap.AtomicLevel) {
o.StacktraceLevel = &fromFlag
}
fs.Var(&stackVal, "zap-stacktrace-level",
"Zap Level at and above which stacktraces are captured (one of 'warn' or 'error')")
}

// UseFlagOptions configures the logger to use the Options set by parsing zap option flags from the CLI.
// opts := zap.Options{}
// opts.BindFlags(flag.CommandLine)
// log := zap.New(zap.UseFlagOptions(&opts))
func UseFlagOptions(in *Options) Opts {
return func(o *Options) {
*o = *in
o.addDefaults()
}
}