Skip to content

Commit

Permalink
Auto-update dependencies (knative#6419)
Browse files Browse the repository at this point in the history
Produced via:
  `dep ensure -update knative.dev/test-infra knative.dev/pkg knative.dev/caching`
/assign vagababov
/cc vagababov
  • Loading branch information
mattmoor authored and knative-prow-robot committed Jan 3, 2020
1 parent 9e63b4d commit e5aaca3
Show file tree
Hide file tree
Showing 9 changed files with 80 additions and 43 deletions.
10 changes: 5 additions & 5 deletions Gopkg.lock

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

4 changes: 2 additions & 2 deletions vendor/knative.dev/caching/Gopkg.lock

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

16 changes: 9 additions & 7 deletions vendor/knative.dev/pkg/Gopkg.lock

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

10 changes: 7 additions & 3 deletions vendor/knative.dev/pkg/test/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -184,8 +184,9 @@ 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`
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
Expand All @@ -194,14 +195,17 @@ 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}}`
reference to an image from the test. Defaults to
`{{.Repository}}/{{.Name}}:{{.Tag}}`

```bash
go test ./test --imagetemplate {{.Repository}}/{{.Name}}:{{.Tag}}
```
Expand Down
25 changes: 19 additions & 6 deletions vendor/knative.dev/pkg/test/gke/request.go
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,11 @@ type Request struct {
// GKEVersion: GKE version of the cluster, default to be latest if not provided
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 string

Expand Down Expand Up @@ -63,6 +68,7 @@ func (r *Request) DeepCopy() *Request {
return &Request{
Project: r.Project,
GKEVersion: r.GKEVersion,
ReleaseChannel: r.ReleaseChannel,
ClusterName: r.ClusterName,
MinNodes: r.MinNodes,
MaxNodes: r.MaxNodes,
Expand Down Expand Up @@ -91,9 +97,8 @@ func NewCreateClusterRequest(request *Request) (*container.CreateClusterRequest,
if request.EnableWorkloadIdentity && request.Project == "" {
return nil, errors.New("project cannot be empty if you want Workload Identity")
}

if request.GKEVersion == "" {
request.GKEVersion = defaultGKEVersion
if request.GKEVersion != "" && request.ReleaseChannel != "" {
return nil, errors.New("can only specify one of GKE version or release channel (not both)")
}

ccr := &container.CreateClusterRequest{
Expand All @@ -113,9 +118,6 @@ func NewCreateClusterRequest(request *Request) (*container.CreateClusterRequest,
},
},
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
// minutes, so install addons as part of cluster creation, which
// doesn't seem to add much time on top of cluster creation
Expand All @@ -135,5 +137,16 @@ func NewCreateClusterRequest(request *Request) (*container.CreateClusterRequest,
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
}
Original file line number Diff line number Diff line change
Expand Up @@ -37,30 +37,43 @@ var (
defaultWaitDuration = time.Minute * 20
)

// Operation defines actions for handling GKE resources
type Operation interface {
AcquireGKEProject(*string, string) (*boskoscommon.Resource, error)
ReleaseGKEProject(*string, string) error
AcquireGKEProject(string) (*boskoscommon.Resource, error)
ReleaseGKEProject(string) error
}

// Client a wrapper around k8s boskos client that implements Operation
type Client struct {
*boskosclient.Client
}

func newClient(host *string) *boskosclient.Client {
if host == nil {
hostName := common.GetOSEnv("JOB_NAME")
host = &hostName
// NewClient creates a boskos Client with GKE operation. The owner of any resources acquired
// by this client is the same as the host name. `user` and `pass` are used for basic
// authentication for boskos client where pass is a password file. `user` and `pass` fields
// 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
// owned by anyone, sets its state to "busy" and assign it an owner of *host,
// 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)
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 {
return nil, fmt.Errorf("boskos failed to acquire GKE project: %v", err)
}
Expand All @@ -75,9 +88,8 @@ func (c *Client) AcquireGKEProject(host *string, resType string) (*boskoscommon.
// "dirty" for Janitor picking up.
// This function is very powerful, it can release Boskos resource acquired by
// other processes, regardless of where the other process is running.
func (c *Client) ReleaseGKEProject(host *string, name string) error {
client := newClient(host)
if err := client.Release(name, boskoscommon.Dirty); err != nil {
func (c *Client) ReleaseGKEProject(name string) error {
if err := c.Release(name, boskoscommon.Dirty); err != nil {
return fmt.Errorf("boskos failed to release GKE project '%s': %v", name, err)
}
return nil
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -44,11 +44,11 @@ func (c *FakeBoskosClient) GetResources() []*boskoscommon.Resource {
}

// 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 {
if res.State == boskoscommon.Free {
res.State = boskoscommon.Busy
res.Owner = c.getOwner(host)
res.Owner = c.getOwner(nil)
res.Type = resType
return res, nil
}
Expand All @@ -57,8 +57,8 @@ func (c *FakeBoskosClient) AcquireGKEProject(host *string, resType string) (*bos
}

// ReleaseGKEProject fakes to be no op
func (c *FakeBoskosClient) ReleaseGKEProject(host *string, name string) error {
owner := c.getOwner(host)
func (c *FakeBoskosClient) ReleaseGKEProject(name string) error {
owner := c.getOwner(nil)
for _, res := range c.resources {
if res.Name == name {
if res.Owner == owner {
Expand Down
13 changes: 9 additions & 4 deletions vendor/knative.dev/pkg/testutils/clustermanager/e2e-tests/gke.go
Original file line number Diff line number Diff line change
Expand Up @@ -135,11 +135,16 @@ func (gs *GKEClient) Setup(r GKERequest) ClusterOperations {

client, err := gke.NewSDKClient()
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.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
}
Expand Down Expand Up @@ -176,7 +181,7 @@ func (gc *GKECluster) Acquire() error {
// Get project name from boskos if running in Prow, otherwise it should fail
// since we don't know which project to use
if common.IsProw() {
project, err := gc.boskosOps.AcquireGKEProject(nil, gc.Request.ResourceType)
project, err := gc.boskosOps.AcquireGKEProject(gc.Request.ResourceType)
if err != nil {
return fmt.Errorf("failed acquiring boskos project: '%v'", err)
}
Expand Down Expand Up @@ -264,7 +269,7 @@ func (gc *GKECluster) Delete() error {
// clusters deleting
if common.IsProw() {
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
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,7 @@ func (rw *RequestWrapper) addOptions() {
flag.StringVar(&rw.Request.Zone, "zone", "", "GCP zone")
flag.StringVar(&rw.Request.Project, "project", "", "GCP project")
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.BackupRegionsStr, "backup-regions", "", "GCP regions as backup, separated by comma")
flag.StringVar(&rw.AddonsStr, "addons", "", "addons to be added, separated by comma")
Expand Down

0 comments on commit e5aaca3

Please sign in to comment.