From 675254f609287fe613a8582ec4b4d7f03e6322ce Mon Sep 17 00:00:00 2001 From: Artur Troian Date: Mon, 29 Jan 2024 12:14:33 -0500 Subject: [PATCH] feat: add config flag for grpc endpoint (#178) Signed-off-by: Artur Troian --- .github/workflows/integration-tests.yaml | 12 ++++++------ _docs/kustomize/akash-provider/deployment.yaml | 2 ++ _docs/kustomize/akash-provider/service.yaml | 2 ++ cmd/provider-services/cmd/run.go | 13 ++++++++----- 4 files changed, 18 insertions(+), 11 deletions(-) diff --git a/.github/workflows/integration-tests.yaml b/.github/workflows/integration-tests.yaml index 38da3058..403bcd75 100644 --- a/.github/workflows/integration-tests.yaml +++ b/.github/workflows/integration-tests.yaml @@ -116,14 +116,14 @@ jobs: working-directory: ${{ env.GOPATH }}/src/github.com/akash-network/provider run: | __pod=$(kubectl -n akash-services get pods -l app.kubernetes.io/part-of=provider -l app.kubernetes.io/component=operator -l app.kubernetes.io/instance=inventory-node --no-headers -o custom-columns=":metadata.name") - kubectl -n akash-services port-forward --address 0.0.0.0 pod/$__pod 8444:grpc & - kubectl -n akash-services port-forward --address 0.0.0.0 service/operator-inventory 8445:grpc & + kubectl -n akash-services port-forward --address 0.0.0.0 pod/$__pod 8454:grpc & + kubectl -n akash-services port-forward --address 0.0.0.0 service/operator-inventory 8455:grpc & - timeout 10 bash -c -- 'while ! nc -vz localhost 8445 > /dev/null 2>&1 ; do sleep 0.1; done' - timeout 10 bash -c -- 'while ! nc -vz localhost 8444 > /dev/null 2>&1 ; do sleep 0.1; done' + timeout 10 bash -c -- 'while ! nc -vz localhost 8454 > /dev/null 2>&1 ; do sleep 0.1; done' + timeout 10 bash -c -- 'while ! nc -vz localhost 8455 > /dev/null 2>&1 ; do sleep 0.1; done' - ${{ env.GOPATH }}/src/github.com/akash-network/akash-api/script/grpc-probe.sh --host=localhost:8444 --mode=plaintext akash.inventory.v1.NodeRPC/QueryNode - ${{ env.GOPATH }}/src/github.com/akash-network/akash-api/script/grpc-probe.sh --host=localhost:8445 --mode=plaintext akash.inventory.v1.ClusterRPC/QueryCluster + ${{ env.GOPATH }}/src/github.com/akash-network/akash-api/script/grpc-probe.sh --host=localhost:8454 --mode=plaintext akash.inventory.v1.NodeRPC/QueryNode + ${{ env.GOPATH }}/src/github.com/akash-network/akash-api/script/grpc-probe.sh --host=localhost:8455 --mode=plaintext akash.inventory.v1.ClusterRPC/QueryCluster kubectl -n akash-services logs service/operator-inventory - name: Run E2E Tests working-directory: ${{ env.GOPATH }}/src/github.com/akash-network/provider diff --git a/_docs/kustomize/akash-provider/deployment.yaml b/_docs/kustomize/akash-provider/deployment.yaml index 5f9eb6bd..0db82fb3 100644 --- a/_docs/kustomize/akash-provider/deployment.yaml +++ b/_docs/kustomize/akash-provider/deployment.yaml @@ -358,6 +358,8 @@ spec: ports: - name: gateway containerPort: 8443 + - name: grpc + containerPort: 8444 volumeMounts: - name: home mountPath: /home diff --git a/_docs/kustomize/akash-provider/service.yaml b/_docs/kustomize/akash-provider/service.yaml index 4d649f48..284fcbae 100644 --- a/_docs/kustomize/akash-provider/service.yaml +++ b/_docs/kustomize/akash-provider/service.yaml @@ -9,3 +9,5 @@ spec: ports: - name: gateway port: 8443 + - name: gateway + port: 8444 diff --git a/cmd/provider-services/cmd/run.go b/cmd/provider-services/cmd/run.go index e24c8498..355f0f00 100644 --- a/cmd/provider-services/cmd/run.go +++ b/cmd/provider-services/cmd/run.go @@ -57,6 +57,7 @@ const ( // FlagGatewayListenAddress determines listening address for Manifests FlagGatewayListenAddress = "gateway-listen-address" + FlagGatewayGRPCListenAddress = "gateway-grpc-listen-address" FlagBidPricingStrategy = "bid-price-strategy" FlagBidPriceCPUScale = "bid-price-cpu-scale" FlagBidPriceMemoryScale = "bid-price-memory-scale" @@ -180,6 +181,11 @@ func RunCmd() *cobra.Command { panic(err) } + cmd.Flags().String(FlagGatewayGRPCListenAddress, "0.0.0.0:8444", "Gateway listen address") + if err := viper.BindPFlag(FlagGatewayGRPCListenAddress, cmd.Flags().Lookup(FlagGatewayGRPCListenAddress)); err != nil { + panic(err) + } + cmd.Flags().String(FlagBidPricingStrategy, "scale", "Pricing strategy to use") if err := viper.BindPFlag(FlagBidPricingStrategy, cmd.Flags().Lookup(FlagBidPricingStrategy)); err != nil { panic(err) @@ -523,6 +529,7 @@ func doRunCmd(ctx context.Context, cmd *cobra.Command, _ []string) error { } gwaddr := viper.GetString(FlagGatewayListenAddress) + grpcaddr := viper.GetString(FlagGatewayGRPCListenAddress) var certFromFlag io.Reader if val := cmd.Flag(FlagAuthPem).Value.String(); val != "" { @@ -704,15 +711,11 @@ func doRunCmd(ctx context.Context, cmd *cobra.Command, _ []string) error { return err } - err = gwgrpc.NewServer(ctx, ":8081", []tls.Certificate{tlsCert}, service) + err = gwgrpc.NewServer(ctx, grpcaddr, []tls.Certificate{tlsCert}, service) if err != nil { return err } - // clGroup.Go(func() error { - // return group.Wait() - // }) - group.Go(func() error { return events.Publish(ctx, cctx.Client, "provider-cli", bus) })