From 23d851fe41fdecff431477f41505aa983c98fa92 Mon Sep 17 00:00:00 2001 From: Valentyna Bukhalova Date: Wed, 18 Sep 2024 10:33:53 +0200 Subject: [PATCH] fix linters --- .golangci.yaml | 50 +++++- cmd/proxy/main.go | 8 +- e2e/Dockerfile | 4 - e2e/chart/.helmignore | 23 --- e2e/chart/Chart.yaml | 24 --- e2e/chart/templates/_helpers.tpl | 62 ------- e2e/chart/templates/job.yaml | 22 --- e2e/chart/templates/service.yaml | 15 -- e2e/chart/values.yaml | 5 - e2e/main.go | 61 ------- e2e/run.sh | 94 ---------- e2e/setup.go | 163 ------------------ .../castai/dummy/external_provisioner_mock.go | 5 +- internal/cloud/gcp/executor.go | 6 +- internal/cloud/gcp/gcpauth/client.go | 3 +- internal/config/config.go | 18 +- internal/config/config_test.go | 4 +- internal/e2etest/roundtripper.go | 16 +- internal/proxy/client.go | 23 ++- internal/proxy/client_test.go | 24 +-- proto/gen/proto/v1alpha/proxy.pb.go | 70 ++++---- proto/v1alpha/proxy.proto | 5 +- 22 files changed, 137 insertions(+), 568 deletions(-) delete mode 100644 e2e/Dockerfile delete mode 100644 e2e/chart/.helmignore delete mode 100644 e2e/chart/Chart.yaml delete mode 100644 e2e/chart/templates/_helpers.tpl delete mode 100644 e2e/chart/templates/job.yaml delete mode 100644 e2e/chart/templates/service.yaml delete mode 100644 e2e/chart/values.yaml delete mode 100644 e2e/main.go delete mode 100755 e2e/run.sh delete mode 100644 e2e/setup.go diff --git a/.golangci.yaml b/.golangci.yaml index 3078bec..18bfd1b 100644 --- a/.golangci.yaml +++ b/.golangci.yaml @@ -35,12 +35,60 @@ linters: - whitespace linters-settings: + gocritic: + enabled-all: true + disabled-checks: + - commentFormatting + godot: + scope: all + gofumpt: + extra-rules: true + goconst: + min-len: 2 + min-occurrences: 5 + golint: + min-confidence: 0 + gomnd: + settings: + mnd: + # don't include the "operation" and "assign" + checks: [argument,case,condition,return] + govet: + # shadow is marked as experimental feature, skip it for now. + check-shadowing: false + settings: + printf: + funcs: + - (github.com/golangci/golangci-lint/pkg/logutils.Log).Infof + - (github.com/golangci/golangci-lint/pkg/logutils.Log).Warnf + - (github.com/golangci/golangci-lint/pkg/logutils.Log).Errorf + - (github.com/golangci/golangci-lint/pkg/logutils.Log).Fatalf + lll: + line-length: 200 + maligned: + suggest-new: true + misspell: + locale: US + revive: + rules: + - name: redefines-builtin-id + disabled: true + + # Allow code like: + # Items: binpacking.Items{ + # { + # }, + # } + - name: nested-structs + disabled: true gci: sections: - standard - default - prefix(cloud-proxy) - +issues: + fix: true run: skip-dirs: - mock + - internal/castai diff --git a/cmd/proxy/main.go b/cmd/proxy/main.go index d4dab82..f216bd5 100644 --- a/cmd/proxy/main.go +++ b/cmd/proxy/main.go @@ -34,7 +34,7 @@ func main() { dialOpts := make([]grpc.DialOption, 0) if cfg.CastAI.DisableGRPCTLS { - // ONLY For testing purposes + // ONLY For testing purposes. dialOpts = append(dialOpts, grpc.WithTransportCredentials(insecure.NewCredentials())) } else { dialOpts = append(dialOpts, grpc.WithTransportCredentials(credentials.NewTLS(nil))) @@ -72,11 +72,11 @@ func main() { }(conn) ctx := metadata.NewOutgoingContext(context.Background(), metadata.Pairs( - "authorization", fmt.Sprintf("Token %s", cfg.CastAI.ApiKey), + "authorization", fmt.Sprintf("Token %s", cfg.CastAI.APIKey), )) client := proxy.New(conn, gcp.New(gcpauth.NewCredentialsSource(), http.DefaultClient), logger, - cfg.ClusterID, GetVersion(), cfg.KeepAlive, cfg.KeepAliveTimeout) + cfg.GetPodName(), cfg.ClusterID, GetVersion(), cfg.KeepAlive, cfg.KeepAliveTimeout) err = client.Run(ctx) if err != nil { logger.Panicf("Failed to run client: %v", err) @@ -93,7 +93,7 @@ func setupLogger(cfg config.Config) *logrus.Logger { logger.SetLevel(logrus.Level(cfg.Log.Level)) logger.SetReportCaller(true) logger.Formatter = &logrus.TextFormatter{ - CallerPrettyfier: func(f *runtime.Frame) (function string, file string) { + CallerPrettyfier: func(f *runtime.Frame) (function, file string) { filename := path.Base(f.File) return fmt.Sprintf("%s()", f.Function), fmt.Sprintf("%s:%d", filename, f.Line) }, diff --git a/e2e/Dockerfile b/e2e/Dockerfile deleted file mode 100644 index fa98e3e..0000000 --- a/e2e/Dockerfile +++ /dev/null @@ -1,4 +0,0 @@ -FROM gcr.io/distroless/static-debian11 -COPY bin/cloud-proxy-e2e /usr/local/bin/cloud-proxy-e2e -CMD ["cloud-proxy-e2e"] - diff --git a/e2e/chart/.helmignore b/e2e/chart/.helmignore deleted file mode 100644 index 0e8a0eb..0000000 --- a/e2e/chart/.helmignore +++ /dev/null @@ -1,23 +0,0 @@ -# Patterns to ignore when building packages. -# This supports shell glob matching, relative path matching, and -# negation (prefixed with !). Only one pattern per line. -.DS_Store -# Common VCS dirs -.git/ -.gitignore -.bzr/ -.bzrignore -.hg/ -.hgignore -.svn/ -# Common backup files -*.swp -*.bak -*.tmp -*.orig -*~ -# Various IDEs -.project -.idea/ -*.tmproj -.vscode/ diff --git a/e2e/chart/Chart.yaml b/e2e/chart/Chart.yaml deleted file mode 100644 index 973b09a..0000000 --- a/e2e/chart/Chart.yaml +++ /dev/null @@ -1,24 +0,0 @@ -apiVersion: v2 -name: cloud-proxy-e2e -description: A Helm chart for Kubernetes - -# A chart can be either an 'application' or a 'library' chart. -# -# Application charts are a collection of templates that can be packaged into versioned archives -# to be deployed. -# -# Library charts provide useful utilities or functions for the chart developer. They're included as -# a dependency of application charts to inject those utilities and functions into the rendering -# pipeline. Library charts do not define any templates and therefore cannot be deployed. -type: application - -# This is the chart version. This version number should be incremented each time you make changes -# to the chart and its templates, including the app version. -# Versions are expected to follow Semantic Versioning (https://semver.org/) -version: 0.1.0 - -# This is the version number of the application being deployed. This version number should be -# incremented each time you make changes to the application. Versions are not expected to -# follow Semantic Versioning. They should reflect the version the application is using. -# It is recommended to use it with quotes. -appVersion: "1.16.0" diff --git a/e2e/chart/templates/_helpers.tpl b/e2e/chart/templates/_helpers.tpl deleted file mode 100644 index 60d16d1..0000000 --- a/e2e/chart/templates/_helpers.tpl +++ /dev/null @@ -1,62 +0,0 @@ -{{/* -Expand the name of the chart. -*/}} -{{- define "e2e.name" -}} -{{- default .Chart.Name .Values.nameOverride | trunc 63 | trimSuffix "-" }} -{{- end }} - -{{/* -Create a default fully qualified app name. -We truncate at 63 chars because some Kubernetes name fields are limited to this (by the DNS naming spec). -If release name contains chart name it will be used as a full name. -*/}} -{{- define "e2e.fullname" -}} -{{- if .Values.fullnameOverride }} -{{- .Values.fullnameOverride | trunc 63 | trimSuffix "-" }} -{{- else }} -{{- $name := default .Chart.Name .Values.nameOverride }} -{{- if contains $name .Release.Name }} -{{- .Release.Name | trunc 63 | trimSuffix "-" }} -{{- else }} -{{- printf "%s-%s" .Release.Name $name | trunc 63 | trimSuffix "-" }} -{{- end }} -{{- end }} -{{- end }} - -{{/* -Create chart name and version as used by the chart label. -*/}} -{{- define "e2e.chart" -}} -{{- printf "%s-%s" .Chart.Name .Chart.Version | replace "+" "_" | trunc 63 | trimSuffix "-" }} -{{- end }} - -{{/* -Common labels -*/}} -{{- define "e2e.labels" -}} -helm.sh/chart: {{ include "e2e.chart" . }} -{{ include "e2e.selectorLabels" . }} -{{- if .Chart.AppVersion }} -app.kubernetes.io/version: {{ .Chart.AppVersion | quote }} -{{- end }} -app.kubernetes.io/managed-by: {{ .Release.Service }} -{{- end }} - -{{/* -Selector labels -*/}} -{{- define "e2e.selectorLabels" -}} -app.kubernetes.io/name: {{ include "e2e.name" . }} -app.kubernetes.io/instance: {{ .Release.Name }} -{{- end }} - -{{/* -Create the name of the service account to use -*/}} -{{- define "e2e.serviceAccountName" -}} -{{- if .Values.serviceAccount.create }} -{{- default (include "e2e.fullname" .) .Values.serviceAccount.name }} -{{- else }} -{{- default "default" .Values.serviceAccount.name }} -{{- end }} -{{- end }} diff --git a/e2e/chart/templates/job.yaml b/e2e/chart/templates/job.yaml deleted file mode 100644 index 54abbbf..0000000 --- a/e2e/chart/templates/job.yaml +++ /dev/null @@ -1,22 +0,0 @@ -apiVersion: batch/v1 -kind: Job -metadata: - name: {{ include "e2e.fullname" . }} - labels: - {{- include "e2e.labels" . | nindent 4}} -spec: - backoffLimit: 0 - template: - metadata: - labels: - {{- include "e2e.selectorLabels" . | nindent 8 }} - spec: - restartPolicy: Never - containers: - - image: {{ .Values.image.repository }}:{{ .Values.image.tag }} - imagePullPolicy: {{ .Values.image.pullPolicy }} - name: {{ .Chart.Name }} - ports: - - containerPort: 50051 - name: grpc - diff --git a/e2e/chart/templates/service.yaml b/e2e/chart/templates/service.yaml deleted file mode 100644 index dc82ef8..0000000 --- a/e2e/chart/templates/service.yaml +++ /dev/null @@ -1,15 +0,0 @@ -apiVersion: v1 -kind: Service -metadata: - name: {{ include "e2e.fullname" . }} - labels: - {{- include "e2e.labels" . | nindent 4 }} -spec: - type: ClusterIP - ports: - - port: 50051 - targetPort: grpc - protocol: TCP - name: grpc - selector: - {{- include "e2e.selectorLabels" . | nindent 4 }} diff --git a/e2e/chart/values.yaml b/e2e/chart/values.yaml deleted file mode 100644 index beb389b..0000000 --- a/e2e/chart/values.yaml +++ /dev/null @@ -1,5 +0,0 @@ -image: - repository: cloud-proxy-e2e - pullPolicy: IfNotPresent - tag: "" - diff --git a/e2e/main.go b/e2e/main.go deleted file mode 100644 index b68aa9c..0000000 --- a/e2e/main.go +++ /dev/null @@ -1,61 +0,0 @@ -package main - -import ( - "context" - "fmt" - "log" - "net/http" - "os" - - "cloud.google.com/go/container/apiv1/containerpb" - "golang.org/x/sync/errgroup" -) - -const projectID = "engineering-test-353509" - -func TestParallelCalls(ctx context.Context, server Server, rt http.RoundTripper) error { - if err := server.StartServer(); err != nil { - return err - } - defer server.GracefulStopServer() - - eg := &errgroup.Group{} - for i := 0; i < 3; i++ { - eg.Go(func() error { - contClient, err := GetContainerClient(ctx, rt) - if err != nil { - return err - } - - _, err = contClient.ListClusters(ctx, &containerpb.ListClustersRequest{ - Parent: fmt.Sprintf("projects/%s/locations/-", projectID), - }) - if err != nil { - return err - } - - return nil - }) - } - return eg.Wait() -} - -func main() { - ctx := context.Background() - - logger := log.New(os.Stderr, "[CLOUD-PROXY-E2E] ", log.LstdFlags) - - setup := NewTestSetup(logger) - - tt := map[string]func(ctx context.Context, server Server, rt http.RoundTripper) error{ - "basic test": TestParallelCalls, - } - - for name, testFunc := range tt { - setup.ExecuteTest(ctx, name, testFunc) - } - - if !setup.result { - os.Exit(1) - } -} diff --git a/e2e/run.sh b/e2e/run.sh deleted file mode 100755 index 4e4892c..0000000 --- a/e2e/run.sh +++ /dev/null @@ -1,94 +0,0 @@ -#!/usr/bin/env bash - -set -eEu - -CLUSTER_NAME=cloud-proxy-e2e -IMAGE_TAG=$RANDOM - -shout() { - echo "============= $(date) ===============" - echo "= $1" - echo "===========================================================" -} -kind::ensure() { - if ! kind export kubeconfig --name "${CLUSTER_NAME}"; then - kind create cluster --name "${CLUSTER_NAME}" - fi -} - -kind::load_images() { - kind load docker-image --name "${CLUSTER_NAME}" cloud-proxy:$IMAGE_TAG - kind load docker-image --name "${CLUSTER_NAME}" cloud-proxy-e2e:$IMAGE_TAG - -} - -cloud_proxy::build_image() { - CGO_ENABLED=0 GOOS=linux GOARCH=amd64 go build -ldflags "-s -w" -o bin/castai-cloud-proxy-amd64 ./cmd/proxy - docker build -t cloud-proxy:$IMAGE_TAG . -} - -cloud_proxy::helm_install() { - helm upgrade --install --wait \ - --set image.repository=cloud-proxy \ - --set image.tag=$IMAGE_TAG \ - --set config.grpc.endpoint=cloud-proxy-e2e:50051 \ - --set config.grpc.key=dummytoken \ - --set config.grpc.tls.enabled=false \ - --set-file config.gcpCredentials="${GCP_CREDENTIALS}" \ - castai-cloud-proxy ../github-helm-charts/charts/castai-cloud-proxy -} - -e2e::build_image() { - CGO_ENABLED=0 GOOS=linux GOARCH=amd64 go build -ldflags "-s -w" -o bin/cloud-proxy-e2e ./e2e - docker build -t cloud-proxy-e2e:$IMAGE_TAG -f ./e2e/Dockerfile . -} - -e2e::helm_install() { - helm upgrade --install --wait \ - --set image.tag=$IMAGE_TAG \ - cloud-proxy-e2e ./e2e/chart -} - -e2e::helm_uninstall() { - helm delete cloud-proxy-e2e -} - -e2e::failure() { - shout "e2e logs" - kubectl logs jobs/cloud-proxy-e2e - - shout "cloud-proxy logs" - kubectl logs deployment/castai-cloud-proxy -} - -main() { - [[ -z "${GCP_CREDENTIALS:-}" ]] && echo "Missing GCP_CREDENTIALS" && exit 1 - - kind::ensure - cloud_proxy::build_image - e2e::build_image - kind::load_images - cloud_proxy::helm_install - e2e::helm_install - - kubectl wait jobs cloud-proxy-e2e --for condition=Complete --timeout=120s & - local -r complete_pid="$!" - - kubectl wait jobs cloud-proxy-e2e --for condition=Failed --timeout=120s && exit 1 & - local -r failed_pid="$!" - - if wait -n "$complete_pid" "$failed_pid"; then - local -r exit_code=0 - shout "TESTS PASSED!" - else - local -r exit_code=1 - shout "TESTS FAILED!" - e2e::failure - fi - - e2e::helm_uninstall - - exit $exit_code -} - -main $@ diff --git a/e2e/setup.go b/e2e/setup.go deleted file mode 100644 index 1ac94de..0000000 --- a/e2e/setup.go +++ /dev/null @@ -1,163 +0,0 @@ -package main - -import ( - "context" - "fmt" - "io" - "log" - "net" - "net/http" - - "cloud-proxy/internal/e2etest" - cloudproxyv1alpha "cloud-proxy/proto/gen/proto/v1alpha" - compute "cloud.google.com/go/compute/apiv1" - container "cloud.google.com/go/container/apiv1" - "golang.org/x/sync/errgroup" - "google.golang.org/api/option" - "google.golang.org/grpc" -) - -type Server interface { - StartServer() error - StopServer() - GracefulStopServer() -} - -type TestSetup struct { - cloudproxyv1alpha.UnimplementedCloudProxyAPIServer - - result bool - - grpcServer *grpc.Server - dispatcher *e2etest.Dispatcher - roundTripper *e2etest.HttpOverGrpcRoundTripper - - requestChan chan *cloudproxyv1alpha.StreamCloudProxyResponse - responseChan chan *cloudproxyv1alpha.StreamCloudProxyRequest - - logger *log.Logger -} - -func NewTestSetup(logger *log.Logger) *TestSetup { - requestChan, respChan := make(chan *cloudproxyv1alpha.StreamCloudProxyResponse), make(chan *cloudproxyv1alpha.StreamCloudProxyRequest) - dispatcher := e2etest.NewDispatcher(requestChan, respChan, logger) - roundTrip := e2etest.NewHttpOverGrpcRoundTripper(dispatcher, logger) - - dispatcher.Run() - - return &TestSetup{ - result: true, - dispatcher: dispatcher, - roundTripper: roundTrip, - requestChan: requestChan, - responseChan: respChan, - logger: logger, - } -} - -func (srv *TestSetup) StartServer() error { - list, err := net.Listen("tcp", "0.0.0.0:50051") - if err != nil { - return fmt.Errorf("listening: %w", err) - } - - srv.grpcServer = grpc.NewServer() - cloudproxyv1alpha.RegisterCloudProxyAPIServer(srv.grpcServer, srv) - - go func() { - if err := srv.grpcServer.Serve(list); err != nil { - srv.logger.Printf("when serving grpc: %v", err) - } - }() - - return nil -} - -func (srv *TestSetup) StopServer() { - srv.grpcServer.Stop() -} - -func (srv *TestSetup) GracefulStopServer() { - srv.grpcServer.Stop() -} - -func (srv *TestSetup) StreamCloudProxy(stream cloudproxyv1alpha.CloudProxyAPI_StreamCloudProxyServer) error { - srv.logger.Println("Received a proxy connection from client") - - //md, ok := metadata.FromIncomingContext(stream.Context()) - //if !ok { - // return fmt.Errorf("missing metadata") - //} - //if token := md.Get("authorization"); token[0] != "Token dummytoken" { - // fmt.Println(token) - // return fmt.Errorf("wrong authentication token") - //} - - var eg errgroup.Group - - eg.Go(func() error { - srv.logger.Println("Starting request sender") - - for { - select { - case req := <-srv.requestChan: - srv.logger.Println("Sending request to cluster proxy client") - - if err := stream.Send(req); err != nil { - srv.logger.Printf("Error sending request: %v\n", err) - } - case <-stream.Context().Done(): - srv.logger.Printf("stream closed, stopping sending responses") - return nil - } - } - }) - - eg.Go(func() error { - srv.logger.Println("Starting response receiver") - - for { - in, err := stream.Recv() - if err == io.EOF { - fmt.Println("stream was closed by client") - return err - } - if err != nil { - srv.logger.Printf("Error in response receiver: %v\n", err) - return err - } - - srv.logger.Printf("Got a response from client: %v, %v\n", - in.GetResponse().GetMessageId(), in.GetResponse().GetHttpResponse().GetStatus()) - srv.responseChan <- in - } - }) - - return eg.Wait() -} - -func (srv *TestSetup) ExecuteTest(ctx context.Context, name string, f func(ctx context.Context, server Server, rt http.RoundTripper) error) { - if err := f(ctx, srv, srv.roundTripper); err != nil { - srv.logger.Printf("TEST FAILED: %s", name) - srv.logger.Printf("error: %v", err) - srv.result = false - } else { - srv.logger.Printf("TEST PASSED: %s", name) - } -} - -func GetContainerClient(ctx context.Context, rt http.RoundTripper) (*container.ClusterManagerClient, error) { - httpClient := &http.Client{} - httpClient.Transport = rt - return container.NewClusterManagerRESTClient(ctx, - option.WithoutAuthentication(), - option.WithHTTPClient(httpClient)) -} - -func GetZonesClient(ctx context.Context, rt http.RoundTripper) (*compute.ZonesClient, error) { - httpClient := &http.Client{} - httpClient.Transport = rt - return compute.NewZonesRESTClient(ctx, - option.WithoutAuthentication(), - option.WithHTTPClient(httpClient)) -} diff --git a/internal/castai/dummy/external_provisioner_mock.go b/internal/castai/dummy/external_provisioner_mock.go index 4ae1385..4f15190 100644 --- a/internal/castai/dummy/external_provisioner_mock.go +++ b/internal/castai/dummy/external_provisioner_mock.go @@ -7,11 +7,12 @@ import ( "math/rand/v2" "time" - "cloud-proxy/internal/e2etest" container "cloud.google.com/go/container/apiv1" "cloud.google.com/go/container/apiv1/containerpb" "google.golang.org/api/option" htransport "google.golang.org/api/transport/http" + + "cloud-proxy/internal/e2etest" ) const ( @@ -30,7 +31,7 @@ func newMockEP(dispatcher *e2etest.Dispatcher, logger *log.Logger) (*mockEP, err if err != nil { return nil, err } - httpClient.Transport = e2etest.NewHttpOverGrpcRoundTripper(dispatcher, logger) + httpClient.Transport = e2etest.NewHTTPOverGrpcRoundTripper(dispatcher, logger) gkeProxiedClient, err := container.NewClusterManagerRESTClient( context.Background(), option.WithoutAuthentication(), diff --git a/internal/cloud/gcp/executor.go b/internal/cloud/gcp/executor.go index e54b221..da32877 100644 --- a/internal/cloud/gcp/executor.go +++ b/internal/cloud/gcp/executor.go @@ -26,14 +26,14 @@ func (c *Client) DoHTTPRequest(request *http.Request) (*http.Response, error) { token, err := c.credentials.GetToken() if err != nil { - return nil, fmt.Errorf("credentialsSrc.GetToken: error: %v", err) + return nil, fmt.Errorf("credentialsSrc.GetToken: error: %w", err) } - // Set the authorize header manually since we can't rely on mothership auth + // Set the authorize header manually since we can't rely on mothership auth. request.Header.Set("Authorization", fmt.Sprintf("Bearer %s", token)) resp, err := c.httpClient.Do(request) if err != nil { - return nil, fmt.Errorf("httpClient.Do: request %+v error: %v", request, err) + return nil, fmt.Errorf("httpClient.Do: request %+v error: %w", request, err) } return resp, nil diff --git a/internal/cloud/gcp/gcpauth/client.go b/internal/cloud/gcp/gcpauth/client.go index 2fb164a..54c5fc8 100644 --- a/internal/cloud/gcp/gcpauth/client.go +++ b/internal/cloud/gcp/gcpauth/client.go @@ -20,7 +20,7 @@ type CredentialsSource struct { scopes []string } -// TODO: check if we should be doing it constantly; cache them; cache the token or something else +// TODO: check if we should be doing it constantly; cache them; cache the token or something else. func (src *CredentialsSource) getDefaultCredentials() (*google.Credentials, error) { defaultCreds, err := google.FindDefaultCredentials(context.Background(), src.scopes...) @@ -29,6 +29,7 @@ func (src *CredentialsSource) getDefaultCredentials() (*google.Credentials, erro } return defaultCreds, nil } + func (src *CredentialsSource) GetToken() (string, error) { credentials, err := src.getDefaultCredentials() if err != nil { diff --git a/internal/config/config.go b/internal/config/config.go index 6a5af2d..537c5d2 100644 --- a/internal/config/config.go +++ b/internal/config/config.go @@ -21,8 +21,8 @@ type Config struct { PodMetadata PodMetadata `mapstructure:"podmetadata"` - //MetricsAddress string `mapstructure:"metricsaddress"` - //HealthAddress string `mapstructure:"healthaddress"` + // MetricsAddress string `mapstructure:"metricsaddress"` + // HealthAddress string `mapstructure:"healthaddress"` Log Log `mapstructure:"log"` } @@ -40,8 +40,8 @@ type PodMetadata struct { // CastAPI contains the configuration for the connection to CAST AI API. type CastAPI struct { - // ApiKey is the API key used to authenticate to CAST AI API. - ApiKey string `mapstructure:"apikey"` + // APIKey is the API key used to authenticate to CAST AI API. + APIKey string `mapstructure:"apikey"` // URL is the URL of CAST AI REST API. URL string `mapstructure:"url"` // GrpcURL is the URL of CAST AI gRPC API. @@ -56,7 +56,7 @@ type GCP struct { } type Log struct { - Level int `mapstructure:"level"` + Level int32 `mapstructure:"level"` } var cfg *Config = nil @@ -90,7 +90,7 @@ func Get() Config { panic(fmt.Errorf("while parsing config: %w", err)) } - if cfg.CastAI.ApiKey == "" { + if cfg.CastAI.APIKey == "" { required("CAST_API_KEY") } if cfg.CastAI.GrpcURL == "" { @@ -104,7 +104,7 @@ func Get() Config { } if cfg.Log.Level == 0 { - cfg.Log.Level = int(logrus.InfoLevel) + cfg.Log.Level = int32(logrus.InfoLevel) } if cfg.KeepAlive == 0 { @@ -124,3 +124,7 @@ func Get() Config { func required(variable string) { panic(fmt.Errorf("variable %s is required", variable)) } + +func (c *Config) GetPodName() string { + return fmt.Sprintf("%v@%v", cfg.PodMetadata.PodNamespace, cfg.PodMetadata.PodName) +} diff --git a/internal/config/config_test.go b/internal/config/config_test.go index 69df649..49e4086 100644 --- a/internal/config/config_test.go +++ b/internal/config/config_test.go @@ -7,7 +7,7 @@ import ( "github.com/stretchr/testify/require" ) -// TODO: test defaults +// TODO: test defaults. func TestConfig(t *testing.T) { r := require.New(t) @@ -30,7 +30,7 @@ func TestConfig(t *testing.T) { expected := Config{ CastAI: CastAPI{ - ApiKey: "API_KEY", + APIKey: "API_KEY", URL: "cast-url", GrpcURL: "cast-grpc-url", DisableGRPCTLS: true, diff --git a/internal/e2etest/roundtripper.go b/internal/e2etest/roundtripper.go index 80c041b..40d2736 100644 --- a/internal/e2etest/roundtripper.go +++ b/internal/e2etest/roundtripper.go @@ -7,22 +7,22 @@ import ( "log" "net/http" - cloudproxyv1alpha "cloud-proxy/proto/gen/proto/v1alpha" - "github.com/google/uuid" + + cloudproxyv1alpha "cloud-proxy/proto/gen/proto/v1alpha" ) -type HttpOverGrpcRoundTripper struct { +type HTTPOverGrpcRoundTripper struct { dispatcher *Dispatcher logger *log.Logger } -func NewHttpOverGrpcRoundTripper(dispatcher *Dispatcher, logger *log.Logger) *HttpOverGrpcRoundTripper { - return &HttpOverGrpcRoundTripper{dispatcher: dispatcher, logger: logger} +func NewHTTPOverGrpcRoundTripper(dispatcher *Dispatcher, logger *log.Logger) *HTTPOverGrpcRoundTripper { + return &HTTPOverGrpcRoundTripper{dispatcher: dispatcher, logger: logger} } -func (p *HttpOverGrpcRoundTripper) RoundTrip(request *http.Request) (*http.Response, error) { +func (p *HTTPOverGrpcRoundTripper) RoundTrip(request *http.Request) (*http.Response, error) { requestID := uuid.New().String() headers := make(map[string]*cloudproxyv1alpha.HeaderValue) @@ -50,13 +50,13 @@ func (p *HttpOverGrpcRoundTripper) RoundTrip(request *http.Request) (*http.Respo } waiter, err := p.dispatcher.SendRequest(protoReq) if err != nil { - return nil, fmt.Errorf("error sending request: %v", err) + return nil, fmt.Errorf("error sending request: %w", err) } response := <-waiter p.logger.Println("Received a response back from dispatcher", requestID) - // Convert to response + // Convert to response. resp := &http.Response{ StatusCode: int(response.GetResponse().GetHttpResponse().GetStatus()), Header: func() http.Header { diff --git a/internal/proxy/client.go b/internal/proxy/client.go index 376a17f..e62c361 100644 --- a/internal/proxy/client.go +++ b/internal/proxy/client.go @@ -172,7 +172,7 @@ func (c *Client) run(ctx context.Context, stream cloudproxyv1alpha.CloudProxyAPI case <-time.After(time.Duration(c.keepAlive.Load())): if !c.isAlive() { if err := c.lastSeenError.Load(); err != nil { - return fmt.Errorf("recived error: %w", *err) + return fmt.Errorf("received error: %w", *err) } return fmt.Errorf("last seen too old, closing stream") } @@ -187,7 +187,7 @@ func (c *Client) handleMessage(in *cloudproxyv1alpha.StreamCloudProxyResponse, s } c.processConfigurationRequest(in) - // skip processing http request if keep alive message + // skip processing http request if keep alive message. if in.GetMessageId() == KeepAliveMessageID { c.lastSeen.Store(time.Now().UnixNano()) c.log.Debugf("Received keep-alive message from castai for %s", in.GetClientMetadata().GetClusterId()) @@ -195,7 +195,7 @@ func (c *Client) handleMessage(in *cloudproxyv1alpha.StreamCloudProxyResponse, s } c.log.Debugf("Received request for proxying msg_id=%v from castai", in.GetMessageId()) - resp := c.processHttpRequest(in.GetHttpRequest()) + resp := c.processHTTPRequest(in.GetHttpRequest()) if resp.GetError() != "" { c.log.Errorf("Failed to proxy request msg_id=%v with %v", in.GetMessageId(), resp.GetError()) } else { @@ -216,21 +216,20 @@ func (c *Client) handleMessage(in *cloudproxyv1alpha.StreamCloudProxyResponse, s if err != nil { c.log.Errorf("error sending response for msg_id=%v %v", in.GetMessageId(), err) } - return } func (c *Client) processConfigurationRequest(in *cloudproxyv1alpha.StreamCloudProxyResponse) { if in.ConfigurationRequest != nil { if in.ConfigurationRequest.GetKeepAlive() != 0 { - c.keepAlive.Store(int64(in.ConfigurationRequest.GetKeepAlive())) + c.keepAlive.Store(in.ConfigurationRequest.GetKeepAlive()) } if in.ConfigurationRequest.GetKeepAliveTimeout() != 0 { - c.keepAliveTimeout.Store(int64(in.ConfigurationRequest.GetKeepAliveTimeout())) + c.keepAliveTimeout.Store(in.ConfigurationRequest.GetKeepAliveTimeout()) } } } -func (c *Client) processHttpRequest(req *cloudproxyv1alpha.HTTPRequest) *cloudproxyv1alpha.HTTPResponse { +func (c *Client) processHTTPRequest(req *cloudproxyv1alpha.HTTPRequest) *cloudproxyv1alpha.HTTPResponse { if req == nil { return &cloudproxyv1alpha.HTTPResponse{ Error: lo.ToPtr("nil http request"), @@ -256,10 +255,8 @@ func (c *Client) processHttpRequest(req *cloudproxyv1alpha.HTTPRequest) *cloudpr func (c *Client) isAlive() bool { lastSeen := c.lastSeen.Load() - if time.Now().UnixNano()-lastSeen > c.keepAliveTimeout.Load() { - return false - } - return true + + return time.Now().UnixNano()-lastSeen <= c.keepAliveTimeout.Load() } func (c *Client) sendKeepAlive(stream cloudproxyv1alpha.CloudProxyAPI_StreamCloudProxyClient) { @@ -310,7 +307,7 @@ func (c *Client) toHTTPRequest(req *cloudproxyv1alpha.HTTPRequest) (*http.Reques reqHTTP, err := http.NewRequestWithContext(context.Background(), req.GetMethod(), req.GetPath(), bytes.NewReader(req.GetBody())) if err != nil { - return nil, fmt.Errorf("http.NewRequest: error: %v", err) + return nil, fmt.Errorf("http.NewRequest: error: %w", err) } for header, values := range req.GetHeaders() { @@ -349,7 +346,7 @@ func (c *Client) toResponse(resp *http.Response) *cloudproxyv1alpha.HTTPResponse return &cloudproxyv1alpha.HTTPResponse{ Body: bodyResp, Error: errMessage, - Status: int32(resp.StatusCode), + Status: int64(resp.StatusCode), Headers: headers, } } diff --git a/internal/proxy/client_test.go b/internal/proxy/client_test.go index 19794b8..138d09b 100644 --- a/internal/proxy/client_test.go +++ b/internal/proxy/client_test.go @@ -1,7 +1,9 @@ +// nolint: gocritic package proxy import ( "bytes" + "cloud-proxy/internal/config" "context" "fmt" "io" @@ -16,7 +18,6 @@ import ( "github.com/sirupsen/logrus" "github.com/stretchr/testify/require" - "cloud-proxy/internal/config" mock_proxy "cloud-proxy/internal/proxy/mock" cloudproxyv1alpha "cloud-proxy/proto/gen/proto/v1alpha" ) @@ -31,8 +32,8 @@ func (m mockReadCloserErr) Close() error { return nil } func TestClient_toResponse(t *testing.T) { t.Parallel() type fields struct { - //tuneMockCredentials func(m *mock_gcp.MockCredentials) - //httpClient *http.Client + // tuneMockCredentials func(m *mock_gcp.MockCredentials) + // httpClient *http.Client } type args struct { msgID string @@ -84,8 +85,8 @@ func TestClient_toResponse(t *testing.T) { t.Parallel() c := New(nil, nil, nil, "podName", "clusterID", "version", time.Second, time.Minute) got := c.toResponse(tt.args.resp) - //diff := cmp.Diff(got, tt.want, protocmp.Transform()) - //require.Empty(t, diff) + // diff := cmp.Diff(got, tt.want, protocmp.Transform()) + // require.Empty(t, diff) require.Equal(t, tt.want, got) }) } @@ -340,7 +341,7 @@ func TestClient_processHttpRequest(t *testing.T) { tt.fields.tuneMockCloudClient(cloudClient) } c := New(nil, cloudClient, logrus.New(), "podName", "clusterID", "version", time.Second, time.Minute) - if got := c.processHttpRequest(tt.args.req); !reflect.DeepEqual(got, tt.want) { + if got := c.processHTTPRequest(tt.args.req); !reflect.DeepEqual(got, tt.want) { t.Errorf("processHttpRequest() = %v, want %v", got, tt.want) } require.Equal(t, tt.wantProcessCount, c.processedCount.Load(), "processedCount: %v", c.processedCount.Load()) @@ -391,7 +392,8 @@ func TestClient_sendKeepAlive(t *testing.T) { ctrl := gomock.NewController(t) defer ctrl.Finish() - c := New(nil, nil, logrus.New(), "podName", "clusterID", "version", config.KeepAliveDefault, config.KeepAliveTimeoutDefault) + c := New(nil, nil, logrus.New(), "podName", "clusterID", + "version", config.KeepAliveDefault, config.KeepAliveTimeoutDefault) c.keepAlive.Store(tt.args.keepAlive) c.keepAliveTimeout.Store(tt.args.keepAliveTimeout) @@ -441,8 +443,8 @@ func TestClient_run(t *testing.T) { return ctx }, tuneMockStream: func(m *mock_proxy.MockCloudProxyAPI_StreamCloudProxyClient) { - m.EXPECT().Send(gomock.Any()).Return(nil).AnyTimes() // expected 0 or 1 times - m.EXPECT().Context().Return(context.Background()).AnyTimes() // expected 0 or 1 times + m.EXPECT().Send(gomock.Any()).Return(nil).AnyTimes() // expected 0 or 1 times. + m.EXPECT().Context().Return(context.Background()).AnyTimes() // expected 0 or 1 times. }, }, wantLastSeenUpdated: true, @@ -455,8 +457,8 @@ func TestClient_run(t *testing.T) { return context.Background() }, tuneMockStream: func(m *mock_proxy.MockCloudProxyAPI_StreamCloudProxyClient) { - m.EXPECT().Send(gomock.Any()).Return(nil).AnyTimes() // expected 0 or 1 times - m.EXPECT().Context().Return(context.Background()).AnyTimes() // expected 0 or 1 times + m.EXPECT().Send(gomock.Any()).Return(nil).AnyTimes() // expected 0 or 1 times. + m.EXPECT().Context().Return(context.Background()).AnyTimes() // expected 0 or 1 times. m.EXPECT().Recv().Return(nil, fmt.Errorf("test error")) }, }, diff --git a/proto/gen/proto/v1alpha/proxy.pb.go b/proto/gen/proto/v1alpha/proxy.pb.go index c6fba29..1f09b50 100644 --- a/proto/gen/proto/v1alpha/proxy.pb.go +++ b/proto/gen/proto/v1alpha/proxy.pb.go @@ -598,7 +598,7 @@ type HTTPResponse struct { Body []byte `protobuf:"bytes,1,opt,name=body,proto3,oneof" json:"body,omitempty"` Error *string `protobuf:"bytes,2,opt,name=error,proto3,oneof" json:"error,omitempty"` - Status int32 `protobuf:"varint,3,opt,name=status,proto3" json:"status,omitempty"` + Status int64 `protobuf:"varint,3,opt,name=status,proto3" json:"status,omitempty"` Headers map[string]*HeaderValue `protobuf:"bytes,4,rep,name=headers,proto3" json:"headers,omitempty" protobuf_key:"bytes,1,opt,name=key,proto3" protobuf_val:"bytes,2,opt,name=value,proto3"` } @@ -648,7 +648,7 @@ func (x *HTTPResponse) GetError() string { return "" } -func (x *HTTPResponse) GetStatus() int32 { +func (x *HTTPResponse) GetStatus() int64 { if x != nil { return x.Status } @@ -826,8 +826,7 @@ type ClientMetadata struct { ClusterId string `protobuf:"bytes,1,opt,name=cluster_id,json=clusterId,proto3" json:"cluster_id,omitempty"` OrganizationId *string `protobuf:"bytes,2,opt,name=organization_id,json=organizationId,proto3,oneof" json:"organization_id,omitempty"` - Namespace string `protobuf:"bytes,3,opt,name=namespace,proto3" json:"namespace,omitempty"` - PodName string `protobuf:"bytes,4,opt,name=pod_name,json=podName,proto3" json:"pod_name,omitempty"` + PodName string `protobuf:"bytes,3,opt,name=pod_name,json=podName,proto3" json:"pod_name,omitempty"` } func (x *ClientMetadata) Reset() { @@ -876,13 +875,6 @@ func (x *ClientMetadata) GetOrganizationId() string { return "" } -func (x *ClientMetadata) GetNamespace() string { - if x != nil { - return x.Namespace - } - return "" -} - func (x *ClientMetadata) GetPodName() string { if x != nil { return x.PodName @@ -1130,7 +1122,7 @@ var file_proto_v1alpha_proxy_proto_rawDesc = []byte{ 0x01, 0x28, 0x0c, 0x48, 0x00, 0x52, 0x04, 0x62, 0x6f, 0x64, 0x79, 0x88, 0x01, 0x01, 0x12, 0x19, 0x0a, 0x05, 0x65, 0x72, 0x72, 0x6f, 0x72, 0x18, 0x02, 0x20, 0x01, 0x28, 0x09, 0x48, 0x01, 0x52, 0x05, 0x65, 0x72, 0x72, 0x6f, 0x72, 0x88, 0x01, 0x01, 0x12, 0x16, 0x0a, 0x06, 0x73, 0x74, 0x61, - 0x74, 0x75, 0x73, 0x18, 0x03, 0x20, 0x01, 0x28, 0x05, 0x52, 0x06, 0x73, 0x74, 0x61, 0x74, 0x75, + 0x74, 0x75, 0x73, 0x18, 0x03, 0x20, 0x01, 0x28, 0x03, 0x52, 0x06, 0x73, 0x74, 0x61, 0x74, 0x75, 0x73, 0x12, 0x4f, 0x0a, 0x07, 0x68, 0x65, 0x61, 0x64, 0x65, 0x72, 0x73, 0x18, 0x04, 0x20, 0x03, 0x28, 0x0b, 0x32, 0x35, 0x2e, 0x63, 0x61, 0x73, 0x74, 0x61, 0x69, 0x2e, 0x63, 0x6c, 0x6f, 0x75, 0x64, 0x2e, 0x70, 0x72, 0x6f, 0x78, 0x79, 0x2e, 0x76, 0x31, 0x61, 0x6c, 0x70, 0x68, 0x61, 0x2e, @@ -1165,39 +1157,37 @@ var file_proto_v1alpha_proxy_proto_rawDesc = []byte{ 0x68, 0x61, 0x2e, 0x48, 0x54, 0x54, 0x50, 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x52, 0x0c, 0x68, 0x74, 0x74, 0x70, 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x12, 0x14, 0x0a, 0x05, 0x65, 0x72, 0x72, 0x6f, 0x72, 0x18, 0x02, 0x20, 0x01, 0x28, 0x09, 0x52, 0x05, 0x65, 0x72, - 0x72, 0x6f, 0x72, 0x22, 0xaa, 0x01, 0x0a, 0x0e, 0x43, 0x6c, 0x69, 0x65, 0x6e, 0x74, 0x4d, 0x65, + 0x72, 0x6f, 0x72, 0x22, 0x8c, 0x01, 0x0a, 0x0e, 0x43, 0x6c, 0x69, 0x65, 0x6e, 0x74, 0x4d, 0x65, 0x74, 0x61, 0x64, 0x61, 0x74, 0x61, 0x12, 0x1d, 0x0a, 0x0a, 0x63, 0x6c, 0x75, 0x73, 0x74, 0x65, 0x72, 0x5f, 0x69, 0x64, 0x18, 0x01, 0x20, 0x01, 0x28, 0x09, 0x52, 0x09, 0x63, 0x6c, 0x75, 0x73, 0x74, 0x65, 0x72, 0x49, 0x64, 0x12, 0x2c, 0x0a, 0x0f, 0x6f, 0x72, 0x67, 0x61, 0x6e, 0x69, 0x7a, 0x61, 0x74, 0x69, 0x6f, 0x6e, 0x5f, 0x69, 0x64, 0x18, 0x02, 0x20, 0x01, 0x28, 0x09, 0x48, 0x00, 0x52, 0x0e, 0x6f, 0x72, 0x67, 0x61, 0x6e, 0x69, 0x7a, 0x61, 0x74, 0x69, 0x6f, 0x6e, 0x49, 0x64, - 0x88, 0x01, 0x01, 0x12, 0x1c, 0x0a, 0x09, 0x6e, 0x61, 0x6d, 0x65, 0x73, 0x70, 0x61, 0x63, 0x65, - 0x18, 0x03, 0x20, 0x01, 0x28, 0x09, 0x52, 0x09, 0x6e, 0x61, 0x6d, 0x65, 0x73, 0x70, 0x61, 0x63, - 0x65, 0x12, 0x19, 0x0a, 0x08, 0x70, 0x6f, 0x64, 0x5f, 0x6e, 0x61, 0x6d, 0x65, 0x18, 0x04, 0x20, - 0x01, 0x28, 0x09, 0x52, 0x07, 0x70, 0x6f, 0x64, 0x4e, 0x61, 0x6d, 0x65, 0x42, 0x12, 0x0a, 0x10, - 0x5f, 0x6f, 0x72, 0x67, 0x61, 0x6e, 0x69, 0x7a, 0x61, 0x74, 0x69, 0x6f, 0x6e, 0x5f, 0x69, 0x64, - 0x32, 0x87, 0x02, 0x0a, 0x0d, 0x43, 0x6c, 0x6f, 0x75, 0x64, 0x50, 0x72, 0x6f, 0x78, 0x79, 0x41, - 0x50, 0x49, 0x12, 0x83, 0x01, 0x0a, 0x10, 0x53, 0x74, 0x72, 0x65, 0x61, 0x6d, 0x43, 0x6c, 0x6f, - 0x75, 0x64, 0x50, 0x72, 0x6f, 0x78, 0x79, 0x12, 0x33, 0x2e, 0x63, 0x61, 0x73, 0x74, 0x61, 0x69, - 0x2e, 0x63, 0x6c, 0x6f, 0x75, 0x64, 0x2e, 0x70, 0x72, 0x6f, 0x78, 0x79, 0x2e, 0x76, 0x31, 0x61, - 0x6c, 0x70, 0x68, 0x61, 0x2e, 0x53, 0x74, 0x72, 0x65, 0x61, 0x6d, 0x43, 0x6c, 0x6f, 0x75, 0x64, - 0x50, 0x72, 0x6f, 0x78, 0x79, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x1a, 0x34, 0x2e, 0x63, - 0x61, 0x73, 0x74, 0x61, 0x69, 0x2e, 0x63, 0x6c, 0x6f, 0x75, 0x64, 0x2e, 0x70, 0x72, 0x6f, 0x78, - 0x79, 0x2e, 0x76, 0x31, 0x61, 0x6c, 0x70, 0x68, 0x61, 0x2e, 0x53, 0x74, 0x72, 0x65, 0x61, 0x6d, - 0x43, 0x6c, 0x6f, 0x75, 0x64, 0x50, 0x72, 0x6f, 0x78, 0x79, 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, - 0x73, 0x65, 0x22, 0x00, 0x28, 0x01, 0x30, 0x01, 0x12, 0x70, 0x0a, 0x0b, 0x53, 0x65, 0x6e, 0x64, - 0x54, 0x6f, 0x50, 0x72, 0x6f, 0x78, 0x79, 0x12, 0x2e, 0x2e, 0x63, 0x61, 0x73, 0x74, 0x61, 0x69, - 0x2e, 0x63, 0x6c, 0x6f, 0x75, 0x64, 0x2e, 0x70, 0x72, 0x6f, 0x78, 0x79, 0x2e, 0x76, 0x31, 0x61, - 0x6c, 0x70, 0x68, 0x61, 0x2e, 0x53, 0x65, 0x6e, 0x64, 0x54, 0x6f, 0x50, 0x72, 0x6f, 0x78, 0x79, - 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x1a, 0x2f, 0x2e, 0x63, 0x61, 0x73, 0x74, 0x61, 0x69, - 0x2e, 0x63, 0x6c, 0x6f, 0x75, 0x64, 0x2e, 0x70, 0x72, 0x6f, 0x78, 0x79, 0x2e, 0x76, 0x31, 0x61, - 0x6c, 0x70, 0x68, 0x61, 0x2e, 0x53, 0x65, 0x6e, 0x64, 0x54, 0x6f, 0x50, 0x72, 0x6f, 0x78, 0x79, - 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x22, 0x00, 0x42, 0x49, 0x5a, 0x47, 0x67, 0x69, - 0x74, 0x68, 0x75, 0x62, 0x2e, 0x63, 0x6f, 0x6d, 0x2f, 0x63, 0x61, 0x73, 0x74, 0x61, 0x69, 0x2f, - 0x63, 0x6c, 0x6f, 0x75, 0x64, 0x2d, 0x70, 0x72, 0x6f, 0x78, 0x79, 0x2f, 0x70, 0x72, 0x6f, 0x74, - 0x6f, 0x2f, 0x67, 0x65, 0x6e, 0x2f, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x2f, 0x76, 0x31, 0x61, 0x6c, - 0x70, 0x68, 0x61, 0x3b, 0x63, 0x6c, 0x6f, 0x75, 0x64, 0x70, 0x72, 0x6f, 0x78, 0x79, 0x76, 0x31, - 0x61, 0x6c, 0x70, 0x68, 0x61, 0x62, 0x06, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x33, + 0x88, 0x01, 0x01, 0x12, 0x19, 0x0a, 0x08, 0x70, 0x6f, 0x64, 0x5f, 0x6e, 0x61, 0x6d, 0x65, 0x18, + 0x03, 0x20, 0x01, 0x28, 0x09, 0x52, 0x07, 0x70, 0x6f, 0x64, 0x4e, 0x61, 0x6d, 0x65, 0x42, 0x12, + 0x0a, 0x10, 0x5f, 0x6f, 0x72, 0x67, 0x61, 0x6e, 0x69, 0x7a, 0x61, 0x74, 0x69, 0x6f, 0x6e, 0x5f, + 0x69, 0x64, 0x32, 0x87, 0x02, 0x0a, 0x0d, 0x43, 0x6c, 0x6f, 0x75, 0x64, 0x50, 0x72, 0x6f, 0x78, + 0x79, 0x41, 0x50, 0x49, 0x12, 0x83, 0x01, 0x0a, 0x10, 0x53, 0x74, 0x72, 0x65, 0x61, 0x6d, 0x43, + 0x6c, 0x6f, 0x75, 0x64, 0x50, 0x72, 0x6f, 0x78, 0x79, 0x12, 0x33, 0x2e, 0x63, 0x61, 0x73, 0x74, + 0x61, 0x69, 0x2e, 0x63, 0x6c, 0x6f, 0x75, 0x64, 0x2e, 0x70, 0x72, 0x6f, 0x78, 0x79, 0x2e, 0x76, + 0x31, 0x61, 0x6c, 0x70, 0x68, 0x61, 0x2e, 0x53, 0x74, 0x72, 0x65, 0x61, 0x6d, 0x43, 0x6c, 0x6f, + 0x75, 0x64, 0x50, 0x72, 0x6f, 0x78, 0x79, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x1a, 0x34, + 0x2e, 0x63, 0x61, 0x73, 0x74, 0x61, 0x69, 0x2e, 0x63, 0x6c, 0x6f, 0x75, 0x64, 0x2e, 0x70, 0x72, + 0x6f, 0x78, 0x79, 0x2e, 0x76, 0x31, 0x61, 0x6c, 0x70, 0x68, 0x61, 0x2e, 0x53, 0x74, 0x72, 0x65, + 0x61, 0x6d, 0x43, 0x6c, 0x6f, 0x75, 0x64, 0x50, 0x72, 0x6f, 0x78, 0x79, 0x52, 0x65, 0x73, 0x70, + 0x6f, 0x6e, 0x73, 0x65, 0x22, 0x00, 0x28, 0x01, 0x30, 0x01, 0x12, 0x70, 0x0a, 0x0b, 0x53, 0x65, + 0x6e, 0x64, 0x54, 0x6f, 0x50, 0x72, 0x6f, 0x78, 0x79, 0x12, 0x2e, 0x2e, 0x63, 0x61, 0x73, 0x74, + 0x61, 0x69, 0x2e, 0x63, 0x6c, 0x6f, 0x75, 0x64, 0x2e, 0x70, 0x72, 0x6f, 0x78, 0x79, 0x2e, 0x76, + 0x31, 0x61, 0x6c, 0x70, 0x68, 0x61, 0x2e, 0x53, 0x65, 0x6e, 0x64, 0x54, 0x6f, 0x50, 0x72, 0x6f, + 0x78, 0x79, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x1a, 0x2f, 0x2e, 0x63, 0x61, 0x73, 0x74, + 0x61, 0x69, 0x2e, 0x63, 0x6c, 0x6f, 0x75, 0x64, 0x2e, 0x70, 0x72, 0x6f, 0x78, 0x79, 0x2e, 0x76, + 0x31, 0x61, 0x6c, 0x70, 0x68, 0x61, 0x2e, 0x53, 0x65, 0x6e, 0x64, 0x54, 0x6f, 0x50, 0x72, 0x6f, + 0x78, 0x79, 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x22, 0x00, 0x42, 0x49, 0x5a, 0x47, + 0x67, 0x69, 0x74, 0x68, 0x75, 0x62, 0x2e, 0x63, 0x6f, 0x6d, 0x2f, 0x63, 0x61, 0x73, 0x74, 0x61, + 0x69, 0x2f, 0x63, 0x6c, 0x6f, 0x75, 0x64, 0x2d, 0x70, 0x72, 0x6f, 0x78, 0x79, 0x2f, 0x70, 0x72, + 0x6f, 0x74, 0x6f, 0x2f, 0x67, 0x65, 0x6e, 0x2f, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x2f, 0x76, 0x31, + 0x61, 0x6c, 0x70, 0x68, 0x61, 0x3b, 0x63, 0x6c, 0x6f, 0x75, 0x64, 0x70, 0x72, 0x6f, 0x78, 0x79, + 0x76, 0x31, 0x61, 0x6c, 0x70, 0x68, 0x61, 0x62, 0x06, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x33, } var ( diff --git a/proto/v1alpha/proxy.proto b/proto/v1alpha/proxy.proto index e1c1394..3db2f15 100644 --- a/proto/v1alpha/proxy.proto +++ b/proto/v1alpha/proxy.proto @@ -94,7 +94,7 @@ message HTTPRequest { message HTTPResponse { optional bytes body = 1; optional string error = 2; - int32 status = 3; + int64 status = 3; map headers = 4; } @@ -115,6 +115,5 @@ message SendToProxyResponse { message ClientMetadata { string cluster_id = 1; optional string organization_id = 2; - string namespace = 3; - string pod_name = 4; + string pod_name = 3; }