Skip to content

Commit

Permalink
Rebasing changes after knative renaming
Browse files Browse the repository at this point in the history
  • Loading branch information
bsnchan committed Jun 5, 2018
1 parent d328c41 commit a7d21ed
Show file tree
Hide file tree
Showing 62 changed files with 100 additions and 826 deletions.
2 changes: 1 addition & 1 deletion Gopkg.lock

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

4 changes: 1 addition & 3 deletions cmd/queue/BUILD.bazel
Original file line number Diff line number Diff line change
Expand Up @@ -9,14 +9,12 @@ go_library(
"//cmd/util:go_default_library",
"//pkg/apis/serving/v1alpha1:go_default_library",
"//pkg/autoscaler:go_default_library",
"//pkg/h2c:go_default_library",
"//pkg/logging:go_default_library",
"//pkg/logging/logkey:go_default_library",
"//pkg/h2c:go_default_library",
"//pkg/queue:go_default_library",
"//vendor/github.com/golang/glog:go_default_library",
"//vendor/github.com/gorilla/websocket:go_default_library",
"//vendor/go.uber.org/zap:go_default_library",
"//vendor/golang.org/x/net/http2:go_default_library",
"//vendor/k8s.io/client-go/kubernetes:go_default_library",
"//vendor/k8s.io/client-go/rest:go_default_library",
],
Expand Down
33 changes: 3 additions & 30 deletions cmd/queue/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,6 @@ import (
"bytes"
"context"
"encoding/gob"
"errors"
"flag"
"fmt"
"io"
Expand All @@ -33,7 +32,6 @@ import (
"syscall"
"time"

"github.com/google/tcpproxy"
"github.com/knative/serving/cmd/util"
"github.com/knative/serving/pkg/apis/serving/v1alpha1"
"github.com/knative/serving/pkg/autoscaler"
Expand Down Expand Up @@ -92,11 +90,6 @@ var (
singleConcurrencyBreaker = queue.NewBreaker(singleConcurrencyQueueDepth, 1)
)

type Proxy struct {
HttpProxy *http.Server
TcpProxy *tcpproxy.Proxy
}

func initEnv() {
podName = util.GetRequiredEnvOrFatal("ELA_POD", logger)
elaNamespace = util.GetRequiredEnvOrFatal("ELA_NAMESPACE", logger)
Expand All @@ -106,28 +99,6 @@ func initEnv() {
elaAutoscalerPort = util.GetRequiredEnvOrFatal("ELA_AUTOSCALER_PORT", logger)
}

func (p *Proxy) Run() error {
if p.HttpProxy != nil {
if err := p.HttpProxy.ListenAndServe(); err != nil {
return err
}
}
<<<<<<< HEAD:cmd/queue/main.go
if p.TcpProxy != nil {
if err := p.TcpProxy.Run(); err != nil {
return err
}
}
return errors.New("No proxies to run - both HttpProxy and TcpProxy are nil.")
=======

httpProxy = httputil.NewSingleHostReverseProxy(target)

h2cProxy = httputil.NewSingleHostReverseProxy(target)
h2cProxy.Transport = h2c.NewTransport()
>>>>>>> Update the activator to use an h2c server:cmd/ela-queue/main.go
}

func connectStatSink() {
autoscalerEndpoint := fmt.Sprintf("ws://%s.%s.svc.cluster.local:%s",
elaAutoscaler, queue.AutoscalerNamespace, elaAutoscalerPort)
Expand Down Expand Up @@ -301,7 +272,9 @@ func main() {
if err != nil {
logger.Fatal("Failed to parse localhost url", zap.Error(err))
}
proxy = httputil.NewSingleHostReverseProxy(target)
httpProxy = httputil.NewSingleHostReverseProxy(target)
h2cProxy = httputil.NewSingleHostReverseProxy(target)
h2cProxy.Transport = h2c.NewTransport()

logger.Info("Queue container is starting")
config, err := rest.InClusterConfig()
Expand Down
6 changes: 3 additions & 3 deletions pkg/controller/route/route_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -1522,7 +1522,7 @@ func TestCreateRouteWithGRPCProtocol(t *testing.T) {
rev := getTestRevision("test-rev")
rev.Spec.Protocol = "grpc"

elaClient.ElafrosV1alpha1().Revisions(testNamespace).Create(rev)
elaClient.ServingV1alpha1().Revisions(testNamespace).Create(rev)

// A route targeting the revision
route := getTestRouteWithTrafficTargets(
Expand All @@ -1533,9 +1533,9 @@ func TestCreateRouteWithGRPCProtocol(t *testing.T) {
},
},
)
elaClient.ElafrosV1alpha1().Routes(testNamespace).Create(route)
elaClient.ServingV1alpha1().Routes(testNamespace).Create(route)
// Since updateRouteEvent looks in the lister, we need to add it to the informer
elaInformer.Elafros().V1alpha1().Routes().Informer().GetIndexer().Add(route)
elaInformer.Serving().V1alpha1().Routes().Informer().GetIndexer().Add(route)

controller.updateRouteEvent(KeyOrDie(route))

Expand Down
2 changes: 1 addition & 1 deletion pkg/h2c/BUILD.bazel
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ go_library(
"h2c.go",
"transport.go",
],
importpath = "github.com/elafros/elafros/pkg/h2c",
importpath = "github.com/knative/serving/pkg/h2c",
visibility = ["//visibility:public"],
deps = [
"//vendor/golang.org/x/net/http/httpguts:go_default_library",
Expand Down
2 changes: 1 addition & 1 deletion sample/grpc-ping/BUILD
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ load("@io_bazel_rules_go//go:def.bzl", "go_binary", "go_library")
go_library(
name = "go_default_library",
srcs = ["grpc-ping.go"],
importpath = "github.com/elafros/elafros/sample/grpc-ping",
importpath = "github.com/knative/serving/sample/grpc-ping",
visibility = ["//visibility:private"],
deps = [
"//sample/grpc-ping/proto:go_default_library",
Expand Down
6 changes: 3 additions & 3 deletions sample/grpc-ping/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ A simple gRPC server written in Go that you can use for testing.

## Prerequisites

1. [Install Elafros](https://github.com/elafros/install/blob/master/README.md)
1. [Install Knative](https://github.com/knative/install/blob/master/README.md)
1. Install [docker](https://www.docker.com/)

## Build and run the gRPC server
Expand All @@ -22,9 +22,9 @@ docker build \
docker push "${REPO}/sample/grpc-ping"
# Replace the image reference with our published image.
perl -pi -e "s@github.com/elafros/elafros/sample/grpc-ping@${REPO}/sample/grpc-ping@g" sample/grpc-ping/*.yaml
perl -pi -e "s@github.com/knative/serving/sample/grpc-ping@${REPO}/sample/grpc-ping@g" sample/grpc-ping/*.yaml
# Deploy the Elafros sample
# Deploy the Knative sample
kubectl apply -f sample/grpc-ping/sample.yaml
```
Expand Down
2 changes: 1 addition & 1 deletion sample/grpc-ping/client/BUILD.bazel
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ load("@io_bazel_rules_go//go:def.bzl", "go_binary", "go_library")
go_library(
name = "go_default_library",
srcs = ["client.go"],
importpath = "github.com/elafros/elafros/sample/grpc-ping/client",
importpath = "github.com/knative/serving/sample/grpc-ping/client",
visibility = ["//visibility:private"],
deps = [
"//sample/grpc-ping/proto:go_default_library",
Expand Down
4 changes: 2 additions & 2 deletions sample/grpc-ping/client/client.go
Original file line number Diff line number Diff line change
Expand Up @@ -7,14 +7,14 @@ import (
"log"
"time"

pb "github.com/elafros/elafros/sample/grpc-ping/proto"
pb "github.com/knative/serving/sample/grpc-ping/proto"
"golang.org/x/net/context"
"google.golang.org/grpc"
)

var (
serverAddr = flag.String("server_addr", "127.0.0.1:8080", "The server address in the format of host:port")
serverHostOverride = flag.String("server_host_override", "grpc.elafros.dev", "")
serverHostOverride = flag.String("server_host_override", "grpc.knative.dev", "")
)

func main() {
Expand Down
2 changes: 1 addition & 1 deletion sample/grpc-ping/grpc-ping.go
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ import (
"net"
"time"

ping "github.com/elafros/elafros/sample/grpc-ping/proto"
ping "github.com/knative/serving/sample/grpc-ping/proto"
"golang.org/x/net/context"
"google.golang.org/grpc"
)
Expand Down
2 changes: 1 addition & 1 deletion sample/grpc-ping/proto/BUILD.bazel
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ load("@io_bazel_rules_go//go:def.bzl", "go_library")
go_library(
name = "go_default_library",
srcs = ["ping.pb.go"],
importpath = "github.com/elafros/elafros/sample/grpc-ping/proto",
importpath = "github.com/knative/serving/sample/grpc-ping/proto",
visibility = ["//visibility:public"],
deps = [
"//vendor/github.com/golang/protobuf/proto:go_default_library",
Expand Down
6 changes: 3 additions & 3 deletions sample/grpc-ping/sample.yaml
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
---
apiVersion: elafros.dev/v1alpha1
apiVersion: serving.knative.dev/v1alpha1
kind: Route
metadata:
name: grpc-ping
Expand All @@ -9,7 +9,7 @@ spec:
- configurationName: grpc-ping
percent: 100
---
apiVersion: elafros.dev/v1alpha1
apiVersion: serving.knative.dev/v1alpha1
kind: Configuration
metadata:
name: grpc-ping
Expand All @@ -22,4 +22,4 @@ spec:
spec:
protocol: grpc
container:
image: github.com/elafros/elafros/sample/grpc-ping
image: github.com/knative/serving/sample/grpc-ping
3 changes: 3 additions & 0 deletions test/e2e/BUILD.bazel
Original file line number Diff line number Diff line change
Expand Up @@ -10,9 +10,12 @@ go_test(
deps = [
"//pkg/apis/serving/v1alpha1:go_default_library",
"//test:go_default_library",
"//test/e2e/test_images/helloworld-grpc/proto:go_default_library",
"//vendor/google.golang.org/grpc:go_default_library",
"//vendor/k8s.io/api/core/v1:go_default_library",
"//vendor/k8s.io/api/extensions/v1beta1:go_default_library",
"//vendor/k8s.io/apimachinery/pkg/apis/meta/v1:go_default_library",
"//vendor/k8s.io/apimachinery/pkg/util/wait:go_default_library",
"//vendor/k8s.io/client-go/plugin/pkg/client/auth/gcp:go_default_library",
],
)
2 changes: 1 addition & 1 deletion test/e2e/e2e_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ package e2e
import (
"testing"

"github.com/knative/serving/pkg/apis/ela/v1alpha1"
"github.com/knative/serving/pkg/apis/serving/v1alpha1"
"github.com/knative/serving/test"
// Mysteriously required to support GCP auth (required by k8s libs).
// Apparently just importing it is enough. @_@ side effects @_@.
Expand Down
2 changes: 1 addition & 1 deletion test/e2e/errorcondition_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ func TestContainerErrorMsg(t *testing.T) {
imagePath := strings.Join([]string{test.Flags.DockerRepo, "invalidhelloworld"}, "/")

log.Printf("Creating a new Route and Configuration %s", imagePath)
err := CreateRouteAndConfig(clients, imagePath)
err := CreateRouteAndConfig(clients, imagePath, v1alpha1.RevisionProtocolHTTP)
if err != nil {
t.Fatalf("Failed to create Route and Configuration: %v", err)
}
Expand Down
9 changes: 6 additions & 3 deletions test/e2e/helloworld_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -130,9 +130,12 @@ func waitForHelloWorldGRPCEndpoint(address string, spoofDomain string) error {
ctx, cancel := context.WithTimeout(context.Background(), 120*time.Second)
defer cancel()

resp, err := client.Hello(ctx, &hello.Request{Msg: "world"})
req := &hello.Request{Msg: "world"}
log.Printf("Retrying gRPC request: %+v", req)
resp, err := client.Hello(ctx, req)
if err != nil {
return true, err
// Continue to poll since the Ingress may take a while to start serving requests
return false, nil
}

expectedResponse := "Hello world"
Expand All @@ -141,7 +144,7 @@ func waitForHelloWorldGRPCEndpoint(address string, spoofDomain string) error {
if receivedResponse == expectedResponse {
return true, nil
}
return false, fmt.Errorf("Did not get expected response message %s, got %s", expectedResponse, receivedResponse)
return true, fmt.Errorf("Did not get expected response message %s, got %s", expectedResponse, receivedResponse)
})
return err
}
19 changes: 19 additions & 0 deletions test/e2e/test_images/helloworld-grpc/BUILD.bazel
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
load("@io_bazel_rules_go//go:def.bzl", "go_binary", "go_library")

go_library(
name = "go_default_library",
srcs = ["helloworld.go"],
importpath = "github.com/knative/serving/test/e2e/test_images/helloworld-grpc",
visibility = ["//visibility:private"],
deps = [
"//test/e2e/test_images/helloworld-grpc/proto:go_default_library",
"//vendor/golang.org/x/net/context:go_default_library",
"//vendor/google.golang.org/grpc:go_default_library",
],
)

go_binary(
name = "helloworld-grpc",
embed = [":go_default_library"],
visibility = ["//visibility:public"],
)
2 changes: 1 addition & 1 deletion test/e2e/test_images/helloworld-grpc/Dockerfile
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
FROM golang:latest

ENV APP ${GOPATH}/src/github.com/elafros/elafros/test/e2e/test_images/helloworld-grpc
ENV APP ${GOPATH}/src/github.com/knative/serving/test/e2e/test_images/helloworld-grpc

RUN mkdir -p "$APP"
ADD . "$APP"
Expand Down
2 changes: 1 addition & 1 deletion test/e2e/test_images/helloworld-grpc/helloworld.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ import (
"log"
"net"

hello "github.com/elafros/elafros/test/e2e/test_images/helloworld-grpc/proto"
hello "github.com/knative/serving/test/e2e/test_images/helloworld-grpc/proto"
"golang.org/x/net/context"
"google.golang.org/grpc"
)
Expand Down
13 changes: 13 additions & 0 deletions test/e2e/test_images/helloworld-grpc/proto/BUILD.bazel
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
load("@io_bazel_rules_go//go:def.bzl", "go_library")

go_library(
name = "go_default_library",
srcs = ["helloworld.pb.go"],
importpath = "github.com/knative/serving/test/e2e/test_images/helloworld-grpc/proto",
visibility = ["//visibility:public"],
deps = [
"//vendor/github.com/golang/protobuf/proto:go_default_library",
"//vendor/golang.org/x/net/context:go_default_library",
"//vendor/google.golang.org/grpc:go_default_library",
],
)
53 changes: 0 additions & 53 deletions vendor/github.com/golang/protobuf/regenerate.sh

This file was deleted.

9 changes: 6 additions & 3 deletions vendor/golang.org/x/net/http/httpguts/BUILD.bazel

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

Loading

0 comments on commit a7d21ed

Please sign in to comment.