Auto-update dependencies (#173)

Produced via:
  `dep ensure -update knative.dev/test-infra knative.dev/pkg`
/assign n3wscott
/cc n3wscott
This commit is contained in:
Matt Moore 2020-01-06 07:51:49 -08:00 committed by Knative Prow Robot
parent 587434f9e2
commit a0d7299838
8 changed files with 101 additions and 36 deletions

6
Gopkg.lock generated
View File

@ -931,7 +931,7 @@
[[projects]] [[projects]]
branch = "master" branch = "master"
digest = "1:86a6a4c7d3720415afcf3067cc52b0bbf6b810e58544c7336e514e32cba4a540" digest = "1:39b9c37fd5c6e531b1a2e740ab2ed2fbe237b3f142255fbd8ebae905a957d942"
name = "knative.dev/pkg" name = "knative.dev/pkg"
packages = [ packages = [
"apis", "apis",
@ -950,7 +950,7 @@
"metrics/metricskey", "metrics/metricskey",
] ]
pruneopts = "T" pruneopts = "T"
revision = "587055b113b227ec89894f3907c960e3a9e1f85a" revision = "169ef0797c1f7e548574e6aee289002c0f22dc0a"
[[projects]] [[projects]]
branch = "master" branch = "master"
@ -961,7 +961,7 @@
"tools/dep-collector", "tools/dep-collector",
] ]
pruneopts = "UT" pruneopts = "UT"
revision = "935a8f052a483d4a1b1bebe2c80235d6867a8d91" revision = "c6031e2873d748338362bccaab46d2d347329d58"
[[projects]] [[projects]]
digest = "1:8730e0150dfb2b7e173890c8b9868e7a273082ef8e39f4940e3506a481cf895c" digest = "1:8730e0150dfb2b7e173890c8b9868e7a273082ef8e39f4940e3506a481cf895c"

16
vendor/knative.dev/pkg/Gopkg.lock generated vendored
View File

@ -721,16 +721,15 @@
revision = "8b927904ee0dec805c89aaf9172f4459296ed6e8" revision = "8b927904ee0dec805c89aaf9172f4459296ed6e8"
[[projects]] [[projects]]
branch = "master" digest = "1:081608ceb454c46b54d24b7561e5744088f3ff69478b23f50277ec83bd8636b0"
digest = "1:48871545d029f0561819b6f761e11ed3111e79f29f7f1ba36e2e428e05ceaa9d"
name = "google.golang.org/api" name = "google.golang.org/api"
packages = [ packages = [
"container/v1beta1", "container/v1beta1",
"gensupport",
"googleapi", "googleapi",
"googleapi/internal/uritemplates",
"googleapi/transport", "googleapi/transport",
"internal", "internal",
"internal/gensupport",
"internal/third_party/uritemplates",
"iterator", "iterator",
"option", "option",
"storage/v1", "storage/v1",
@ -741,7 +740,8 @@
"transport/http/internal/propagation", "transport/http/internal/propagation",
] ]
pruneopts = "NUT" pruneopts = "NUT"
revision = "aa15faf3c8a1cffc77fc3dabe95703bb12c5f6a9" revision = "aa5d4e47691e7ae1aebb5221ff8e4beea23fad72"
version = "v0.15.0"
[[projects]] [[projects]]
digest = "1:a955e7c44c2be14b61aa2ddda744edfdfbc6817e993703a16e303c277ba84449" digest = "1:a955e7c44c2be14b61aa2ddda744edfdfbc6817e993703a16e303c277ba84449"
@ -1243,15 +1243,17 @@
[[projects]] [[projects]]
branch = "master" branch = "master"
digest = "1:df1c1cf6d2c9ca0781705ef095cb15e06f777cddb493775aad41b72f79867d7a" digest = "1:85d1708cf70b4fa56e184b16a5af5350945f3239978529719f4a53cbcd67ca2a"
name = "k8s.io/test-infra" name = "k8s.io/test-infra"
packages = [ packages = [
"boskos/client", "boskos/client",
"boskos/common", "boskos/common",
"boskos/storage", "boskos/storage",
"prow/config/secret",
"prow/logrusutil",
] ]
pruneopts = "NUT" pruneopts = "NUT"
revision = "356470ae778d26af50f27ff8673434bf5cf73c07" revision = "70b0b49fe2476f06f97272e77f47ba432cb54244"
[[projects]] [[projects]]
branch = "master" branch = "master"

