mirror of https://github.com/knative/caching.git
upgrade to latest dependencies (#606)
bumping knative.dev/hack 0456e8b...cf8cbc0: > cf8cbc0 Fix the regex used for matching GitHub Actions files (# 156) > a8ef7b6 Skip presubmit tests for .github updates (# 154) bumping knative.dev/pkg 3c00bb0...80c511a: > 80c511a Wait for reconciler/controllers to return prior to exiting the process (# 2437) > d481724 Update community files (# 2428) > 9ea8176 Update actions (# 2430) > 0caafcb upgrade to latest dependencies (# 2429) > 3b550af changeset: Look in packed-refs file if ref file not found. (# 2425) > 5e98acd Make URL compatible with controller-gen (# 2431) Signed-off-by: Knative Automation <automation@knative.team>
This commit is contained in:
parent
057ba67508
commit
1a96127056
4
go.mod
4
go.mod
|
@ -10,6 +10,6 @@ require (
|
|||
k8s.io/client-go v0.22.5
|
||||
k8s.io/code-generator v0.22.5
|
||||
k8s.io/kube-openapi v0.0.0-20211109043538-20434351676c
|
||||
knative.dev/hack v0.0.0-20220216040439-0456e8bf6547
|
||||
knative.dev/pkg v0.0.0-20220215153400-3c00bb0157b9
|
||||
knative.dev/hack v0.0.0-20220222192704-cf8cbc0e9165
|
||||
knative.dev/pkg v0.0.0-20220222211204-80c511aa340f
|
||||
)
|
||||
|
|
8
go.sum
8
go.sum
|
@ -1108,11 +1108,11 @@ k8s.io/kube-openapi v0.0.0-20211109043538-20434351676c h1:jvamsI1tn9V0S8jicyX82q
|
|||
k8s.io/kube-openapi v0.0.0-20211109043538-20434351676c/go.mod h1:vHXdDvt9+2spS2Rx9ql3I8tycm3H9FDfdUoIuKCefvw=
|
||||
k8s.io/utils v0.0.0-20210819203725-bdf08cb9a70a h1:8dYfu/Fc9Gz2rNJKB9IQRGgQOh2clmRzNIPPY1xLY5g=
|
||||
k8s.io/utils v0.0.0-20210819203725-bdf08cb9a70a/go.mod h1:jPW/WVKK9YHAvNhRxK0md/EJ228hCsBRufyofKtW8HA=
|
||||
knative.dev/hack v0.0.0-20220209225905-7331bb16ba00/go.mod h1:PHt8x8yX5Z9pPquBEfIj0X66f8iWkWfR0S/sarACJrI=
|
||||
knative.dev/hack v0.0.0-20220216040439-0456e8bf6547 h1:lEWsaG/yMLLp3onNushrawsHFXD4LXCXTo5FUUa2GiU=
|
||||
knative.dev/hack v0.0.0-20220216040439-0456e8bf6547/go.mod h1:PHt8x8yX5Z9pPquBEfIj0X66f8iWkWfR0S/sarACJrI=
|
||||
knative.dev/pkg v0.0.0-20220215153400-3c00bb0157b9 h1:u0vYuNe0BTFvbqN8euaauL/kN3jR7mjmxMc+QRnWsUw=
|
||||
knative.dev/pkg v0.0.0-20220215153400-3c00bb0157b9/go.mod h1:6ZoCgi60jSUn/WrwTGNAZbsz5/kmwiZZD8EovSLzYZ4=
|
||||
knative.dev/hack v0.0.0-20220222192704-cf8cbc0e9165 h1:0d9rHKKWQnbOUUURb9rEOj7StoxLyAriHVIfhgumV9M=
|
||||
knative.dev/hack v0.0.0-20220222192704-cf8cbc0e9165/go.mod h1:PHt8x8yX5Z9pPquBEfIj0X66f8iWkWfR0S/sarACJrI=
|
||||
knative.dev/pkg v0.0.0-20220222211204-80c511aa340f h1:tFkxKxsHZ8APM3a4x3/qWQJy25IC1MKs3ikmBhQokY8=
|
||||
knative.dev/pkg v0.0.0-20220222211204-80c511aa340f/go.mod h1:qymIihGpeunap7KEUhrKRcm0LjhkCjL+n7ryIx2kLH0=
|
||||
pgregory.net/rapid v0.3.3/go.mod h1:UYpPVyjFHzYBGHIxLFoupi8vwk6rXNzRY9OMvVxFIOU=
|
||||
rsc.io/binaryregexp v0.2.0/go.mod h1:qTv7/COck+e2FymRvadv62gMdZztPaShugOCi3I+8D8=
|
||||
rsc.io/quote/v3 v3.1.0/go.mod h1:yEA65RcK8LyAZtP9Kv3t0HmxON59tX3rD+tICJqUlj0=
|
||||
|
|
|
@ -0,0 +1,66 @@
|
|||
// Copyright 2016 The Go Authors. All rights reserved.
|
||||
// Use of this source code is governed by a BSD-style
|
||||
// license that can be found in the LICENSE file.
|
||||
|
||||
// Package errgroup provides synchronization, error propagation, and Context
|
||||
// cancelation for groups of goroutines working on subtasks of a common task.
|
||||
package errgroup
|
||||
|
||||
import (
|
||||
"context"
|
||||
"sync"
|
||||
)
|
||||
|
||||
// A Group is a collection of goroutines working on subtasks that are part of
|
||||
// the same overall task.
|
||||
//
|
||||
// A zero Group is valid and does not cancel on error.
|
||||
type Group struct {
|
||||
cancel func()
|
||||
|
||||
wg sync.WaitGroup
|
||||
|
||||
errOnce sync.Once
|
||||
err error
|
||||
}
|
||||
|
||||
// WithContext returns a new Group and an associated Context derived from ctx.
|
||||
//
|
||||
// The derived Context is canceled the first time a function passed to Go
|
||||
// returns a non-nil error or the first time Wait returns, whichever occurs
|
||||
// first.
|
||||
func WithContext(ctx context.Context) (*Group, context.Context) {
|
||||
ctx, cancel := context.WithCancel(ctx)
|
||||
return &Group{cancel: cancel}, ctx
|
||||
}
|
||||
|
||||
// Wait blocks until all function calls from the Go method have returned, then
|
||||
// returns the first non-nil error (if any) from them.
|
||||
func (g *Group) Wait() error {
|
||||
g.wg.Wait()
|
||||
if g.cancel != nil {
|
||||
g.cancel()
|
||||
}
|
||||
return g.err
|
||||
}
|
||||
|
||||
// Go calls the given function in a new goroutine.
|
||||
//
|
||||
// The first call to return a non-nil error cancels the group; its error will be
|
||||
// returned by Wait.
|
||||
func (g *Group) Go(f func() error) {
|
||||
g.wg.Add(1)
|
||||
|
||||
go func() {
|
||||
defer g.wg.Done()
|
||||
|
||||
if err := f(); err != nil {
|
||||
g.errOnce.Do(func() {
|
||||
g.err = err
|
||||
if g.cancel != nil {
|
||||
g.cancel()
|
||||
}
|
||||
})
|
||||
}
|
||||
}()
|
||||
}
|
|
@ -23,7 +23,7 @@ source $(dirname "${BASH_SOURCE[0]}")/library.sh
|
|||
readonly PRESUBMIT_TEST_FAIL_FAST=${PRESUBMIT_TEST_FAIL_FAST:-0}
|
||||
|
||||
# Extensions or file patterns that don't require presubmit tests.
|
||||
readonly NO_PRESUBMIT_FILES=(\.png \.gitignore \.gitattributes ^OWNERS ^OWNERS_ALIASES ^AUTHORS)
|
||||
readonly NO_PRESUBMIT_FILES=(\.png \.gitignore \.gitattributes ^OWNERS ^OWNERS_ALIASES ^AUTHORS \.github/.*)
|
||||
|
||||
# Flag if this is a presubmit run or not.
|
||||
(( IS_PROW )) && [[ ${JOB_TYPE} == "presubmit" ]] && IS_PRESUBMIT=1 || IS_PRESUBMIT=0
|
||||
|
|
|
@ -27,6 +27,7 @@ import (
|
|||
// URL is an alias of url.URL.
|
||||
// It has custom json marshal methods that enable it to be used in K8s CRDs
|
||||
// such that the CRD resource will have the URL but operator code can can work with url.URL struct
|
||||
// +kubebuilder:validation:Type=string
|
||||
type URL url.URL
|
||||
|
||||
// ParseURL attempts to parse the given string as a URL.
|
||||
|
|
|
@ -17,6 +17,7 @@ limitations under the License.
|
|||
package changeset
|
||||
|
||||
import (
|
||||
"bufio"
|
||||
"fmt"
|
||||
"io/ioutil"
|
||||
"os"
|
||||
|
@ -28,6 +29,10 @@ import (
|
|||
const (
|
||||
commitIDFile = "HEAD"
|
||||
koDataPathEnvName = "KO_DATA_PATH"
|
||||
// packedRefsFile is a file containing a list of refs, used to compact the
|
||||
// list of refs instead of storing them on the filesystem directly.
|
||||
// See https://git-scm.com/docs/git-pack-refs
|
||||
packedRefsFile = "packed-refs"
|
||||
)
|
||||
|
||||
var commitIDRE = regexp.MustCompile(`^[a-f0-9]{40}$`)
|
||||
|
@ -41,9 +46,27 @@ func Get() (string, error) {
|
|||
}
|
||||
commitID := strings.TrimSpace(string(data))
|
||||
if rID := strings.TrimPrefix(commitID, "ref: "); rID != commitID {
|
||||
// First try to read from the direct ref file - e.g. refs/heads/main
|
||||
data, err := readFileFromKoData(rID)
|
||||
if err != nil {
|
||||
return "", err
|
||||
if !os.IsNotExist(err) {
|
||||
return "", err
|
||||
}
|
||||
|
||||
// Ref file didn't exist - it might be contained in the packed-refs
|
||||
// file.
|
||||
var pferr error
|
||||
data, pferr = findPackedRef(rID)
|
||||
// Only return the sub-error if the packed-refs file exists, otherwise
|
||||
// just let the original error return (e.g. treat it as if we didn't
|
||||
// even attempt the operation). This is primarily to keep the error
|
||||
// messages clean.
|
||||
if pferr != nil {
|
||||
if os.IsNotExist(pferr) {
|
||||
return "", err
|
||||
}
|
||||
return "", pferr
|
||||
}
|
||||
}
|
||||
commitID = strings.TrimSpace(string(data))
|
||||
}
|
||||
|
@ -58,9 +81,49 @@ func Get() (string, error) {
|
|||
// to be wrapped into the container from /kodata by ko. If it fails, returns
|
||||
// the error it gets.
|
||||
func readFileFromKoData(filename string) ([]byte, error) {
|
||||
f, err := koDataFile(filename)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
defer f.Close()
|
||||
return ioutil.ReadAll(f)
|
||||
}
|
||||
|
||||
// readFileFromKoData tries to open the file with given name under KO_DATA_PATH.
|
||||
// The file is expected to be wrapped into the container from /kodata by ko.
|
||||
// If it fails, returns the error it gets.
|
||||
func koDataFile(filename string) (*os.File, error) {
|
||||
koDataPath := os.Getenv(koDataPathEnvName)
|
||||
if koDataPath == "" {
|
||||
return nil, fmt.Errorf("%q does not exist or is empty", koDataPathEnvName)
|
||||
}
|
||||
return ioutil.ReadFile(filepath.Join(koDataPath, filename))
|
||||
return os.Open(filepath.Join(koDataPath, filename))
|
||||
}
|
||||
|
||||
// findPackedRef searches the packed-ref file for ref values.
|
||||
// This can happen if the # of refs in a repo grows too much - git will try
|
||||
// and condense them into a file.
|
||||
// See https://git-scm.com/docs/git-pack-refs
|
||||
func findPackedRef(ref string) ([]byte, error) {
|
||||
f, err := koDataFile(packedRefsFile)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
defer f.Close()
|
||||
|
||||
scanner := bufio.NewScanner(f)
|
||||
for scanner.Scan() {
|
||||
// We only care about lines with `<commit> <ref>` pairs.
|
||||
// Why this might happen:
|
||||
// 1. Lines starting with ^ refer to unpeeled tag SHAs
|
||||
// (e.g. the commits pointed to by annotated tags)
|
||||
s := strings.Split(scanner.Text(), " ")
|
||||
if len(s) != 2 {
|
||||
continue
|
||||
}
|
||||
if ref == s[1] {
|
||||
return []byte(s[0]), nil
|
||||
}
|
||||
}
|
||||
return nil, fmt.Errorf("%q ref not found in packed-refs", ref)
|
||||
}
|
||||
|
|
|
@ -24,6 +24,7 @@ import (
|
|||
"time"
|
||||
|
||||
"github.com/google/uuid"
|
||||
"golang.org/x/sync/errgroup"
|
||||
|
||||
"go.uber.org/zap"
|
||||
"go.uber.org/zap/zapcore"
|
||||
|
@ -440,6 +441,11 @@ func (c *Impl) EnqueueKeyAfter(key types.NamespacedName, delay time.Duration) {
|
|||
}
|
||||
}
|
||||
|
||||
// Run runs the controller with it's configured Concurrency
|
||||
func (c *Impl) Run(ctx context.Context) error {
|
||||
return c.RunContext(ctx, c.Concurrency)
|
||||
}
|
||||
|
||||
// RunContext starts the controller's worker threads, the number of which is threadiness.
|
||||
// If the context has been decorated for LeaderElection, then an elector is built and run.
|
||||
// It then blocks until the context is cancelled, at which point it shuts down its
|
||||
|
@ -487,19 +493,6 @@ func (c *Impl) RunContext(ctx context.Context, threadiness int) error {
|
|||
return nil
|
||||
}
|
||||
|
||||
// Run runs the controller.
|
||||
//
|
||||
// Deprecated: Use RunContext instead.
|
||||
func (c *Impl) Run(threadiness int, stopCh <-chan struct{}) error {
|
||||
// Create a context that is cancelled when the stopCh is called.
|
||||
ctx, cancel := context.WithCancel(context.Background())
|
||||
go func() {
|
||||
<-stopCh
|
||||
cancel()
|
||||
}()
|
||||
return c.RunContext(ctx, threadiness)
|
||||
}
|
||||
|
||||
// processNextWorkItem will read a single work item off the workqueue and
|
||||
// attempt to process it, by calling Reconcile on our Reconciler.
|
||||
func (c *Impl) processNextWorkItem() bool {
|
||||
|
@ -778,18 +771,17 @@ func WaitForCacheSyncQuick(stopCh <-chan struct{}, cacheSyncs ...cache.InformerS
|
|||
}
|
||||
|
||||
// StartAll kicks off all of the passed controllers with DefaultThreadsPerController.
|
||||
func StartAll(ctx context.Context, controllers ...*Impl) {
|
||||
wg := sync.WaitGroup{}
|
||||
func StartAll(ctx context.Context, controllers ...*Impl) error {
|
||||
eg, egCtx := errgroup.WithContext(ctx)
|
||||
|
||||
// Start all of the controllers.
|
||||
for _, ctrlr := range controllers {
|
||||
wg.Add(1)
|
||||
concurrency := ctrlr.Concurrency
|
||||
go func(c *Impl) {
|
||||
defer wg.Done()
|
||||
c.RunContext(ctx, concurrency)
|
||||
}(ctrlr)
|
||||
for _, controller := range controllers {
|
||||
c := controller
|
||||
eg.Go(func() error {
|
||||
return c.Run(egCtx)
|
||||
})
|
||||
}
|
||||
wg.Wait()
|
||||
return eg.Wait()
|
||||
}
|
||||
|
||||
// This is attached to contexts passed to controller constructors to associate
|
||||
|
|
|
@ -166,6 +166,7 @@ golang.org/x/net/trace
|
|||
golang.org/x/oauth2
|
||||
golang.org/x/oauth2/internal
|
||||
# golang.org/x/sync v0.0.0-20210220032951-036812b2e83c
|
||||
golang.org/x/sync/errgroup
|
||||
golang.org/x/sync/semaphore
|
||||
# golang.org/x/sys v0.0.0-20211124211545-fe61309f8881
|
||||
golang.org/x/sys/execabs
|
||||
|
@ -579,10 +580,10 @@ k8s.io/kube-openapi/pkg/validation/spec
|
|||
k8s.io/utils/buffer
|
||||
k8s.io/utils/integer
|
||||
k8s.io/utils/trace
|
||||
# knative.dev/hack v0.0.0-20220216040439-0456e8bf6547
|
||||
# knative.dev/hack v0.0.0-20220222192704-cf8cbc0e9165
|
||||
## explicit
|
||||
knative.dev/hack
|
||||
# knative.dev/pkg v0.0.0-20220215153400-3c00bb0157b9
|
||||
# knative.dev/pkg v0.0.0-20220222211204-80c511aa340f
|
||||
## explicit
|
||||
knative.dev/pkg/apis
|
||||
knative.dev/pkg/apis/duck
|
||||
|
|
Loading…
Reference in New Issue