mirror of https://github.com/knative/caching.git
Auto-update dependencies (#99)
Produced via: `dep ensure -update knative.dev/test-infra knative.dev/pkg` /assign mattmoor
This commit is contained in:
parent
21bff291f8
commit
6185837d36
|
@ -927,7 +927,7 @@
|
||||||
|
|
||||||
[[projects]]
|
[[projects]]
|
||||||
branch = "master"
|
branch = "master"
|
||||||
digest = "1:dfd153fff295bf8023d8f9eca57d4c3fd76790619093b1e6d216810b82fed7a2"
|
digest = "1:bdd1f7aa0a13b578d332f970e36861a834ff8559e06b0b718fa5d8df78e448d8"
|
||||||
name = "knative.dev/pkg"
|
name = "knative.dev/pkg"
|
||||||
packages = [
|
packages = [
|
||||||
"apis",
|
"apis",
|
||||||
|
@ -946,7 +946,7 @@
|
||||||
"metrics/metricskey",
|
"metrics/metricskey",
|
||||||
]
|
]
|
||||||
pruneopts = "T"
|
pruneopts = "T"
|
||||||
revision = "87ad483365174cda3ee83f1c0832df930f9adb52"
|
revision = "34157973944a3419f1e38fce8dfb11a2fb5aadbb"
|
||||||
|
|
||||||
[[projects]]
|
[[projects]]
|
||||||
branch = "master"
|
branch = "master"
|
||||||
|
@ -957,7 +957,7 @@
|
||||||
"tools/dep-collector",
|
"tools/dep-collector",
|
||||||
]
|
]
|
||||||
pruneopts = "UT"
|
pruneopts = "UT"
|
||||||
revision = "816123d5e71fb88533d1564c331443387967e1dc"
|
revision = "ca04b8453a8779f3c800c5e4bcda43ff53ec6f80"
|
||||||
|
|
||||||
[solve-meta]
|
[solve-meta]
|
||||||
analyzer-name = "dep"
|
analyzer-name = "dep"
|
||||||
|
|
|
@ -312,13 +312,13 @@ func ErrDisallowedUpdateDeprecatedFields(fieldPaths ...string) *FieldError {
|
||||||
}
|
}
|
||||||
|
|
||||||
// ErrInvalidArrayValue constructs a FieldError for a repetetive `field`
|
// ErrInvalidArrayValue constructs a FieldError for a repetetive `field`
|
||||||
// at `index` that has received an invalid string value.
|
// at `index` that has received an invalid value.
|
||||||
func ErrInvalidArrayValue(value interface{}, field string, index int) *FieldError {
|
func ErrInvalidArrayValue(value interface{}, field string, index int) *FieldError {
|
||||||
return ErrInvalidValue(value, CurrentField).ViaFieldIndex(field, index)
|
return ErrInvalidValue(value, CurrentField).ViaFieldIndex(field, index)
|
||||||
}
|
}
|
||||||
|
|
||||||
// ErrInvalidValue constructs a FieldError for a field that has received an
|
// ErrInvalidValue constructs a FieldError for a field that has received an
|
||||||
// invalid string value.
|
// invalid value.
|
||||||
func ErrInvalidValue(value interface{}, fieldPath string) *FieldError {
|
func ErrInvalidValue(value interface{}, fieldPath string) *FieldError {
|
||||||
return &FieldError{
|
return &FieldError{
|
||||||
Message: fmt.Sprintf("invalid value: %v", value),
|
Message: fmt.Sprintf("invalid value: %v", value),
|
||||||
|
@ -326,6 +326,15 @@ func ErrInvalidValue(value interface{}, fieldPath string) *FieldError {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// ErrGeneric constructs a FieldError to allow for the different error strings for the
|
||||||
|
// the different cases.
|
||||||
|
func ErrGeneric(diagnostic string, fieldPaths ...string) *FieldError {
|
||||||
|
return &FieldError{
|
||||||
|
Message: diagnostic,
|
||||||
|
Paths: fieldPaths,
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
// ErrMissingOneOf is a variadic helper method for constructing a FieldError for
|
// ErrMissingOneOf is a variadic helper method for constructing a FieldError for
|
||||||
// not having at least one field in a mutually exclusive field group.
|
// not having at least one field in a mutually exclusive field group.
|
||||||
func ErrMissingOneOf(fieldPaths ...string) *FieldError {
|
func ErrMissingOneOf(fieldPaths ...string) *FieldError {
|
||||||
|
|
|
@ -18,9 +18,10 @@ package source
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"context"
|
"context"
|
||||||
|
"strconv"
|
||||||
|
|
||||||
"go.opencensus.io/stats/view"
|
"go.opencensus.io/stats/view"
|
||||||
"knative.dev/pkg/metrics"
|
"knative.dev/pkg/metrics"
|
||||||
"strconv"
|
|
||||||
|
|
||||||
"go.opencensus.io/stats"
|
"go.opencensus.io/stats"
|
||||||
"go.opencensus.io/tag"
|
"go.opencensus.io/tag"
|
||||||
|
|
|
@ -254,12 +254,11 @@ func (sc *SpoofingClient) logZipkinTrace(spoofResp *Response) {
|
||||||
traceID := spoofResp.Header.Get(zipkin.ZipkinTraceIDHeader)
|
traceID := spoofResp.Header.Get(zipkin.ZipkinTraceIDHeader)
|
||||||
sc.logf("Logging Zipkin Trace for: %s", traceID)
|
sc.logf("Logging Zipkin Trace for: %s", traceID)
|
||||||
|
|
||||||
// Sleep to ensure all traces are correctly pushed on the backend.
|
json, err := zipkin.JSONTrace(traceID, /* We don't know the expected number of spans */ -1, 5 * time.Second)
|
||||||
time.Sleep(5 * time.Second)
|
|
||||||
|
|
||||||
json, err := zipkin.JSONTrace(traceID)
|
|
||||||
if err != nil {
|
if err != nil {
|
||||||
sc.logf("Error getting zipkin trace: %v", err)
|
if _, ok := err.(*zipkin.TimeoutError); !ok {
|
||||||
|
sc.logf("Error getting zipkin trace: %v", err)
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
sc.logf("%s", json)
|
sc.logf("%s", json)
|
||||||
|
|
|
@ -40,5 +40,6 @@ Coverage Percentage: <Percentage value of coverage>
|
||||||
|
|
||||||
`GetCoveragePercentageXMLDisplay()` is a utility method that can be used by
|
`GetCoveragePercentageXMLDisplay()` is a utility method that can be used by
|
||||||
repos to produce coverage percentage for each resource in a Junit XML results
|
repos to produce coverage percentage for each resource in a Junit XML results
|
||||||
file. The method takes [CoveragePercentages](../coveragecalculator/calculator.go)
|
file. The method takes
|
||||||
as input and produces a Junit result file format.
|
[CoveragePercentages](../coveragecalculator/calculator.go) as input and produces
|
||||||
|
a Junit result file format.
|
||||||
|
|
|
@ -14,17 +14,18 @@ See the License for the specific language governing permissions and
|
||||||
limitations under the License.
|
limitations under the License.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
//util has constants and helper methods useful for zipkin tracing support.
|
// util has constants and helper methods useful for zipkin tracing support.
|
||||||
|
|
||||||
package zipkin
|
package zipkin
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"bytes"
|
|
||||||
"encoding/json"
|
"encoding/json"
|
||||||
"io/ioutil"
|
"io/ioutil"
|
||||||
"net/http"
|
"net/http"
|
||||||
"sync"
|
"sync"
|
||||||
|
"time"
|
||||||
|
|
||||||
|
"github.com/openzipkin/zipkin-go/model"
|
||||||
"go.opencensus.io/trace"
|
"go.opencensus.io/trace"
|
||||||
"k8s.io/client-go/kubernetes"
|
"k8s.io/client-go/kubernetes"
|
||||||
"knative.dev/pkg/test/logging"
|
"knative.dev/pkg/test/logging"
|
||||||
|
@ -32,7 +33,7 @@ import (
|
||||||
)
|
)
|
||||||
|
|
||||||
const (
|
const (
|
||||||
//ZipkinTraceIDHeader HTTP response header key to be used to store Zipkin Trace ID.
|
// ZipkinTraceIDHeader HTTP response header key to be used to store Zipkin Trace ID.
|
||||||
ZipkinTraceIDHeader = "ZIPKIN_TRACE_ID"
|
ZipkinTraceIDHeader = "ZIPKIN_TRACE_ID"
|
||||||
|
|
||||||
// ZipkinPort is port exposed by the Zipkin Pod
|
// ZipkinPort is port exposed by the Zipkin Pod
|
||||||
|
@ -43,11 +44,11 @@ const (
|
||||||
ZipkinTraceEndpoint = "http://localhost:9411/api/v2/trace/"
|
ZipkinTraceEndpoint = "http://localhost:9411/api/v2/trace/"
|
||||||
|
|
||||||
// App is the name of this component.
|
// App is the name of this component.
|
||||||
// This will be used as a label selector
|
// This will be used as a label selector.
|
||||||
app = "zipkin"
|
app = "zipkin"
|
||||||
|
|
||||||
// Namespace we are using for istio components
|
// istioNS is the namespace we are using for istio components.
|
||||||
istioNs = "istio-system"
|
istioNS = "istio-system"
|
||||||
)
|
)
|
||||||
|
|
||||||
var (
|
var (
|
||||||
|
@ -66,21 +67,21 @@ var (
|
||||||
// SetupZipkinTracing sets up zipkin tracing which involves:
|
// SetupZipkinTracing sets up zipkin tracing which involves:
|
||||||
// 1. Setting up port-forwarding from localhost to zipkin pod on the cluster
|
// 1. Setting up port-forwarding from localhost to zipkin pod on the cluster
|
||||||
// (pid of the process doing Port-Forward is stored in a global variable).
|
// (pid of the process doing Port-Forward is stored in a global variable).
|
||||||
// 2. Enable AlwaysSample config for tracing.
|
// 2. Enable AlwaysSample config for tracing for the SpoofingClient.
|
||||||
func SetupZipkinTracing(kubeClientset *kubernetes.Clientset, logf logging.FormatLogger) {
|
func SetupZipkinTracing(kubeClientset *kubernetes.Clientset, logf logging.FormatLogger) bool {
|
||||||
setupOnce.Do(func() {
|
setupOnce.Do(func() {
|
||||||
if err := monitoring.CheckPortAvailability(ZipkinPort); err != nil {
|
if err := monitoring.CheckPortAvailability(ZipkinPort); err != nil {
|
||||||
logf("Zipkin port not available on the machine: %v", err)
|
logf("Zipkin port not available on the machine: %v", err)
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
zipkinPods, err := monitoring.GetPods(kubeClientset, app, istioNs)
|
zipkinPods, err := monitoring.GetPods(kubeClientset, app, istioNS)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
logf("Error retrieving Zipkin pod details: %v", err)
|
logf("Error retrieving Zipkin pod details: %v", err)
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
zipkinPortForwardPID, err = monitoring.PortForward(logf, zipkinPods, ZipkinPort, ZipkinPort, istioNs)
|
zipkinPortForwardPID, err = monitoring.PortForward(logf, zipkinPods, ZipkinPort, ZipkinPort, istioNS)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
logf("Error starting kubectl port-forward command: %v", err)
|
logf("Error starting kubectl port-forward command: %v", err)
|
||||||
return
|
return
|
||||||
|
@ -93,17 +94,31 @@ func SetupZipkinTracing(kubeClientset *kubernetes.Clientset, logf logging.Format
|
||||||
logf("Successfully setup SpoofingClient for Zipkin Tracing")
|
logf("Successfully setup SpoofingClient for Zipkin Tracing")
|
||||||
ZipkinTracingEnabled = true
|
ZipkinTracingEnabled = true
|
||||||
})
|
})
|
||||||
|
return ZipkinTracingEnabled
|
||||||
}
|
}
|
||||||
|
|
||||||
// CleanupZipkinTracingSetup cleans up the Zipkin tracing setup on the machine. This involves killing the process performing port-forward.
|
// CleanupZipkinTracingSetup cleans up the Zipkin tracing setup on the machine. This involves killing the process performing port-forward.
|
||||||
|
// This should be called exactly once in TestMain. Likely in the form:
|
||||||
|
//
|
||||||
|
// func TestMain(m *testing.M) {
|
||||||
|
// os.Exit(func() int {
|
||||||
|
// // Any setup required for the tests.
|
||||||
|
// defer zipkin.CleanupZipkinTracingSetup(logger)
|
||||||
|
// return m.Run()
|
||||||
|
// }())
|
||||||
|
// }
|
||||||
func CleanupZipkinTracingSetup(logf logging.FormatLogger) {
|
func CleanupZipkinTracingSetup(logf logging.FormatLogger) {
|
||||||
teardownOnce.Do(func() {
|
teardownOnce.Do(func() {
|
||||||
|
// Because CleanupZipkinTracingSetup only runs once, make sure that now that it has been
|
||||||
|
// run, SetupZipkinTracing will no longer setup any port forwarding.
|
||||||
|
setupOnce.Do(func() {})
|
||||||
|
|
||||||
if !ZipkinTracingEnabled {
|
if !ZipkinTracingEnabled {
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
if err := monitoring.Cleanup(zipkinPortForwardPID); err != nil {
|
if err := monitoring.Cleanup(zipkinPortForwardPID); err != nil {
|
||||||
logf("Encountered error killing port-forward process in CleanupZipkingTracingSetup() : %v", err)
|
logf("Encountered error killing port-forward process in CleanupZipkinTracingSetup() : %v", err)
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -117,29 +132,56 @@ func CheckZipkinPortAvailability() error {
|
||||||
return monitoring.CheckPortAvailability(ZipkinPort)
|
return monitoring.CheckPortAvailability(ZipkinPort)
|
||||||
}
|
}
|
||||||
|
|
||||||
// JSONTrace returns a trace for the given traceId in JSON format
|
// JSONTrace returns a trace for the given traceID. It will continually try to get the trace. If the
|
||||||
func JSONTrace(traceID string) (string, error) {
|
// trace it gets has the expected number of spans, then it will be returned. If not, it will try
|
||||||
|
// again. If it reaches timeout, then it returns everything it has so far with an error.
|
||||||
|
func JSONTrace(traceID string, expected int, timeout time.Duration) (trace []model.SpanModel, err error) {
|
||||||
|
t := time.After(timeout)
|
||||||
|
for ; len(trace) != expected; {
|
||||||
|
select {
|
||||||
|
case <-t:
|
||||||
|
return trace, &TimeoutError{}
|
||||||
|
default:
|
||||||
|
trace, err = jsonTrace(traceID)
|
||||||
|
if err != nil {
|
||||||
|
return trace, err
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return trace, nil
|
||||||
|
}
|
||||||
|
|
||||||
|
// TimeoutError is an error returned by JSONTrace if it times out before getting the expected number
|
||||||
|
// of traces.
|
||||||
|
type TimeoutError struct {}
|
||||||
|
func (*TimeoutError) Error() string {
|
||||||
|
return "timeout getting JSONTrace"
|
||||||
|
}
|
||||||
|
|
||||||
|
// jsonTrace gets a trace from Zipkin and returns it.
|
||||||
|
func jsonTrace(traceID string) ([]model.SpanModel, error) {
|
||||||
|
var empty []model.SpanModel
|
||||||
|
|
||||||
// Check if zipkin port forwarding is setup correctly
|
// Check if zipkin port forwarding is setup correctly
|
||||||
if err := CheckZipkinPortAvailability(); err == nil {
|
if err := CheckZipkinPortAvailability(); err == nil {
|
||||||
return "", err
|
return empty, err
|
||||||
}
|
}
|
||||||
|
|
||||||
resp, err := http.Get(ZipkinTraceEndpoint + traceID)
|
resp, err := http.Get(ZipkinTraceEndpoint + traceID)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return "", err
|
return empty, err
|
||||||
}
|
}
|
||||||
defer resp.Body.Close()
|
defer resp.Body.Close()
|
||||||
|
|
||||||
trace, err := ioutil.ReadAll(resp.Body)
|
body, err := ioutil.ReadAll(resp.Body)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return "", err
|
return empty, err
|
||||||
}
|
}
|
||||||
|
|
||||||
var prettyJSON bytes.Buffer
|
var models []model.SpanModel
|
||||||
err = json.Indent(&prettyJSON, trace, "", "\t")
|
err = json.Unmarshal(body, &models)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return "", err
|
return empty, err
|
||||||
}
|
}
|
||||||
|
return models, nil
|
||||||
return prettyJSON.String(), nil
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -37,6 +37,15 @@ var (
|
||||||
defaultWaitDuration = time.Minute * 20
|
defaultWaitDuration = time.Minute * 20
|
||||||
)
|
)
|
||||||
|
|
||||||
|
type Operation interface {
|
||||||
|
AcquireGKEProject(*string) (*boskoscommon.Resource, error)
|
||||||
|
ReleaseGKEProject(*string, string) error
|
||||||
|
}
|
||||||
|
|
||||||
|
type Client struct {
|
||||||
|
*boskosclient.Client
|
||||||
|
}
|
||||||
|
|
||||||
func newClient(host *string) *boskosclient.Client {
|
func newClient(host *string) *boskosclient.Client {
|
||||||
if nil == host {
|
if nil == host {
|
||||||
hostName := common.GetOSEnv("JOB_NAME")
|
hostName := common.GetOSEnv("JOB_NAME")
|
||||||
|
@ -48,7 +57,7 @@ func newClient(host *string) *boskosclient.Client {
|
||||||
// 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 AcquireGKEProject(host *string) (*boskoscommon.Resource, error) {
|
func (c *Client) AcquireGKEProject(host *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, GKEProjectResource, boskoscommon.Free, boskoscommon.Busy)
|
p, err := newClient(host).AcquireWait(ctx, GKEProjectResource, boskoscommon.Free, boskoscommon.Busy)
|
||||||
|
@ -66,7 +75,7 @@ func AcquireGKEProject(host *string) (*boskoscommon.Resource, error) {
|
||||||
// "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 ReleaseGKEProject(host *string, name string) error {
|
func (c *Client) ReleaseGKEProject(host *string, name string) error {
|
||||||
client := newClient(host)
|
client := newClient(host)
|
||||||
if err := client.Release(name, boskoscommon.Dirty); nil != err {
|
if err := client.Release(name, boskoscommon.Dirty); nil != err {
|
||||||
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)
|
||||||
|
|
|
@ -0,0 +1,69 @@
|
||||||
|
/*
|
||||||
|
Copyright 2019 The Knative 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 fake
|
||||||
|
|
||||||
|
import (
|
||||||
|
"fmt"
|
||||||
|
|
||||||
|
boskoscommon "k8s.io/test-infra/boskos/common"
|
||||||
|
"knative.dev/pkg/testutils/clustermanager/boskos"
|
||||||
|
)
|
||||||
|
|
||||||
|
// FakeBoskosClient implements boskos.Operation
|
||||||
|
type FakeBoskosClient struct {
|
||||||
|
resources []*boskoscommon.Resource
|
||||||
|
}
|
||||||
|
|
||||||
|
// AcquireGKEProject fakes to be no op
|
||||||
|
func (c *FakeBoskosClient) AcquireGKEProject(host *string) (*boskoscommon.Resource, error) {
|
||||||
|
for _, res := range c.resources {
|
||||||
|
if res.State == boskoscommon.Free {
|
||||||
|
res.State = boskoscommon.Busy
|
||||||
|
return res, nil
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return nil, fmt.Errorf("no GKE project available")
|
||||||
|
}
|
||||||
|
|
||||||
|
// ReleaseGKEProject fakes to be no op
|
||||||
|
func (c *FakeBoskosClient) ReleaseGKEProject(host *string, name string) error {
|
||||||
|
if nil == host {
|
||||||
|
return fmt.Errorf("host has to be set")
|
||||||
|
}
|
||||||
|
|
||||||
|
for _, res := range c.resources {
|
||||||
|
if res.Name == name {
|
||||||
|
if res.Owner == *host {
|
||||||
|
res.Owner = ""
|
||||||
|
res.State = boskoscommon.Free
|
||||||
|
return nil
|
||||||
|
} else {
|
||||||
|
return fmt.Errorf("Got owner: '%s', expect owner: '%s'", res.Owner, *host)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return fmt.Errorf("resource doesn't exist yet: '%s'", name)
|
||||||
|
}
|
||||||
|
|
||||||
|
// NewGKEProject adds Boskos resources for testing purpose
|
||||||
|
func (c *FakeBoskosClient) NewGKEProject(name string) {
|
||||||
|
c.resources = append(c.resources, &boskoscommon.Resource{
|
||||||
|
Type: boskos.GKEProjectResource,
|
||||||
|
Name: name,
|
||||||
|
State: boskoscommon.Free,
|
||||||
|
})
|
||||||
|
}
|
|
@ -71,6 +71,7 @@ type GKECluster struct {
|
||||||
NeedCleanup bool
|
NeedCleanup bool
|
||||||
Cluster *container.Cluster
|
Cluster *container.Cluster
|
||||||
operations GKESDKOperations
|
operations GKESDKOperations
|
||||||
|
boskosOps boskos.Operation
|
||||||
}
|
}
|
||||||
|
|
||||||
// GKESDKOperations wraps GKE SDK related functions
|
// GKESDKOperations wraps GKE SDK related functions
|
||||||
|
@ -152,12 +153,15 @@ func (gs *GKEClient) Setup(numNodes *int64, nodeType *string, region *string, zo
|
||||||
}
|
}
|
||||||
gc.operations = &GKESDKClient{containerService}
|
gc.operations = &GKESDKClient{containerService}
|
||||||
|
|
||||||
|
gc.boskosOps = &boskos.Client{}
|
||||||
|
|
||||||
return gc
|
return gc
|
||||||
}
|
}
|
||||||
|
|
||||||
// Initialize sets up GKE SDK client, checks environment for cluster and
|
// Initialize sets up GKE SDK client, checks environment for cluster and
|
||||||
// projects to decide whether use existing cluster/project or creating new ones.
|
// projects to decide whether use existing cluster/project or creating new ones.
|
||||||
func (gc *GKECluster) Initialize() error {
|
func (gc *GKECluster) Initialize() error {
|
||||||
|
// Try obtain project name via `kubectl`, `gcloud`
|
||||||
if nil == gc.Project {
|
if nil == gc.Project {
|
||||||
if err := gc.checkEnvironment(); nil != err {
|
if err := gc.checkEnvironment(); nil != err {
|
||||||
return fmt.Errorf("failed checking existing cluster: '%v'", err)
|
return fmt.Errorf("failed checking existing cluster: '%v'", err)
|
||||||
|
@ -165,14 +169,13 @@ func (gc *GKECluster) Initialize() error {
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if nil == gc.Cluster {
|
// Get project name from boskos if running in Prow
|
||||||
if common.IsProw() {
|
if nil == gc.Project && common.IsProw() {
|
||||||
project, err := boskos.AcquireGKEProject(nil)
|
project, err := gc.boskosOps.AcquireGKEProject(nil)
|
||||||
if nil != err {
|
if nil != err {
|
||||||
return fmt.Errorf("failed acquire boskos project: '%v'", err)
|
return fmt.Errorf("failed acquire boskos project: '%v'", err)
|
||||||
}
|
|
||||||
gc.Project = &project.Name
|
|
||||||
}
|
}
|
||||||
|
gc.Project = &project.Name
|
||||||
}
|
}
|
||||||
if nil == gc.Project || "" == *gc.Project {
|
if nil == gc.Project || "" == *gc.Project {
|
||||||
return errors.New("gcp project must be set")
|
return errors.New("gcp project must be set")
|
||||||
|
|
|
@ -9,7 +9,7 @@ import (
|
||||||
|
|
||||||
"contrib.go.opencensus.io/exporter/stackdriver"
|
"contrib.go.opencensus.io/exporter/stackdriver"
|
||||||
oczipkin "contrib.go.opencensus.io/exporter/zipkin"
|
oczipkin "contrib.go.opencensus.io/exporter/zipkin"
|
||||||
"github.com/openzipkin/zipkin-go"
|
zipkin "github.com/openzipkin/zipkin-go"
|
||||||
httpreporter "github.com/openzipkin/zipkin-go/reporter/http"
|
httpreporter "github.com/openzipkin/zipkin-go/reporter/http"
|
||||||
"go.opencensus.io/trace"
|
"go.opencensus.io/trace"
|
||||||
"go.uber.org/zap"
|
"go.uber.org/zap"
|
||||||
|
|
Loading…
Reference in New Issue