View File

@ -121,6 +121,10 @@ Tests importing [`knative.dev/pkg/test`](#test-library) recognize these flags:
- [`--cluster`](#specifying-cluster) - [`--cluster`](#specifying-cluster)
- [`--namespace`](#specifying-namespace) - [`--namespace`](#specifying-namespace)
- [`--logverbose`](#output-verbose-logs) - [`--logverbose`](#output-verbose-logs)
- [`--ingressendpoint`](#specifying-ingress-endpoint)
- [`--dockerrepo`](#specifying-docker-repo)
- [`--tag`](#specifying-tag)
- [`--imagetemplate`](#specifying-image-template)
### Specifying kubeconfig ### Specifying kubeconfig
@ -178,6 +182,34 @@ The `--logverbose` argument lets you see verbose test logs and k8s logs.
go test ./test --logverbose go test ./test --logverbose
``` ```
### Specifying docker repo
The `--dockerrepo` argument lets you specify a uri of the docker repo where you
have uploaded the test image to using `uploadtestimage.sh`. Defaults to
`$KO_DOCKER_REPO`
```bash
go test ./test --dockerrepo myspecialdockerrepo
```
### Specifying tag
The `--tag` argument lets you specify the version tag for the test images.
```bash
go test ./test --tag v1.0
```
### Specifying image template
The `--imagetemplate` argument lets you specify a template to generate the
reference to an image from the test. Defaults to
`{{.Repository}}/{{.Name}}:{{.Tag}}`
```bash
go test ./test --imagetemplate {{.Repository}}/{{.Name}}:{{.Tag}}
```
--- ---
Except as otherwise noted, the content of this page is licensed under the Except as otherwise noted, the content of this page is licensed under the

View File

@ -32,6 +32,11 @@ type Request struct {
// GKEVersion: GKE version of the cluster, default to be latest if not provided // GKEVersion: GKE version of the cluster, default to be latest if not provided
GKEVersion string GKEVersion string
// ReleaseChannel: GKE release channel. Only one of GKEVersion or ReleaseChannel can be
// specified at a time.
// https://cloud.google.com/kubernetes-engine/docs/concepts/release-channels
ReleaseChannel string
// ClusterName: name of the cluster // ClusterName: name of the cluster
ClusterName string ClusterName string
@ -63,6 +68,7 @@ func (r *Request) DeepCopy() *Request {
return &Request{ return &Request{
Project: r.Project, Project: r.Project,
GKEVersion: r.GKEVersion, GKEVersion: r.GKEVersion,
ReleaseChannel: r.ReleaseChannel,
ClusterName: r.ClusterName, ClusterName: r.ClusterName,
MinNodes: r.MinNodes, MinNodes: r.MinNodes,
MaxNodes: r.MaxNodes, MaxNodes: r.MaxNodes,
@ -91,9 +97,8 @@ func NewCreateClusterRequest(request *Request) (*container.CreateClusterRequest,
if request.EnableWorkloadIdentity && request.Project == "" { if request.EnableWorkloadIdentity && request.Project == "" {
return nil, errors.New("project cannot be empty if you want Workload Identity") return nil, errors.New("project cannot be empty if you want Workload Identity")
} }
if request.GKEVersion != "" && request.ReleaseChannel != "" {
if request.GKEVersion == "" { return nil, errors.New("can only specify one of GKE version or release channel (not both)")
request.GKEVersion = defaultGKEVersion
} }
ccr := &container.CreateClusterRequest{ ccr := &container.CreateClusterRequest{
@ -113,9 +118,6 @@ func NewCreateClusterRequest(request *Request) (*container.CreateClusterRequest,
}, },
}, },
Name: request.ClusterName, Name: request.ClusterName,
// The default cluster version is not latest, has to explicitly
// set it as "latest"
InitialClusterVersion: request.GKEVersion,
// Installing addons after cluster creation takes at least 5 // Installing addons after cluster creation takes at least 5
// minutes, so install addons as part of cluster creation, which // minutes, so install addons as part of cluster creation, which
// doesn't seem to add much time on top of cluster creation // doesn't seem to add much time on top of cluster creation
@ -135,5 +137,16 @@ func NewCreateClusterRequest(request *Request) (*container.CreateClusterRequest,
IdentityNamespace: request.Project + ".svc.id.goog", IdentityNamespace: request.Project + ".svc.id.goog",
} }
} }
// Manage the GKE cluster version. Only one of initial cluster version or release channel can be specified.
if request.ReleaseChannel != "" {
ccr.Cluster.ReleaseChannel = &container.ReleaseChannel{Channel: request.ReleaseChannel}
} else if request.GKEVersion != "" {
ccr.Cluster.InitialClusterVersion = request.GKEVersion
} else {
// The default cluster version is not latest, has to explicitly
// set it as "latest"
ccr.Cluster.InitialClusterVersion = defaultGKEVersion
}
return ccr, nil return ccr, nil
} }

View File

@ -37,30 +37,43 @@ var (
defaultWaitDuration = time.Minute * 20 defaultWaitDuration = time.Minute * 20
) )
// Operation defines actions for handling GKE resources
type Operation interface { type Operation interface {
AcquireGKEProject(*string, string) (*boskoscommon.Resource, error) AcquireGKEProject(string) (*boskoscommon.Resource, error)
ReleaseGKEProject(*string, string) error ReleaseGKEProject(string) error
} }
// Client a wrapper around k8s boskos client that implements Operation
type Client struct { type Client struct {
*boskosclient.Client *boskosclient.Client
} }
func newClient(host *string) *boskosclient.Client { // NewClient creates a boskos Client with GKE operation. The owner of any resources acquired
if host == nil { // by this client is the same as the host name. `user` and `pass` are used for basic
hostName := common.GetOSEnv("JOB_NAME") // authentication for boskos client where pass is a password file. `user` and `pass` fields
host = &hostName // are passed directly to k8s boskos client. Refer to
// [k8s boskos](https://github.com/kubernetes/test-infra/tree/master/boskos) for more details.
// If host is "", it looks up JOB_NAME environment variable and set it to be the host name.
func NewClient(host string, user string, pass string) (*Client, error) {
if host == "" {
host = common.GetOSEnv("JOB_NAME")
} }
return boskosclient.NewClient(*host, boskosURI)
c, err := boskosclient.NewClient(host, boskosURI, user, pass)
if err != nil {
return nil, err
}
return &Client{c}, nil
} }
// AcquireGKEProject acquires GKE Boskos Project with "free" state, and not // AcquireGKEProject acquires GKE Boskos Project with "free" state, and not
// owned by anyone, sets its state to "busy" and assign it an owner of *host, // owned by anyone, sets its state to "busy" and assign it an owner of *host,
// which by default is env var `JOB_NAME`. // which by default is env var `JOB_NAME`.
func (c *Client) AcquireGKEProject(host *string, resType string) (*boskoscommon.Resource, error) { func (c *Client) AcquireGKEProject(resType string) (*boskoscommon.Resource, error) {
ctx, cancel := context.WithTimeout(context.Background(), defaultWaitDuration) ctx, cancel := context.WithTimeout(context.Background(), defaultWaitDuration)
defer cancel() defer cancel()
p, err := newClient(host).AcquireWait(ctx, resType, boskoscommon.Free, boskoscommon.Busy) p, err := c.AcquireWait(ctx, resType, boskoscommon.Free, boskoscommon.Busy)
if err != nil { if err != nil {
return nil, fmt.Errorf("boskos failed to acquire GKE project: %v", err) return nil, fmt.Errorf("boskos failed to acquire GKE project: %v", err)
} }
@ -75,9 +88,8 @@ func (c *Client) AcquireGKEProject(host *string, resType string) (*boskoscommon.
// "dirty" for Janitor picking up. // "dirty" for Janitor picking up.
// This function is very powerful, it can release Boskos resource acquired by // This function is very powerful, it can release Boskos resource acquired by
// other processes, regardless of where the other process is running. // other processes, regardless of where the other process is running.
func (c *Client) ReleaseGKEProject(host *string, name string) error { func (c *Client) ReleaseGKEProject(name string) error {
client := newClient(host) if err := c.Release(name, boskoscommon.Dirty); err != nil {
if err := client.Release(name, boskoscommon.Dirty); err != nil {
return fmt.Errorf("boskos failed to release GKE project '%s': %v", name, err) return fmt.Errorf("boskos failed to release GKE project '%s': %v", name, err)
} }
return nil return nil

View File

@ -44,11 +44,11 @@ func (c *FakeBoskosClient) GetResources() []*boskoscommon.Resource {
} }
// AcquireGKEProject fakes to be no op // AcquireGKEProject fakes to be no op
func (c *FakeBoskosClient) AcquireGKEProject(host *string, resType string) (*boskoscommon.Resource, error) { func (c *FakeBoskosClient) AcquireGKEProject(resType string) (*boskoscommon.Resource, error) {
for _, res := range c.resources { for _, res := range c.resources {
if res.State == boskoscommon.Free { if res.State == boskoscommon.Free {
res.State = boskoscommon.Busy res.State = boskoscommon.Busy
res.Owner = c.getOwner(host) res.Owner = c.getOwner(nil)
res.Type = resType res.Type = resType
return res, nil return res, nil
} }
@ -57,8 +57,8 @@ func (c *FakeBoskosClient) AcquireGKEProject(host *string, resType string) (*bos
} }
// ReleaseGKEProject fakes to be no op // ReleaseGKEProject fakes to be no op
func (c *FakeBoskosClient) ReleaseGKEProject(host *string, name string) error { func (c *FakeBoskosClient) ReleaseGKEProject(name string) error {
owner := c.getOwner(host) owner := c.getOwner(nil)
for _, res := range c.resources { for _, res := range c.resources {
if res.Name == name { if res.Name == name {
if res.Owner == owner { if res.Owner == owner {

View File

@ -135,11 +135,16 @@ func (gs *GKEClient) Setup(r GKERequest) ClusterOperations {
client, err := gke.NewSDKClient() client, err := gke.NewSDKClient()
if err != nil { if err != nil {
log.Fatalf("failed to create GKE SDK client: '%v'", err) log.Fatalf("Failed to create GKE SDK client: '%v'", err)
} }
gc.operations = client gc.operations = client
gc.boskosOps = &boskos.Client{} gc.boskosOps, err = boskos.NewClient("", /* boskos owner */
"", /* boskos user */
"" /* boskos password file */)
if err != nil {
log.Fatalf("Failed to create boskos client: '%v", err)
}
return gc return gc
} }
@ -176,7 +181,7 @@ func (gc *GKECluster) Acquire() error {
// Get project name from boskos if running in Prow, otherwise it should fail // Get project name from boskos if running in Prow, otherwise it should fail
// since we don't know which project to use // since we don't know which project to use
if common.IsProw() { if common.IsProw() {
project, err := gc.boskosOps.AcquireGKEProject(nil, gc.Request.ResourceType) project, err := gc.boskosOps.AcquireGKEProject(gc.Request.ResourceType)
if err != nil { if err != nil {
return fmt.Errorf("failed acquiring boskos project: '%v'", err) return fmt.Errorf("failed acquiring boskos project: '%v'", err)
} }
@ -264,7 +269,7 @@ func (gc *GKECluster) Delete() error {
// clusters deleting // clusters deleting
if common.IsProw() { if common.IsProw() {
log.Printf("Releasing Boskos resource: '%v'", gc.Project) log.Printf("Releasing Boskos resource: '%v'", gc.Project)
return gc.boskosOps.ReleaseGKEProject(nil, gc.Project) return gc.boskosOps.ReleaseGKEProject(gc.Project)
} }
// NeedsCleanup is only true if running locally and cluster created by the // NeedsCleanup is only true if running locally and cluster created by the

View File

@ -55,6 +55,7 @@ func (rw *RequestWrapper) addOptions() {
flag.StringVar(&rw.Request.Zone, "zone", "", "GCP zone") flag.StringVar(&rw.Request.Zone, "zone", "", "GCP zone")
flag.StringVar(&rw.Request.Project, "project", "", "GCP project") flag.StringVar(&rw.Request.Project, "project", "", "GCP project")
flag.StringVar(&rw.Request.ClusterName, "name", "", "cluster name") flag.StringVar(&rw.Request.ClusterName, "name", "", "cluster name")
flag.StringVar(&rw.Request.ReleaseChannel, "release-channel", "", "GKE release channel")
flag.StringVar(&rw.Request.ResourceType, "resource-type", "", "Boskos Resource Type") flag.StringVar(&rw.Request.ResourceType, "resource-type", "", "Boskos Resource Type")
flag.StringVar(&rw.BackupRegionsStr, "backup-regions", "", "GCP regions as backup, separated by comma") flag.StringVar(&rw.BackupRegionsStr, "backup-regions", "", "GCP regions as backup, separated by comma")
flag.StringVar(&rw.AddonsStr, "addons", "", "addons to be added, separated by comma") flag.StringVar(&rw.AddonsStr, "addons", "", "addons to be added, separated by comma")