From 531b08a70ba71975884847e913d59a5dda1af43a Mon Sep 17 00:00:00 2001 From: Alex Angelini Date: Tue, 5 Dec 2023 10:17:49 -0500 Subject: [PATCH] Allow use of headless hostname --- Makefile | 34 ++++++++++++------------ cmd/fuzz-test/main.go | 8 +++--- default.nix | 2 +- go.mod | 28 +++++++++++--------- go.sum | 58 +++++++++++++++++++++++------------------ js/spec/util.ts | 4 ++- js/src/binary-client.ts | 37 ++++++++++++++++---------- pkg/cli/client.go | 22 +++++++++------- pkg/client/client.go | 49 +++++++++++++++++++++++++++++----- 9 files changed, 152 insertions(+), 90 deletions(-) diff --git a/Makefile b/Makefile index 20e3db5..ed7240c 100644 --- a/Makefile +++ b/Makefile @@ -8,7 +8,7 @@ DB_PASS ?= password DB_URI := postgres://$(DB_USER):$(DB_PASS)@$(DB_HOST):5432/dl GRPC_PORT ?= 5051 -GRPC_SERVER ?= localhost:$(GRPC_PORT) +GRPC_HOST ?= localhost DEV_TOKEN_ADMIN ?= v2.public.eyJzdWIiOiJhZG1pbiIsImlhdCI6IjIwMjEtMTAtMTVUMTE6MjA6MDAuMDM0WiJ9WtEey8KfQQRy21xoHq1C5KQatEevk8RxS47k4bRfMwVCPHumZmVuk6ADcfDHTmSnMtEGfFXdxnYOhRP6Clb_Dw DEV_TOKEN_PROJECT_1 ?= v2.public.eyJzdWIiOiIxIiwiaWF0IjoiMjAyMS0xMC0xNVQxMToyMDowMC4wMzVaIn2MQ14RfIGpoEycCuvRu9J3CZp6PppUXf5l5w8uKKydN3C31z6f6GgOEPNcnwODqBnX7Pjarpz4i2uzWEqLgQYD @@ -109,7 +109,7 @@ endif test-fuzz: export DL_TOKEN=$(DEV_TOKEN_ADMIN) test-fuzz: export DL_SKIP_SSL_VERIFICATION=1 test-fuzz: reset-db - go run cmd/fuzz-test/main.go --server $(GRPC_SERVER) --iterations 1000 --projects 5 + go run cmd/fuzz-test/main.go --host $(GRPC_HOST) --iterations 1000 --projects 5 reset-db: migrate psql $(DB_URI) -c "truncate dl.objects; truncate dl.contents; truncate dl.projects; truncate dl.cache_versions;" @@ -129,64 +129,64 @@ client-update: export DL_TOKEN=$(DEV_TOKEN_PROJECT_1) client-update: export DL_SKIP_SSL_VERIFICATION=1 client-update: development/scripts/simple_input.sh 1 - go run cmd/client/main.go update --server $(GRPC_SERVER) --project 1 --dir input/simple + go run cmd/client/main.go update --host $(GRPC_HOST) --project 1 --dir input/simple development/scripts/simple_input.sh 2 - go run cmd/client/main.go update --server $(GRPC_SERVER) --project 1 --dir input/simple + go run cmd/client/main.go update --host $(GRPC_HOST) --project 1 --dir input/simple development/scripts/simple_input.sh 3 - go run cmd/client/main.go update --server $(GRPC_SERVER) --project 1 --dir input/simple + go run cmd/client/main.go update --host $(GRPC_HOST) --project 1 --dir input/simple client-large-update: export DL_TOKEN=$(DEV_TOKEN_PROJECT_1) client-large-update: export DL_SKIP_SSL_VERIFICATION=1 client-large-update: development/scripts/complex_input.sh 1 - go run cmd/client/main.go update --server $(GRPC_SERVER) --project 1 --dir input/complex + go run cmd/client/main.go update --host $(GRPC_HOST) --project 1 --dir input/complex development/scripts/complex_input.sh 2 - go run cmd/client/main.go update --server $(GRPC_SERVER) --project 1 --dir input/complex + go run cmd/client/main.go update --host $(GRPC_HOST) --project 1 --dir input/complex development/scripts/complex_input.sh 3 - go run cmd/client/main.go update --server $(GRPC_SERVER) --project 1 --dir input/complex + go run cmd/client/main.go update --host $(GRPC_HOST) --project 1 --dir input/complex client-get: export DL_TOKEN=$(DEV_TOKEN_PROJECT_1) client-get: export DL_SKIP_SSL_VERIFICATION=1 client-get: ifndef to_version - go run cmd/client/main.go get --server $(GRPC_SERVER) --project 1 --prefix "$(prefix)" + go run cmd/client/main.go get --host $(GRPC_HOST) --project 1 --prefix "$(prefix)" else - go run cmd/client/main.go get --server $(GRPC_SERVER) --project 1 --to $(to_version) --prefix "$(prefix)" + go run cmd/client/main.go get --host $(GRPC_HOST) --project 1 --to $(to_version) --prefix "$(prefix)" endif client-rebuild: export DL_TOKEN=$(DEV_TOKEN_ADMIN) client-rebuild: export DL_SKIP_SSL_VERIFICATION=1 client-rebuild: ifndef to_version - go run cmd/client/main.go rebuild --server $(GRPC_SERVER) --project 1 --prefix "$(prefix)" --dir $(dir) + go run cmd/client/main.go rebuild --host $(GRPC_HOST) --project 1 --prefix "$(prefix)" --dir $(dir) else - go run cmd/client/main.go rebuild --server $(GRPC_SERVER) --project 1 --to $(to_version) --prefix "$(prefix)" --dir $(dir) + go run cmd/client/main.go rebuild --host $(GRPC_HOST) --project 1 --to $(to_version) --prefix "$(prefix)" --dir $(dir) endif client-rebuild-with-cache: export DL_TOKEN=$(DEV_TOKEN_ADMIN) client-rebuild-with-cache: export DL_SKIP_SSL_VERIFICATION=1 client-rebuild-with-cache: - go run cmd/client/main.go rebuild --server $(GRPC_SERVER) --project 1 --prefix "$(prefix)" --dir $(dir) --cachedir input/cache + go run cmd/client/main.go rebuild --host $(GRPC_HOST) --project 1 --prefix "$(prefix)" --dir $(dir) --cachedir input/cache client-getcache: export DL_TOKEN=$(DEV_TOKEN_ADMIN) client-getcache: export DL_SKIP_SSL_VERIFICATION=1 client-getcache: - go run cmd/client/main.go getcache --server $(GRPC_SERVER) --path input/cache + go run cmd/client/main.go getcache --host $(GRPC_HOST) --path input/cache client-gc-contents: export DL_TOKEN=$(DEV_TOKEN_ADMIN) client-gc-contents: export DL_SKIP_SSL_VERIFICATION=1 client-gc-contents: - go run cmd/client/main.go gc --server $(GRPC_SERVER) --mode contents --sample 25 + go run cmd/client/main.go gc --host $(GRPC_HOST) --mode contents --sample 25 client-gc-project: export DL_TOKEN=$(DEV_TOKEN_ADMIN) client-gc-project: export DL_SKIP_SSL_VERIFICATION=1 client-gc-project: - go run cmd/client/main.go gc --server $(GRPC_SERVER) --mode project --project 1 --keep 1 + go run cmd/client/main.go gc --host $(GRPC_HOST) --mode project --project 1 --keep 1 client-gc-random-projects: export DL_TOKEN=$(DEV_TOKEN_ADMIN) client-gc-random-projects: export DL_SKIP_SSL_VERIFICATION=1 client-gc-random-projects: - go run cmd/client/main.go gc --server $(GRPC_SERVER) --mode random-projects --sample 25 --keep 1 + go run cmd/client/main.go gc --host $(GRPC_HOST) --mode random-projects --sample 25 --keep 1 health: grpc-health-probe -addr $(GRPC_SERVER) diff --git a/cmd/fuzz-test/main.go b/cmd/fuzz-test/main.go index a056ece..28754d6 100644 --- a/cmd/fuzz-test/main.go +++ b/cmd/fuzz-test/main.go @@ -622,7 +622,8 @@ func newCommand() *cobra.Command { var ( projects int iterations int - server string + host string + port uint16 ) cmd := &cobra.Command{ @@ -634,7 +635,7 @@ func newCommand() *cobra.Command { ctx := cmd.Context() - client, err := dlc.NewClient(ctx, server) + client, err := dlc.NewClient(ctx, host, port) if err != nil { return err } @@ -646,7 +647,8 @@ func newCommand() *cobra.Command { flags := cmd.PersistentFlags() flags.IntVar(&projects, "projects", 5, "How many projects to create") flags.IntVar(&iterations, "iterations", 1000, "How many FS operations to apply") - flags.StringVar(&server, "server", "", "Server GRPC address") + flags.StringVar(&host, "host", "", "GRPC server hostname") + flags.Uint16Var(&port, "port", 5051, "GRPC server port") return cmd } diff --git a/default.nix b/default.nix index 2c1205c..691bbbb 100644 --- a/default.nix +++ b/default.nix @@ -17,7 +17,7 @@ buildGoModule rec { version = "0.6.1"; src = ./.; proxyVendor = true; # Fixes: cannot query module due to -mod=vendor running make install - vendorSha256 = "sha256-IDr0jYOFskBPC6b7QUgZygBdDMZvm4pZePK1/2GGbY0="; + vendorSha256 = "sha256-v0orVKF/ili8RSGPxOYpvpa+vUmBJ3/fGS8mzcsbwc8="; outputs = [ "out" "client" "server" "migrations" ]; diff --git a/go.mod b/go.mod index 3d3fb11..cd6d38a 100644 --- a/go.mod +++ b/go.mod @@ -7,8 +7,8 @@ require ( github.com/gadget-inc/fsdiff v0.4.4 github.com/gobwas/glob v0.2.3 github.com/grpc-ecosystem/go-grpc-middleware v1.3.0 - github.com/jackc/pgx/v5 v5.3.1 - github.com/jackc/puddle/v2 v2.2.0 + github.com/jackc/pgx/v5 v5.5.0 + github.com/jackc/puddle/v2 v2.2.1 github.com/klauspost/compress v1.16.5 github.com/minio/sha256-simd v1.0.0 github.com/o1egl/paseto v1.0.0 @@ -21,15 +21,15 @@ require ( go.opentelemetry.io/otel/sdk v1.16.0 go.opentelemetry.io/otel/trace v1.16.0 go.uber.org/zap v1.23.0 - golang.org/x/oauth2 v0.6.0 - golang.org/x/sync v0.1.0 - golang.org/x/sys v0.8.0 - google.golang.org/grpc v1.55.0 - google.golang.org/protobuf v1.30.0 + golang.org/x/oauth2 v0.15.0 + golang.org/x/sync v0.5.0 + golang.org/x/sys v0.15.0 + google.golang.org/grpc v1.59.0 + google.golang.org/protobuf v1.31.0 ) require ( - cloud.google.com/go/compute v1.18.0 // indirect + cloud.google.com/go/compute v1.23.0 // indirect cloud.google.com/go/compute/metadata v0.2.3 // indirect github.com/aead/chacha20 v0.0.0-20180709150244-8b13a72661da // indirect github.com/aead/chacha20poly1305 v0.0.0-20201124145622-1a5aba2a8b29 // indirect @@ -42,7 +42,7 @@ require ( github.com/dustin/go-humanize v1.0.0 // indirect github.com/go-logr/logr v1.2.4 // indirect github.com/go-logr/stdr v1.2.2 // indirect - github.com/golang/glog v1.1.0 // indirect + github.com/golang/glog v1.1.2 // indirect github.com/golang/protobuf v1.5.3 // indirect github.com/grpc-ecosystem/grpc-gateway/v2 v2.11.3 // indirect github.com/inconshreveable/mousetrap v1.0.1 // indirect @@ -60,10 +60,12 @@ require ( go.opentelemetry.io/proto/otlp v0.19.0 // indirect go.uber.org/atomic v1.10.0 // indirect go.uber.org/multierr v1.8.0 // indirect - golang.org/x/crypto v0.6.0 // indirect - golang.org/x/net v0.10.0 // indirect - golang.org/x/text v0.9.0 // indirect + golang.org/x/crypto v0.16.0 // indirect + golang.org/x/net v0.19.0 // indirect + golang.org/x/text v0.14.0 // indirect google.golang.org/appengine v1.6.7 // indirect - google.golang.org/genproto v0.0.0-20230306155012-7f2fa6fef1f4 // indirect + google.golang.org/genproto v0.0.0-20230822172742-b8732ec3820d // indirect + google.golang.org/genproto/googleapis/api v0.0.0-20230822172742-b8732ec3820d // indirect + google.golang.org/genproto/googleapis/rpc v0.0.0-20230822172742-b8732ec3820d // indirect gopkg.in/yaml.v3 v3.0.1 // indirect ) diff --git a/go.sum b/go.sum index 66a424e..5daaad9 100644 --- a/go.sum +++ b/go.sum @@ -19,8 +19,8 @@ cloud.google.com/go/bigquery v1.4.0/go.mod h1:S8dzgnTigyfTmLBfrtrhyYhwRxG72rYxvf cloud.google.com/go/bigquery v1.5.0/go.mod h1:snEHRnqQbz117VIFhE8bmtwIDY80NLUZUMb4Nv6dBIg= cloud.google.com/go/bigquery v1.7.0/go.mod h1://okPTzCYNXSlb24MZs83e2Do+h+VXtc4gLoIoXIAPc= cloud.google.com/go/bigquery v1.8.0/go.mod h1:J5hqkt3O0uAFnINi6JXValWIb1v0goeZM77hZzJN/fQ= -cloud.google.com/go/compute v1.18.0 h1:FEigFqoDbys2cvFkZ9Fjq4gnHBP55anJ0yQyau2f9oY= -cloud.google.com/go/compute v1.18.0/go.mod h1:1X7yHxec2Ga+Ss6jPyjxRxpu2uu7PLgsOVXvgU0yacs= +cloud.google.com/go/compute v1.23.0 h1:tP41Zoavr8ptEqaW6j+LQOnyBBhO7OkOMAGrgLopTwY= +cloud.google.com/go/compute v1.23.0/go.mod h1:4tCnrn48xsqlwSAiLf1HXMQk8CONslYbdiEZc9FEIbM= cloud.google.com/go/compute/metadata v0.2.3 h1:mg4jlk7mCAj6xXp9UJ4fjI9VUI5rubuGBW5aJ7UnBMY= cloud.google.com/go/compute/metadata v0.2.3/go.mod h1:VAV5nSsACxMJvgaAuX6Pk2AawlZn8kiOGuCv6gTkwuA= cloud.google.com/go/datastore v1.0.0/go.mod h1:LXYbyblFSglQ5pkeyhO+Qmw7ukd3C+pD7TKLgZqpHYE= @@ -66,6 +66,7 @@ github.com/cncf/xds/go v0.0.0-20210312221358-fbca930ec8ed/go.mod h1:eXthEFrGJvWH github.com/cncf/xds/go v0.0.0-20210805033703-aa0b78936158/go.mod h1:eXthEFrGJvWHgFFCl3hGmgk+/aYT6PnTQLykKQRLhEs= github.com/cncf/xds/go v0.0.0-20210922020428-25de7278fc84/go.mod h1:eXthEFrGJvWHgFFCl3hGmgk+/aYT6PnTQLykKQRLhEs= github.com/cncf/xds/go v0.0.0-20211011173535-cb28da3451f1/go.mod h1:eXthEFrGJvWHgFFCl3hGmgk+/aYT6PnTQLykKQRLhEs= +github.com/cncf/xds/go v0.0.0-20230607035331-e9ce68804cb4 h1:/inchEIKaYC1Akx+H+gqO04wryn5h75LSazbRlnya1k= github.com/cpuguy83/go-md2man/v2 v2.0.2 h1:p1EgwI/C7NhT0JmVkwCD2ZBK8j4aeHQX2pMHHBfMQ6w= github.com/cpuguy83/go-md2man/v2 v2.0.2/go.mod h1:tgQtvFlXSQOSOSIRvRPT7W67SCa46tRHOmNcaadrF8o= github.com/creack/pty v1.1.9/go.mod h1:oKZEueFk5CKHvIhNR5MUki03XCEU+Q6VDXinZuGJ33E= @@ -85,6 +86,7 @@ github.com/envoyproxy/go-control-plane v0.9.9-0.20201210154907-fd9021fe5dad/go.m github.com/envoyproxy/go-control-plane v0.9.9-0.20210512163311-63b5d3c536b0/go.mod h1:hliV/p42l8fGbc6Y9bQ70uLwIvmJyVE5k4iMKlh8wCQ= github.com/envoyproxy/go-control-plane v0.9.10-0.20210907150352-cf90f659a021/go.mod h1:AFq3mo9L8Lqqiid3OhADV3RfLJnjiw63cSpi+fDTRC0= github.com/envoyproxy/protoc-gen-validate v0.1.0/go.mod h1:iSmxcyjqTsJpI2R4NaDN7+kN2VEUnK/pcBlmesArF7c= +github.com/envoyproxy/protoc-gen-validate v1.0.2 h1:QkIBuU5k+x7/QXPvPPnWXWlCdaBFApVqftFV6k087DA= github.com/gadget-inc/fsdiff v0.4.4 h1:hLl/rCcWmW3P27LqMEyT2LVNWDLsREqsncODECH1vNw= github.com/gadget-inc/fsdiff v0.4.4/go.mod h1:GJurAL/F4qq4hp7uLc7nhqu9PbszI4/7fkTAUNa/VIY= github.com/ghodss/yaml v1.0.0/go.mod h1:4dBDuWmgqj2HViK6kFavaiC9ZROes6MMH2rRYeMEF04= @@ -105,8 +107,8 @@ github.com/gogo/protobuf v1.3.2 h1:Ov1cvc58UF3b5XjBnZv7+opcTcQFZebYjWzi34vdm4Q= github.com/gogo/protobuf v1.3.2/go.mod h1:P1XiOD3dCwIKUDQYPy72D8LYyHL2YPYrpS2s69NZV8Q= github.com/golang/glog v0.0.0-20160126235308-23def4e6c14b/go.mod h1:SBH7ygxi8pfUlaOkMMuAQtPIUF8ecWP5IEl/CR7VP2Q= github.com/golang/glog v1.0.0/go.mod h1:EWib/APOK0SL3dFbYqvxE3UYd8E6s1ouQ7iEp/0LWV4= -github.com/golang/glog v1.1.0 h1:/d3pCKDPWNnvIWe0vVUpNP32qc8U3PDVxySP/y360qE= -github.com/golang/glog v1.1.0/go.mod h1:pfYeQZ3JWZoXTV5sFc986z3HTpwQs9At6P4ImfuP3NQ= +github.com/golang/glog v1.1.2 h1:DVjP2PbBOzHyzA+dn3WhHIq4NdVu3Q+pvivFICf/7fo= +github.com/golang/glog v1.1.2/go.mod h1:zR+okUeTbrL6EL3xHUDxZuEtGv04p5shwip1+mL/rLQ= github.com/golang/groupcache v0.0.0-20190702054246-869f871628b6/go.mod h1:cIg4eruTrX1D+g88fzRXU5OdNfaM+9IcxsU14FzY7Hc= github.com/golang/groupcache v0.0.0-20191227052852-215e87163ea7/go.mod h1:cIg4eruTrX1D+g88fzRXU5OdNfaM+9IcxsU14FzY7Hc= github.com/golang/groupcache v0.0.0-20200121045136-8c9f03a8e57e/go.mod h1:cIg4eruTrX1D+g88fzRXU5OdNfaM+9IcxsU14FzY7Hc= @@ -175,10 +177,10 @@ github.com/jackc/pgpassfile v1.0.0 h1:/6Hmqy13Ss2zCq62VdNG8tM1wchn8zjSGOBJ6icpsI github.com/jackc/pgpassfile v1.0.0/go.mod h1:CEx0iS5ambNFdcRtxPj5JhEz+xB6uRky5eyVu/W2HEg= github.com/jackc/pgservicefile v0.0.0-20221227161230-091c0ba34f0a h1:bbPeKD0xmW/Y25WS6cokEszi5g+S0QxI/d45PkRi7Nk= github.com/jackc/pgservicefile v0.0.0-20221227161230-091c0ba34f0a/go.mod h1:5TJZWKEWniPve33vlWYSoGYefn3gLQRzjfDlhSJ9ZKM= -github.com/jackc/pgx/v5 v5.3.1 h1:Fcr8QJ1ZeLi5zsPZqQeUZhNhxfkkKBOgJuYkJHoBOtU= -github.com/jackc/pgx/v5 v5.3.1/go.mod h1:t3JDKnCBlYIc0ewLF0Q7B8MXmoIaBOZj/ic7iHozM/8= -github.com/jackc/puddle/v2 v2.2.0 h1:RdcDk92EJBuBS55nQMMYFXTxwstHug4jkhT5pq8VxPk= -github.com/jackc/puddle/v2 v2.2.0/go.mod h1:vriiEXHvEE654aYKXXjOvZM39qJ0q+azkZFrfEOc3H4= +github.com/jackc/pgx/v5 v5.5.0 h1:NxstgwndsTRy7eq9/kqYc/BZh5w2hHJV86wjvO+1xPw= +github.com/jackc/pgx/v5 v5.5.0/go.mod h1:Ig06C2Vu0t5qXC60W8sqIthScaEnFvojjj9dSljmHRA= +github.com/jackc/puddle/v2 v2.2.1 h1:RhxXJtFG022u4ibrCSMSiu5aOq1i77R3OHKNJj77OAk= +github.com/jackc/puddle/v2 v2.2.1/go.mod h1:vriiEXHvEE654aYKXXjOvZM39qJ0q+azkZFrfEOc3H4= github.com/jstemmer/go-junit-report v0.0.0-20190106144839-af01ea7f8024/go.mod h1:6v2b51hI/fHJwM22ozAgKL4VKDeJcHhJFhtBdhmNjmU= github.com/jstemmer/go-junit-report v0.9.1/go.mod h1:Brl9GWCQeLvo8nXZwPNNblvFj/XSXhF0NWZEnDohbsk= github.com/kisielk/errcheck v1.5.0/go.mod h1:pFxgyoBC7bSaBwPgfKdkLd5X25qrDl4LWUI2bnpBCr8= @@ -275,8 +277,8 @@ golang.org/x/crypto v0.0.0-20190510104115-cbcb75029529/go.mod h1:yigFU9vqHzYiE8U golang.org/x/crypto v0.0.0-20190605123033-f99c8df09eb5/go.mod h1:yigFU9vqHzYiE8UmvKecakEJjdnWj3jj499lnFckfCI= golang.org/x/crypto v0.0.0-20191011191535-87dc89f01550/go.mod h1:yigFU9vqHzYiE8UmvKecakEJjdnWj3jj499lnFckfCI= golang.org/x/crypto v0.0.0-20200622213623-75b288015ac9/go.mod h1:LzIPMQfyMNhhGPhUkYOs5KpL4U8rLKemX1yGLhDgUto= -golang.org/x/crypto v0.6.0 h1:qfktjS5LUO+fFKeJXZ+ikTRijMmljikvG68fpMMruSc= -golang.org/x/crypto v0.6.0/go.mod h1:OFC/31mSvZgRz0V1QTNCzfAI1aIRzbiufJtkMIlEp58= +golang.org/x/crypto v0.16.0 h1:mMMrFzRSCF0GvB7Ne27XVtVAaXLrPmgPC7/v0tkwHaY= +golang.org/x/crypto v0.16.0/go.mod h1:gCAAfMLgwOJRpTjQ2zCCt2OcSfYMTeZVSRtQlPC7Nq4= golang.org/x/exp v0.0.0-20190121172915-509febef88a4/go.mod h1:CJ0aWSM057203Lf6IL+f9T1iT9GByDxfZKAQTCR3kQA= golang.org/x/exp v0.0.0-20190306152737-a1d7652674e8/go.mod h1:CJ0aWSM057203Lf6IL+f9T1iT9GByDxfZKAQTCR3kQA= golang.org/x/exp v0.0.0-20190510132918-efd6b22b2522/go.mod h1:ZjyILWgesfNpC6sMxTJOJm9Kp84zZh5NQWvqDGG3Qr8= @@ -335,16 +337,16 @@ golang.org/x/net v0.0.0-20200707034311-ab3426394381/go.mod h1:/O7V0waA8r7cgGh81R golang.org/x/net v0.0.0-20200822124328-c89045814202/go.mod h1:/O7V0waA8r7cgGh81Ro3o1hOxt32SMVPicZroKQ2sZA= golang.org/x/net v0.0.0-20201021035429-f5854403a974/go.mod h1:sp8m0HH+o8qH0wwXwYZr8TS3Oi6o0r6Gce1SSxlDquU= golang.org/x/net v0.0.0-20210405180319-a5a99cb37ef4/go.mod h1:p54w0d4576C0XHj96bSt6lcn1PtDYWL6XObtHCRCNQM= -golang.org/x/net v0.10.0 h1:X2//UzNDwYmtCLn7To6G58Wr6f5ahEAQgKNzv9Y951M= -golang.org/x/net v0.10.0/go.mod h1:0qNGK6F8kojg2nk9dLZ2mShWaEBan6FAoqfSigmmuDg= +golang.org/x/net v0.19.0 h1:zTwKpTd2XuCqf8huc7Fo2iSy+4RHPd10s4KzeTnVr1c= +golang.org/x/net v0.19.0/go.mod h1:CfAk/cbD4CthTvqiEl8NpboMuiuOYsAr/7NOjZJtv1U= golang.org/x/oauth2 v0.0.0-20180821212333-d2e6202438be/go.mod h1:N/0e6XlmueqKjAGxoOufVs8QHGRruUQn6yWY3a++T0U= golang.org/x/oauth2 v0.0.0-20190226205417-e64efc72b421/go.mod h1:gOpvHmFTYa4IltrdGE7lF6nIHvwfUNPOp7c8zoXwtLw= golang.org/x/oauth2 v0.0.0-20190604053449-0f29369cfe45/go.mod h1:gOpvHmFTYa4IltrdGE7lF6nIHvwfUNPOp7c8zoXwtLw= golang.org/x/oauth2 v0.0.0-20191202225959-858c2ad4c8b6/go.mod h1:gOpvHmFTYa4IltrdGE7lF6nIHvwfUNPOp7c8zoXwtLw= golang.org/x/oauth2 v0.0.0-20200107190931-bf48bf16ab8d/go.mod h1:gOpvHmFTYa4IltrdGE7lF6nIHvwfUNPOp7c8zoXwtLw= golang.org/x/oauth2 v0.0.0-20211104180415-d3ed0bb246c8/go.mod h1:KelEdhl1UZF7XfJ4dDtk6s++YSgaE7mD/BuKKDLBl4A= -golang.org/x/oauth2 v0.6.0 h1:Lh8GPgSKBfWSwFvtuWOfeI3aAAnbXTSutYxJiOJFgIw= -golang.org/x/oauth2 v0.6.0/go.mod h1:ycmewcwgD4Rpr3eZJLSB4Kyyljb3qDh40vJ8STE5HKw= +golang.org/x/oauth2 v0.15.0 h1:s8pnnxNVzjWyrvYdFUQq5llS1PX2zhPXmccZv99h7uQ= +golang.org/x/oauth2 v0.15.0/go.mod h1:q48ptWNTY5XWf+JNten23lcvHpLJ0ZSxF5ttTHKVCAM= golang.org/x/sync v0.0.0-20180314180146-1d60e4601c6f/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= golang.org/x/sync v0.0.0-20181108010431-42b317875d0f/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= golang.org/x/sync v0.0.0-20181221193216-37e7f081c4d4/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= @@ -354,8 +356,8 @@ golang.org/x/sync v0.0.0-20190911185100-cd5d95a43a6e/go.mod h1:RxMgew5VJxzue5/jJ golang.org/x/sync v0.0.0-20200317015054-43a5402ce75a/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= golang.org/x/sync v0.0.0-20200625203802-6e8e738ad208/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= golang.org/x/sync v0.0.0-20201020160332-67f06af15bc9/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= -golang.org/x/sync v0.1.0 h1:wsuoTGHzEhffawBOhz5CYhcrV4IdKZbEyZjBMuTp12o= -golang.org/x/sync v0.1.0/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= +golang.org/x/sync v0.5.0 h1:60k92dhOjHxJkrqnwsfl8KuaHbn/5dl0lUPUklKo3qE= +golang.org/x/sync v0.5.0/go.mod h1:Czt+wKu1gCyEFDUtn0jG5QVvpJ6rzVqr5aXyt9drQfk= golang.org/x/sys v0.0.0-20180830151530-49385e6e1522/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY= golang.org/x/sys v0.0.0-20181026203630-95b1ffbd15a5/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY= golang.org/x/sys v0.0.0-20190215142949-d0b11bdaac8a/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY= @@ -389,8 +391,8 @@ golang.org/x/sys v0.0.0-20210330210617-4fbd30eecc44/go.mod h1:h1NjWce9XRLGQEsW7w golang.org/x/sys v0.0.0-20210510120138-977fb7262007/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= golang.org/x/sys v0.0.0-20220704084225-05e143d24a9e/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= golang.org/x/sys v0.0.0-20221010170243-090e33056c14/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= -golang.org/x/sys v0.8.0 h1:EBmGv8NaZBZTWvrbjNoL6HVt+IVy3QDQpJs7VRIw3tU= -golang.org/x/sys v0.8.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= +golang.org/x/sys v0.15.0 h1:h48lPFYpsTvQJZF4EKyI4aLHaev3CxivZmv7yZig9pc= +golang.org/x/sys v0.15.0/go.mod h1:/VUhepiaJMQUp4+oa/7Zr1D23ma6VTLIYjOOTFZPUcA= golang.org/x/term v0.0.0-20201126162022-7de9c90e9dd1/go.mod h1:bj7SfCRtBDWHUb9snDiAeCFNEtKQo2Wmx5Cou7ajbmo= golang.org/x/text v0.0.0-20170915032832-14c0d48ead0c/go.mod h1:NqM8EUOU14njkJ3fqMW+pc6Ldnwhi/IjpwHt7yyuwOQ= golang.org/x/text v0.3.0/go.mod h1:NqM8EUOU14njkJ3fqMW+pc6Ldnwhi/IjpwHt7yyuwOQ= @@ -398,8 +400,8 @@ golang.org/x/text v0.3.1-0.20180807135948-17ff2d5776d2/go.mod h1:NqM8EUOU14njkJ3 golang.org/x/text v0.3.2/go.mod h1:bEr9sfX3Q8Zfm5fL9x+3itogRgK3+ptLWKqgva+5dAk= golang.org/x/text v0.3.3/go.mod h1:5Zoc/QRtKVWzQhOtBMvqHzDpF6irO9z98xDceosuGiQ= golang.org/x/text v0.3.5/go.mod h1:5Zoc/QRtKVWzQhOtBMvqHzDpF6irO9z98xDceosuGiQ= -golang.org/x/text v0.9.0 h1:2sjJmO8cDvYveuX97RDLsxlyUxLl+GHoLxBiRdHllBE= -golang.org/x/text v0.9.0/go.mod h1:e1OnstbJyHTd6l/uOt8jFFHp6TRDWZR/bV3emEE/zU8= +golang.org/x/text v0.14.0 h1:ScX5w1eTa3QqT8oi6+ziP7dTV1S2+ALU0bI+0zXKWiQ= +golang.org/x/text v0.14.0/go.mod h1:18ZOQIKpY8NJVqYksKHtTdi31H5itFRjB5/qKTNYzSU= golang.org/x/time v0.0.0-20181108054448-85acf8d2951c/go.mod h1:tRJNPiyCQ0inRvYxbN9jk5I+vvW/OXSQhTDSoE431IQ= golang.org/x/time v0.0.0-20190308202827-9d24e82272b4/go.mod h1:tRJNPiyCQ0inRvYxbN9jk5I+vvW/OXSQhTDSoE431IQ= golang.org/x/time v0.0.0-20191024005414-555d28b269f0/go.mod h1:tRJNPiyCQ0inRvYxbN9jk5I+vvW/OXSQhTDSoE431IQ= @@ -505,8 +507,12 @@ google.golang.org/genproto v0.0.0-20200729003335-053ba62fc06f/go.mod h1:FWY/as6D google.golang.org/genproto v0.0.0-20200804131852-c06518451d9c/go.mod h1:FWY/as6DDZQgahTzZj3fqbO1CbirC29ZNUFHwi0/+no= google.golang.org/genproto v0.0.0-20200825200019-8632dd797987/go.mod h1:FWY/as6DDZQgahTzZj3fqbO1CbirC29ZNUFHwi0/+no= google.golang.org/genproto v0.0.0-20211118181313-81c1377c94b1/go.mod h1:5CzLGKJ67TSI2B9POpiiyGha0AjJvZIUgRMt1dSmuhc= -google.golang.org/genproto v0.0.0-20230306155012-7f2fa6fef1f4 h1:DdoeryqhaXp1LtT/emMP1BRJPHHKFi5akj/nbx/zNTA= -google.golang.org/genproto v0.0.0-20230306155012-7f2fa6fef1f4/go.mod h1:NWraEVixdDnqcqQ30jipen1STv2r/n24Wb7twVTGR4s= +google.golang.org/genproto v0.0.0-20230822172742-b8732ec3820d h1:VBu5YqKPv6XiJ199exd8Br+Aetz+o08F+PLMnwJQHAY= +google.golang.org/genproto v0.0.0-20230822172742-b8732ec3820d/go.mod h1:yZTlhN0tQnXo3h00fuXNCxJdLdIdnVFVBaRJ5LWBbw4= +google.golang.org/genproto/googleapis/api v0.0.0-20230822172742-b8732ec3820d h1:DoPTO70H+bcDXcd39vOqb2viZxgqeBeSGtZ55yZU4/Q= +google.golang.org/genproto/googleapis/api v0.0.0-20230822172742-b8732ec3820d/go.mod h1:KjSP20unUpOx5kyQUFa7k4OJg0qeJ7DEZflGDu2p6Bk= +google.golang.org/genproto/googleapis/rpc v0.0.0-20230822172742-b8732ec3820d h1:uvYuEyMHKNt+lT4K3bN6fGswmK8qSvcreM3BwjDh+y4= +google.golang.org/genproto/googleapis/rpc v0.0.0-20230822172742-b8732ec3820d/go.mod h1:+Bk1OCOj40wS2hwAMA+aCW9ypzm63QTBBHp6lQ3p+9M= google.golang.org/grpc v1.19.0/go.mod h1:mqu4LbDTu4XGKhr4mRzUsmM4RtVoemTSY81AxZiDr8c= google.golang.org/grpc v1.20.1/go.mod h1:10oTOabMzJvdu6/UiuZezV6QK5dSlG84ov/aaiqXj38= google.golang.org/grpc v1.21.1/go.mod h1:oYelfM1adQP15Ek0mdvEgi9Df8B9CZIaU1084ijfRaM= @@ -523,8 +529,8 @@ google.golang.org/grpc v1.33.1/go.mod h1:fr5YgcSWrqhRRxogOsw7RzIpsmvOZ6IcH4kBYTp google.golang.org/grpc v1.36.0/go.mod h1:qjiiYl8FncCW8feJPdyg3v6XW24KsRHe+dy9BAGRRjU= google.golang.org/grpc v1.40.0/go.mod h1:ogyxbiOoUXAkP+4+xa6PZSE9DZgIHtSpzjDTB9KAK34= google.golang.org/grpc v1.42.0/go.mod h1:k+4IHHFw41K8+bbowsex27ge2rCb65oeWqe4jJ590SU= -google.golang.org/grpc v1.55.0 h1:3Oj82/tFSCeUrRTg/5E/7d/W5A1tj6Ky1ABAuZuv5ag= -google.golang.org/grpc v1.55.0/go.mod h1:iYEXKGkEBhg1PjZQvoYEVPTDkHo1/bjTnfwTeGONTY8= +google.golang.org/grpc v1.59.0 h1:Z5Iec2pjwb+LEOqzpB2MR12/eKFhDPhuqW91O+4bwUk= +google.golang.org/grpc v1.59.0/go.mod h1:aUPDwccQo6OTjy7Hct4AfBPD1GptF4fyUjIkQ9YtF98= google.golang.org/protobuf v0.0.0-20200109180630-ec00e32a8dfd/go.mod h1:DFci5gLYBciE7Vtevhsrf46CRTquxDuWsQurQQe4oz8= google.golang.org/protobuf v0.0.0-20200221191635-4d8936d0db64/go.mod h1:kwYJMbMJ01Woi6D6+Kah6886xMZcty6N08ah7+eCXa0= google.golang.org/protobuf v0.0.0-20200228230310-ab0ca4ff8a60/go.mod h1:cfTl7dwQJ+fmap5saPgwCLgHXTUD7jkjRqWcaiX5VyM= @@ -538,8 +544,8 @@ google.golang.org/protobuf v1.25.0/go.mod h1:9JNX74DMeImyA3h4bdi1ymwjUzf21/xIlba google.golang.org/protobuf v1.26.0-rc.1/go.mod h1:jlhhOSvTdKEhbULTjvd4ARK9grFBp09yW+WbY/TyQbw= google.golang.org/protobuf v1.26.0/go.mod h1:9q0QmTI4eRPtz6boOQmLYwt+qCgq0jsYwAQnmE0givc= google.golang.org/protobuf v1.27.1/go.mod h1:9q0QmTI4eRPtz6boOQmLYwt+qCgq0jsYwAQnmE0givc= -google.golang.org/protobuf v1.30.0 h1:kPPoIgf3TsEvrm0PFe15JQ+570QVxYzEvvHqChK+cng= -google.golang.org/protobuf v1.30.0/go.mod h1:HV8QOd/L58Z+nl8r43ehVNZIU/HEI6OcFqwMG9pJV4I= +google.golang.org/protobuf v1.31.0 h1:g0LDEJHgrBl9N9r17Ru3sqWhkIx2NB67okBHPwC7hs8= +google.golang.org/protobuf v1.31.0/go.mod h1:HV8QOd/L58Z+nl8r43ehVNZIU/HEI6OcFqwMG9pJV4I= gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0= gopkg.in/check.v1 v1.0.0-20180628173108-788fd7840127/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0= gopkg.in/check.v1 v1.0.0-20201130134442-10cb98267c6c h1:Hei/4ADfdWqJk1ZMxUNpqntNwaWcugrBjAiHlqqRiVk= diff --git a/js/spec/util.ts b/js/spec/util.ts index 5ad59f6..922fe24 100644 --- a/js/spec/util.ts +++ b/js/spec/util.ts @@ -11,7 +11,9 @@ export const grpcClient = new DateiLagerGrpcClient({ }); export const binaryClient = new DateiLagerBinaryClient({ - server: "localhost:5051", + server: { + host: "localhost", + }, token: devAdminToken, command: path.join(__dirname, "..", "..", "bin", "client"), }); diff --git a/js/src/binary-client.ts b/js/src/binary-client.ts index ab8bffc..d58c946 100644 --- a/js/src/binary-client.ts +++ b/js/src/binary-client.ts @@ -12,19 +12,22 @@ export interface DateiLagerBinaryClientOptions { /** * The address of the dateilager server. */ - server: - | string - | { - /** - * The host of the dateilager server. - */ - host: string; + server: { + /** + * The host of the dateilager server. + */ + host: string; - /** - * The port of the dateilager server. - */ - port: number; - }; + /** + * The port of the dateilager server. + */ + port?: number; + + /** + * The GRPC headless service hostname, used for load balancing across multiple servers. + */ + headlessHost?: string; + }; /** * The token that will be sent as authorization metadata to the dateilager server. @@ -135,7 +138,9 @@ export class DateiLagerBinaryClient { */ public constructor(options: DateiLagerBinaryClientOptions) { this._options = { - server: typeof options.server === "string" ? options.server : `${options.server.host}:${options.server.port}`, + host: options.server.host, + port: options.server.port ?? 5051, + headlessHost: options.server.headlessHost, token: typeof options.token === "string" ? () => Promise.resolve(options.token as string) : options.token, command: options.command ?? "dateilager-client", timeout: @@ -350,12 +355,16 @@ export class DateiLagerBinaryClient { cwd?: string, options?: { timeout?: number } ): Promise { - const baseArgs = [method, "--server", this._options.server, "--log-encoding", "json"]; + const baseArgs = [method, "--host", this._options.host, "--port", String(this._options.port), "--log-encoding", "json"]; if (this._options.logger) { baseArgs.push("--log-level", this._options.logger.level); } + if (this._options.headlessHost) { + baseArgs.push("--headless-host", this._options.headlessHost); + } + if (this._options.tracing) { const carrier = {}; propagation.inject(context.active(), carrier); diff --git a/pkg/cli/client.go b/pkg/cli/client.go index 2dd24f1..3de3c8f 100644 --- a/pkg/cli/client.go +++ b/pkg/cli/client.go @@ -27,11 +27,13 @@ var ( func NewClientCommand() *cobra.Command { var ( - level *zapcore.Level - encoding string - tracing bool - otelContext string - server string + level *zapcore.Level + encoding string + tracing bool + otelContext string + host string + port uint16 + headlessHostname string ) cmd := &cobra.Command{ @@ -70,11 +72,11 @@ func NewClientCommand() *cobra.Command { ctx, span = telemetry.Start(ctx, "cmd.main") - if server == "" { - return fmt.Errorf("required flag(s) \"server\" not set") + if host == "" { + return fmt.Errorf("required flag(s) \"host\" not set") } - cl, err := client.NewClient(ctx, server) + cl, err := client.NewClient(ctx, host, port, client.WithHeadlessAddress(headlessHostname)) if err != nil { return err } @@ -94,7 +96,9 @@ func NewClientCommand() *cobra.Command { flags.StringVar(&encoding, "log-encoding", "console", "Log encoding (console | json)") flags.BoolVar(&tracing, "tracing", false, "Whether tracing is enabled") flags.StringVar(&otelContext, "otel-context", "", "Open Telemetry context") - flags.StringVar(&server, "server", "", "Server GRPC address") + flags.StringVar(&host, "host", "", "GRPC server hostname") + flags.Uint16Var(&port, "port", 5051, "GRPC server port") + flags.StringVar(&headlessHostname, "headless-host", "", "Alternative headless hostname to use for round robin connections") cmd.AddCommand(NewCmdGet()) cmd.AddCommand(NewCmdInspect()) diff --git a/pkg/client/client.go b/pkg/client/client.go index 508054b..280c948 100644 --- a/pkg/client/client.go +++ b/pkg/client/client.go @@ -55,7 +55,8 @@ func NewClientConn(conn *grpc.ClientConn) *Client { } type options struct { - token string + headlessAdress string + token string } func WithToken(token string) func(*options) { @@ -64,9 +65,15 @@ func WithToken(token string) func(*options) { } } -func NewClient(ctx context.Context, server string, opts ...func(*options)) (*Client, error) { +func WithHeadlessAddress(address string) func(*options) { + return func(o *options) { + o.headlessAdress = address + } +} + +func NewClient(ctx context.Context, host string, port uint16, opts ...func(*options)) (*Client, error) { ctx, span := telemetry.Start(ctx, "client.new", trace.WithAttributes( - key.Server.Attribute(server), + key.Server.Attribute(host), )) defer span.End() @@ -75,14 +82,18 @@ func NewClient(ctx context.Context, server string, opts ...func(*options)) (*Cli return nil, fmt.Errorf("load system cert pool: %w", err) } - sslVerification := os.Getenv("DL_SKIP_SSL_VERIFICATION") - creds := credentials.NewTLS(&tls.Config{RootCAs: pool, InsecureSkipVerify: sslVerification == "1"}) - o := &options{} for _, opt := range opts { opt(o) } + sslVerification := os.Getenv("DL_SKIP_SSL_VERIFICATION") + creds := credentials.NewTLS(&tls.Config{ + RootCAs: pool, + InsecureSkipVerify: sslVerification == "1", + ServerName: host, + }) + if o.token == "" { o.token, err = getToken() if err != nil { @@ -99,6 +110,11 @@ func NewClient(ctx context.Context, server string, opts ...func(*options)) (*Cli connectCtx, cancel := context.WithTimeout(ctx, 10*time.Second) defer cancel() + server := fmt.Sprintf("%s:%d", host, port) + if o.headlessAdress != "" { + server = fmt.Sprintf("%s:%d", o.headlessAdress, port) + } + conn, err := grpc.DialContext(connectCtx, server, grpc.WithTransportCredentials(creds), grpc.WithPerRPCCredentials(auth), @@ -117,6 +133,27 @@ func NewClient(ctx context.Context, server string, opts ...func(*options)) (*Cli }), grpc.WithUnaryInterceptor(otelgrpc.UnaryClientInterceptor()), grpc.WithStreamInterceptor(otelgrpc.StreamClientInterceptor()), + grpc.WithDefaultServiceConfig(` + { + "loadBalancingConfig": [{ "round_robin": {} }], + "methodConfig": [ + { + "name": [ + { "service": "pb.Fs", "method": "Get" }, + { "service": "pb.Fs", "method": "GetUnary" }, + { "service": "pb.Fs", "method": "GetCompress" } + ], + "retryPolicy": { + "maxAttempts": 3, + "initialBackoff": "0.1s", + "maxBackoff": "1s", + "backoffMultiplier": 2, + "retryableStatusCodes": ["UNAVAILABLE", "DEADLINE_EXCEEDED"] + } + } + ] + } + `), ) if err != nil { return nil, err