From 66357787650f5906c32e547ddaf61ffbd4e307b6 Mon Sep 17 00:00:00 2001 From: Jim Date: Sun, 15 May 2022 12:56:32 -0400 Subject: [PATCH 1/9] chore (kms): upgrade extras/kms dep which no longer directly deps on sqlite (#2078) --- go.mod | 12 +----------- go.sum | 18 ++---------------- 2 files changed, 3 insertions(+), 27 deletions(-) diff --git a/go.mod b/go.mod index b968a6aed0..b1b3ffbdec 100644 --- a/go.mod +++ b/go.mod @@ -86,7 +86,7 @@ require ( require github.com/hashicorp/go-dbw v0.0.0-20220412153211-c470aec9369f // this is a branch and should be updated before merging require ( - github.com/hashicorp/go-kms-wrapping/extras/kms/v2 v2.0.0-20220512190651-85bdcdd684e6 + github.com/hashicorp/go-kms-wrapping/extras/kms/v2 v2.0.0-20220515130442-cac0b5ac133b github.com/prometheus/client_golang v1.12.1 golang.org/x/sync v0.0.0-20210220032951-036812b2e83c ) @@ -168,7 +168,6 @@ require ( github.com/prometheus/client_model v0.2.0 // indirect github.com/prometheus/common v0.32.1 // indirect github.com/prometheus/procfs v0.7.3 // indirect - github.com/remyoudompheng/bigfft v0.0.0-20200410134404-eec4a21b6bb0 // indirect github.com/rogpeppe/go-internal v1.8.1 // indirect github.com/russross/blackfriday/v2 v2.0.1 // indirect github.com/shurcooL/sanitized_anchor_name v1.0.0 // indirect @@ -190,14 +189,5 @@ require ( gopkg.in/yaml.v2 v2.4.0 // indirect gopkg.in/yaml.v3 v3.0.0-20210107192922-496545a6307b // indirect gorm.io/driver/sqlite v1.2.4 // indirect - modernc.org/cc/v3 v3.32.4 // indirect - modernc.org/ccgo/v3 v3.9.2 // indirect - modernc.org/libc v1.9.5 // indirect - modernc.org/mathutil v1.2.2 // indirect - modernc.org/memory v1.0.4 // indirect - modernc.org/opt v0.1.1 // indirect - modernc.org/sqlite v1.10.6 // indirect - modernc.org/strutil v1.1.0 // indirect - modernc.org/token v1.0.0 // indirect sigs.k8s.io/yaml v1.3.0 // indirect ) diff --git a/go.sum b/go.sum index 834c53eccc..3ed7620cde 100644 --- a/go.sum +++ b/go.sum @@ -377,7 +377,6 @@ github.com/docker/libtrust v0.0.0-20150114040149-fa567046d9b1/go.mod h1:cyGadeNE github.com/docker/spdystream v0.0.0-20160310174837-449fdfce4d96/go.mod h1:Qh8CwZgvJUkLughtfhJv5dyTYa91l1fOUCrgjqmcifM= github.com/docopt/docopt-go v0.0.0-20180111231733-ee0de3bc6815/go.mod h1:WwZ+bS3ebgob9U8Nd0kOddGdZWjyMGR8Wziv+TBNwSE= github.com/dustin/go-humanize v0.0.0-20171111073723-bb3d318650d4/go.mod h1:HtrtbFcZ19U5GC7JDqmcUSB87Iq5E25KnS6fMYU6eOk= -github.com/dustin/go-humanize v1.0.0 h1:VSnTsYCnlFHaM2/igO1h6X3HA71jcobQuxemgkq4zYo= github.com/dustin/go-humanize v1.0.0/go.mod h1:HtrtbFcZ19U5GC7JDqmcUSB87Iq5E25KnS6fMYU6eOk= github.com/dvsekhvalnov/jose2go v1.5.0 h1:3j8ya4Z4kMCwT5nXIKFSV84YS+HdqSSO0VsTQxaLAeM= github.com/dvsekhvalnov/jose2go v1.5.0/go.mod h1:QsHjhyTlD/lAVqn/NSbVZmSCGeDehTB/mPZadG+mhXU= @@ -678,8 +677,8 @@ github.com/hashicorp/go-immutable-radix v1.0.0/go.mod h1:0y9vanUI8NX6FsYoO3zeMjh github.com/hashicorp/go-immutable-radix v1.3.1 h1:DKHmCUm2hRBK510BaiZlwvpD40f8bJFeZnpfm2KLowc= github.com/hashicorp/go-immutable-radix v1.3.1/go.mod h1:0y9vanUI8NX6FsYoO3zeMjhV/C5i9g4Q3DwcSNZ4P60= github.com/hashicorp/go-kms-wrapping/entropy v0.1.0/go.mod h1:d1g9WGtAunDNpek8jUIEJnBlbgKS1N2Q61QkHiZyR1g= -github.com/hashicorp/go-kms-wrapping/extras/kms/v2 v2.0.0-20220512190651-85bdcdd684e6 h1:3BknAN8P8326GPQac8e3iM132lwtwkO/3OilBU67S1I= -github.com/hashicorp/go-kms-wrapping/extras/kms/v2 v2.0.0-20220512190651-85bdcdd684e6/go.mod h1:TzFKcCsMKyMwFiMfH2MfO8SXqsFQLxzR7Z8JZiGzpK4= +github.com/hashicorp/go-kms-wrapping/extras/kms/v2 v2.0.0-20220515130442-cac0b5ac133b h1:NmqGrxmUGR1XRhmYA3wsD2BktB9PfbCDIhXd4FM0hbk= +github.com/hashicorp/go-kms-wrapping/extras/kms/v2 v2.0.0-20220515130442-cac0b5ac133b/go.mod h1:puo5dXNWmXx4xoKCzbKSevcFQ4w+z72k3ZF3EVo6zI4= github.com/hashicorp/go-kms-wrapping/plugin/v2 v2.0.2 h1:it114Kjpk79JVh6AfxFMP5oi1gb+RPzcSLiG3zF/J0w= github.com/hashicorp/go-kms-wrapping/plugin/v2 v2.0.2/go.mod h1:b9mq0bG5xJ10ZcTEQJLZ22O9y71hIt2MGTLqROA/SAM= github.com/hashicorp/go-kms-wrapping/v2 v2.0.6-0.20220512190651-85bdcdd684e6 h1:isD0/0pGWppbxkakRvnX4M4k65+ZSRW0yELW+twLPDk= @@ -1155,7 +1154,6 @@ github.com/prometheus/procfs v0.7.3 h1:4jVXhlkAyzOScmCkXBTOLRLTz8EeU+eyjrwB/EPq0 github.com/prometheus/procfs v0.7.3/go.mod h1:cz+aTbrPOrUb4q7XlbU9ygM+/jj0fzG6c1xBZuNvfVA= github.com/prometheus/tsdb v0.7.1/go.mod h1:qhTCs0VvXwvX/y3TZrWD7rabWM+ijKTux40TwIPHuXU= github.com/remyoudompheng/bigfft v0.0.0-20190728182440-6a916e37a237/go.mod h1:qqbHyh8v60DhA7CoWK5oRCqLrMHRGoxYCSS9EjAz6Eo= -github.com/remyoudompheng/bigfft v0.0.0-20200410134404-eec4a21b6bb0 h1:OdAsTTz6OkFY5QxjkYwrChwuRruF69c169dPK26NUlk= github.com/remyoudompheng/bigfft v0.0.0-20200410134404-eec4a21b6bb0/go.mod h1:qqbHyh8v60DhA7CoWK5oRCqLrMHRGoxYCSS9EjAz6Eo= github.com/rogpeppe/fastuuid v0.0.0-20150106093220-6724a57986af/go.mod h1:XWv6SoW27p1b0cqNHllgS5HIMJraePCO15w5zCzIWYg= github.com/rogpeppe/fastuuid v1.1.0/go.mod h1:jVj6XXZzXRy/MSR5jhDC/2q6DgLz+nrA6LYCDYWNEvQ= @@ -1960,41 +1958,29 @@ k8s.io/kube-openapi v0.0.0-20201113171705-d219536bb9fd/go.mod h1:WOJ3KddDSol4tAG k8s.io/kubernetes v1.13.0/go.mod h1:ocZa8+6APFNC2tX1DZASIbocyYT5jHzqFVsY5aoB7Jk= k8s.io/utils v0.0.0-20201110183641-67b214c5f920/go.mod h1:jPW/WVKK9YHAvNhRxK0md/EJ228hCsBRufyofKtW8HA= modernc.org/b v1.0.0/go.mod h1:uZWcZfRj1BpYzfN9JTerzlNUnnPsV9O2ZA8JsRcubNg= -modernc.org/cc/v3 v3.32.4 h1:1ScT6MCQRWwvwVdERhGPsPq0f55J1/pFEOCiqM7zc78= modernc.org/cc/v3 v3.32.4/go.mod h1:0R6jl1aZlIl2avnYfbfHBS1QB6/f+16mihBObaBC878= -modernc.org/ccgo/v3 v3.9.2 h1:mOLFgduk60HFuPmxSix3AluTEh7zhozkby+e1VDo/ro= modernc.org/ccgo/v3 v3.9.2/go.mod h1:gnJpy6NIVqkETT+L5zPsQFj7L2kkhfPMzOghRNv/CFo= modernc.org/db v1.0.0/go.mod h1:kYD/cO29L/29RM0hXYl4i3+Q5VojL31kTUVpVJDw0s8= modernc.org/file v1.0.0/go.mod h1:uqEokAEn1u6e+J45e54dsEA/pw4o7zLrA2GwyntZzjw= modernc.org/fileutil v1.0.0/go.mod h1:JHsWpkrk/CnVV1H/eGlFf85BEpfkrp56ro8nojIq9Q8= modernc.org/golex v1.0.0/go.mod h1:b/QX9oBD/LhixY6NDh+IdGv17hgB+51fET1i2kPSmvk= -modernc.org/httpfs v1.0.6 h1:AAgIpFZRXuYnkjftxTAZwMIiwEqAfk8aVB2/oA6nAeM= modernc.org/httpfs v1.0.6/go.mod h1:7dosgurJGp0sPaRanU53W4xZYKh14wfzX420oZADeHM= modernc.org/internal v1.0.0/go.mod h1:VUD/+JAkhCpvkUitlEOnhpVxCgsBI90oTzSCRcqQVSM= modernc.org/libc v1.7.13-0.20210308123627-12f642a52bb8/go.mod h1:U1eq8YWr/Kc1RWCMFUWEdkTg8OTcfLw2kY8EDwl039w= -modernc.org/libc v1.9.5 h1:zv111ldxmP7DJ5mOIqzRbza7ZDl3kh4ncKfASB2jIYY= modernc.org/libc v1.9.5/go.mod h1:U1eq8YWr/Kc1RWCMFUWEdkTg8OTcfLw2kY8EDwl039w= modernc.org/lldb v1.0.0/go.mod h1:jcRvJGWfCGodDZz8BPwiKMJxGJngQ/5DrRapkQnLob8= modernc.org/mathutil v1.0.0/go.mod h1:wU0vUrJsVWBZ4P6e7xtFJEhFSNsfRLJ8H458uRjg03k= modernc.org/mathutil v1.1.1/go.mod h1:mZW8CKdRPY1v87qxC/wUdX5O1qDzXMP5TH3wjfpga6E= -modernc.org/mathutil v1.2.2 h1:+yFk8hBprV+4c0U9GjFtL+dV3N8hOJ8JCituQcMShFY= modernc.org/mathutil v1.2.2/go.mod h1:mZW8CKdRPY1v87qxC/wUdX5O1qDzXMP5TH3wjfpga6E= -modernc.org/memory v1.0.4 h1:utMBrFcpnQDdNsmM6asmyH/FM9TqLPS7XF7otpJmrwM= modernc.org/memory v1.0.4/go.mod h1:nV2OApxradM3/OVbs2/0OsP6nPfakXpi50C7dcoHXlc= -modernc.org/opt v0.1.1 h1:/0RX92k9vwVeDXj+Xn23DKp2VJubL7k8qNffND6qn3A= modernc.org/opt v0.1.1/go.mod h1:WdSiB5evDcignE70guQKxYUl14mgWtbClRi5wmkkTX0= modernc.org/ql v1.0.0/go.mod h1:xGVyrLIatPcO2C1JvI/Co8c0sr6y91HKFNy4pt9JXEY= modernc.org/sortutil v1.1.0/go.mod h1:ZyL98OQHJgH9IEfN71VsamvJgrtRX9Dj2gX+vH86L1k= -modernc.org/sqlite v1.10.6 h1:iNDTQbULcm0IJAqrzCm2JcCqxaKRS94rJ5/clBMRmc8= modernc.org/sqlite v1.10.6/go.mod h1:Z9FEjUtZP4qFEg6/SiADg9XCER7aYy9a/j7Pg9P7CPs= -modernc.org/strutil v1.1.0 h1:+1/yCzZxY2pZwwrsbH+4T7BQMoLQ9QiBshRC9eicYsc= modernc.org/strutil v1.1.0/go.mod h1:lstksw84oURvj9y3tn8lGvRxyRC1S2+g5uuIzNfIOBs= -modernc.org/tcl v1.5.2 h1:sYNjGr4zK6cDH74USl8wVJRrvDX6UOLpG0j4lFvR0W0= modernc.org/tcl v1.5.2/go.mod h1:pmJYOLgpiys3oI4AeAafkcUfE+TKKilminxNyU/+Zlo= -modernc.org/token v1.0.0 h1:a0jaWiNMDhDUtqOj09wvjWWAqd3q7WpBulmL9H2egsk= modernc.org/token v1.0.0/go.mod h1:UGzOrNV1mAFSEB63lOFHIpNRUVMvYTc6yu1SMY/XTDM= modernc.org/z v1.0.1-0.20210308123920-1f282aa71362/go.mod h1:8/SRk5C/HgiQWCgXdfpb+1RvhORdkz5sw72d3jjtyqA= -modernc.org/z v1.0.1 h1:WyIDpEpAIx4Hel6q/Pcgj/VhaQV5XPJ2I6ryIYbjnpc= modernc.org/z v1.0.1/go.mod h1:8/SRk5C/HgiQWCgXdfpb+1RvhORdkz5sw72d3jjtyqA= modernc.org/zappy v1.0.0/go.mod h1:hHe+oGahLVII/aTTyWK/b53VDHMAGCBYYeZ9sn83HC4= mvdan.cc/gofumpt v0.1.1/go.mod h1:yXG1r1WqZVKWbVRtBWKWX9+CxGYfA51nSomhM0woR48= From ff9470d7df844e12d47d2b54b1a419b615d737ba Mon Sep 17 00:00:00 2001 From: irenarindos Date: Mon, 16 May 2022 15:03:45 -0400 Subject: [PATCH 2/9] Update changelog for 0.8.1 --- CHANGELOG.md | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index 48341934b0..24a59ef262 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -6,6 +6,10 @@ Canonical reference for changes, improvements, and bugfixes for Boundary. ### Bug Fixes +## 0.8.1 (2022/05/13) + +### Bug Fixes + * controller: Do not shut down cluster listener when it receives an invalid packet ([Issue](https://github.com/hashicorp/boundary/issues/2072), [PR](https://github.com/hashicorp/boundary/pull/2073)) From ce0507ee994ced11e790644b86bcab14f9c8865d Mon Sep 17 00:00:00 2001 From: Carlos Alcaide Corvo Date: Mon, 16 May 2022 12:05:32 -0700 Subject: [PATCH 3/9] Update UI artifacts consumption (#2074) Update UI artifacts consumption to allow UI editions --- .github/workflows/build.yml | 26 +++++++++++++++++++++++--- Makefile | 10 ++++++++++ internal/ui/VERSION | 2 +- 3 files changed, 34 insertions(+), 4 deletions(-) diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index 24fdc6633f..1d1e7bf321 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -60,10 +60,28 @@ jobs: project="$(go list -m)" sha="$(git rev-parse HEAD)" echo "::set-output name=ldflags::"-s -w -X \'$project/version.GitCommit=$sha\'"" + + get-product-edition: + runs-on: ubuntu-latest + outputs: + product-edition: ${{ steps.get-product-edition.outputs.product-edition}} + steps: + - uses: actions/checkout@v3 + - name: Setup Go + uses: actions/setup-go@v3 + with: + go-version: "1.18.1" + - name: Get product edition + id: get-product-edition + run: | + make edition + echo "::set-output name=product-edition::$(make edition)" + build-other: needs: - get-product-version + - get-product-edition - set-ld-flags runs-on: ubuntu-latest strategy: @@ -102,7 +120,7 @@ jobs: workflow: build-admin-ui.yaml commit: ${{ steps.set-sha.outputs.sha }} repo: "hashicorp/boundary-ui" - name: admin-ui + name: admin-ui-${{ needs.get-product-edition.outputs.product-edition }} path: internal/ui/.tmp/boundary-ui/ui/admin/dist - name: Go Build env: @@ -124,6 +142,7 @@ jobs: build-linux: needs: - get-product-version + - get-product-edition - set-ld-flags runs-on: ubuntu-latest strategy: @@ -157,7 +176,7 @@ jobs: workflow: build-admin-ui.yaml commit: ${{ steps.set-sha.outputs.sha }} repo: "hashicorp/boundary-ui" - name: admin-ui + name: admin-ui-${{ needs.get-product-edition.outputs.product-edition }} path: internal/ui/.tmp/boundary-ui/ui/admin/dist - name: Go Build env: @@ -209,6 +228,7 @@ jobs: build-darwin: needs: - get-product-version + - get-product-edition - set-ld-flags runs-on: macos-latest strategy: @@ -239,7 +259,7 @@ jobs: workflow: build-admin-ui.yaml commit: ${{ steps.set-sha.outputs.sha }} repo: "hashicorp/boundary-ui" - name: admin-ui + name: admin-ui-${{ needs.get-product-edition.outputs.product-edition }} path: internal/ui/.tmp/boundary-ui/ui/admin/dist - name: Go Build env: diff --git a/Makefile b/Makefile index 3229a19736..0c2502934f 100644 --- a/Makefile +++ b/Makefile @@ -323,3 +323,13 @@ ci-verify: # This is used for release builds by .github/workflows/build.yml version: @go run ./cmd/boundary version | awk '/Version Number:/ { print $$3 }' + +EDITION?= +.PHONY: edition +# This is used for release builds by .github/workflows/build.yml +edition: + @if [ -z "$(EDITION)" ]; then \ + go run ./cmd/boundary version -format=json | jq -r '.version_metadata // "oss"'; \ + else \ + echo $(EDITION); \ + fi; \ diff --git a/internal/ui/VERSION b/internal/ui/VERSION index e1c104f635..812447e695 100644 --- a/internal/ui/VERSION +++ b/internal/ui/VERSION @@ -1,4 +1,4 @@ -8545697b430a432bd50c1bde6a080759f803f157 Add toolbar regions to align refresh button to the right (#1098) +7e792d3f7664bf3efdf33a66539022d3f3cdaf4c Refactor UI generated artifacts creation. (#1104) # This file determines the version of the UI to embed in the boundary binary. # Update this file by running 'make update-ui-version' from the root of this repo. # Set UI_COMMITISH when running the above target to update to a specific version. From 6f4cee88bf13ec367ccb1dcf31b1be8081969284 Mon Sep 17 00:00:00 2001 From: Louis Ruch Date: Tue, 17 May 2022 12:20:01 -0700 Subject: [PATCH 4/9] fix(vault_store): Correctly return expected errors (#2081) * fix(vault_store): Correctly return errors --- .../credential/vault/client_certificate.go | 4 +-- .../vault/client_certificate_test.go | 25 +++++++++++-------- internal/credential/vault/vault_token.go | 2 +- 3 files changed, 18 insertions(+), 13 deletions(-) diff --git a/internal/credential/vault/client_certificate.go b/internal/credential/vault/client_certificate.go index 057fa29f9f..0813f6813a 100644 --- a/internal/credential/vault/client_certificate.go +++ b/internal/credential/vault/client_certificate.go @@ -75,7 +75,7 @@ func (c *ClientCertificate) SetTableName(n string) { func (c *ClientCertificate) encrypt(ctx context.Context, cipher wrapping.Wrapper) error { const op = "vault.(ClientCertificate).encrypt" if len(c.CertificateKey) == 0 { - errors.New(ctx, errors.InvalidParameter, op, "no certificate key defined") + return errors.New(ctx, errors.InvalidParameter, op, "no certificate key defined") } if err := structwrapping.WrapStruct(ctx, cipher, c.ClientCertificate, nil); err != nil { return errors.Wrap(ctx, err, op, errors.WithCode(errors.Encrypt)) @@ -86,7 +86,7 @@ func (c *ClientCertificate) encrypt(ctx context.Context, cipher wrapping.Wrapper } c.KeyId = keyId if err := c.hmacCertificateKey(ctx, cipher); err != nil { - errors.Wrap(ctx, err, op) + return errors.Wrap(ctx, err, op) } return nil } diff --git a/internal/credential/vault/client_certificate_test.go b/internal/credential/vault/client_certificate_test.go index 21af5dd262..4e2842379e 100644 --- a/internal/credential/vault/client_certificate_test.go +++ b/internal/credential/vault/client_certificate_test.go @@ -6,6 +6,7 @@ import ( "github.com/hashicorp/boundary/internal/credential/vault/store" "github.com/hashicorp/boundary/internal/db" + "github.com/hashicorp/boundary/internal/errors" "github.com/hashicorp/boundary/internal/iam" "github.com/hashicorp/boundary/internal/kms" "github.com/stretchr/testify/assert" @@ -49,11 +50,12 @@ func TestClientCertificate_New(t *testing.T) { } tests := []struct { - name string - args args - want *ClientCertificate - wantErr bool - wantEncryptErr bool + name string + args args + want *ClientCertificate + wantErr bool + wantEncryptErr bool + wantEncryptErrCode errors.Code }{ { name: "missing-certificate", @@ -64,7 +66,7 @@ func TestClientCertificate_New(t *testing.T) { wantErr: true, }, { - name: "valid-missing-key", + name: "missing-key", args: args{ certificate: []byte(certPem), }, @@ -73,7 +75,8 @@ func TestClientCertificate_New(t *testing.T) { Certificate: []byte(certPem), }, }, - wantEncryptErr: true, + wantEncryptErr: true, + wantEncryptErrCode: errors.InvalidParameter, }, { name: "valid", @@ -116,10 +119,12 @@ func TestClientCertificate_New(t *testing.T) { err = got.encrypt(ctx, databaseWrapper) if tt.wantEncryptErr { require.Error(err) - } else { - require.NoError(err) - require.NoError(got.decrypt(ctx, databaseWrapper)) + assert.Truef(errors.Match(errors.T(tt.wantEncryptErrCode), err), "%v", err) + return } + + require.NoError(err) + assert.NoError(got.decrypt(ctx, databaseWrapper)) }) } } diff --git a/internal/credential/vault/vault_token.go b/internal/credential/vault/vault_token.go index a0ac6efa5a..8729816989 100644 --- a/internal/credential/vault/vault_token.go +++ b/internal/credential/vault/vault_token.go @@ -122,7 +122,7 @@ func (t *Token) encrypt(ctx context.Context, cipher wrapping.Wrapper) error { } keyId, err := cipher.KeyId(ctx) if err != nil { - errors.Wrap(ctx, err, op, errors.WithCode(errors.Encrypt), errors.WithMsg("error fetching wrapper key id")) + return errors.Wrap(ctx, err, op, errors.WithCode(errors.Encrypt), errors.WithMsg("error fetching wrapper key id")) } t.KeyId = keyId return nil From d7adc2cb5ec730c429f806ae15c92996f2e051f7 Mon Sep 17 00:00:00 2001 From: Carlos Alcaide Corvo Date: Tue, 17 May 2022 16:32:36 -0700 Subject: [PATCH 5/9] Update UI version to consume the new renamed UI artifacts (#2080) --- internal/ui/VERSION | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/internal/ui/VERSION b/internal/ui/VERSION index 812447e695..c5193b209e 100644 --- a/internal/ui/VERSION +++ b/internal/ui/VERSION @@ -1,4 +1,4 @@ -7e792d3f7664bf3efdf33a66539022d3f3cdaf4c Refactor UI generated artifacts creation. (#1104) +698160d423e8fee640d3286c3a3f17434f56a12b # This file determines the version of the UI to embed in the boundary binary. # Update this file by running 'make update-ui-version' from the root of this repo. # Set UI_COMMITISH when running the above target to update to a specific version. From c2d632f1a25e1e043c75c5fc9eaa1226d3bb4d1b Mon Sep 17 00:00:00 2001 From: Timothy Messier Date: Wed, 18 May 2022 09:45:31 -0400 Subject: [PATCH 6/9] test(targets): Prevent panic due to non-deterministic order (#2086) This test was using the third element in the result from a list request to craft the input for the next assertion. However, one of the test targets that is created does not have a default port set. Since the target list call is not ordered, sometimes this element could be the third element and a panic would result when default port interface was converted to a float64. This fixes the panic like: --- FAIL: TestList (1.31s) panic: interface conversion: interface {} is nil, not float64 [recovered] panic: interface conversion: interface {} is nil, not float64 goroutine 1694 [running]: testing.tRunner.func1.2({0x14b2320, 0xc002f486f0}) /prefix/usr/lib/go/src/testing/testing.go:1389 +0x24e testing.tRunner.func1() /prefix/usr/lib/go/src/testing/testing.go:1392 +0x39f panic({0x14b2320, 0xc002f486f0}) /prefix/usr/lib/go/src/runtime/panic.go:838 +0x207 github.com/hashicorp/boundary/internal/tests/api/targets_test.TestList(0xc000f81380) /go/src/github.com/hashicorp/boundary/internal/tests/api/targets/target_test.go:193 +0x174b testing.tRunner(0xc000f81380, 0x2b933a8) /prefix/usr/lib/go/src/testing/testing.go:1439 +0x102 created by testing.(*T).Run /prefix/usr/lib/go/src/testing/testing.go:1486 +0x35f FAIL github.com/hashicorp/boundary/internal/tests/api/targets 5.742s FAIL Refs: #2003 --- internal/tests/api/targets/target_test.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/internal/tests/api/targets/target_test.go b/internal/tests/api/targets/target_test.go index c7966c3192..835b00f710 100644 --- a/internal/tests/api/targets/target_test.go +++ b/internal/tests/api/targets/target_test.go @@ -179,11 +179,11 @@ func TestList(t *testing.T) { require.NoError(err) expected[i] = tcr.Item } + filterItem := expected[3] ul, err = tarClient.List(tc.Context(), proj.GetPublicId()) require.NoError(err) assert.ElementsMatch(comparableSlice(expected), comparableSlice(ul.Items)) - filterItem := ul.Items[3] ul, err = tarClient.List(tc.Context(), proj.GetPublicId(), targets.WithFilter(fmt.Sprintf(`"/item/id"==%q`, filterItem.Id))) require.NoError(err) From ec608b79da1646ca098528a77bab2b939236e4c9 Mon Sep 17 00:00:00 2001 From: Johan Brandhorst-Satzkorn Date: Mon, 23 May 2022 08:21:15 -0400 Subject: [PATCH 7/9] fix(cmd): Respect DB max open connections (#2094) Both the init and migrate commands were ignoring the configured max_open_connections database setting. This fix ensures that both commands respect the limits. --- internal/cmd/commands/database/funcs.go | 3 ++- internal/cmd/commands/database/init.go | 4 +++- internal/cmd/commands/database/migrate.go | 2 +- 3 files changed, 6 insertions(+), 3 deletions(-) diff --git a/internal/cmd/commands/database/funcs.go b/internal/cmd/commands/database/funcs.go index 105c5ea1e4..fb9c69f830 100644 --- a/internal/cmd/commands/database/funcs.go +++ b/internal/cmd/commands/database/funcs.go @@ -16,7 +16,7 @@ import ( // We expect the database already to be initialized iff initialized is set to true. // Returns a cleanup function which must be called even if an error is returned and // an error code where a non-zero value indicates an error happened. -func migrateDatabase(ctx context.Context, ui cli.Ui, dialect, u string, initialized bool) (func(), int) { +func migrateDatabase(ctx context.Context, ui cli.Ui, dialect, u string, initialized bool, maxOpenConns int) (func(), int) { noop := func() {} // This database is used to keep an exclusive lock on the database for the // remainder of the command @@ -25,6 +25,7 @@ func migrateDatabase(ctx context.Context, ui cli.Ui, dialect, u string, initiali ui.Error(fmt.Errorf("Error establishing db connection: %w", err).Error()) return noop, 2 } + dBase.SetMaxOpenConns(maxOpenConns) if err := dBase.PingContext(ctx); err != nil { ui.Error(fmt.Sprintf("Unable to connect to the database at %q", u)) return noop, 2 diff --git a/internal/cmd/commands/database/init.go b/internal/cmd/commands/database/init.go index 19bef5ba8a..409748aaac 100644 --- a/internal/cmd/commands/database/init.go +++ b/internal/cmd/commands/database/init.go @@ -239,6 +239,8 @@ func (c *InitCommand) Run(args []string) (retCode int) { return base.CommandUserError } + c.DatabaseMaxOpenConnections = c.Config.Controller.Database.MaxOpenConnections + var migrationUrlToParse string if c.Config.Controller.Database.MigrationUrl != "" { migrationUrlToParse = c.Config.Controller.Database.MigrationUrl @@ -262,7 +264,7 @@ func (c *InitCommand) Run(args []string) (retCode int) { return base.CommandUserError } - clean, errCode := migrateDatabase(c.Context, c.UI, dialect, migrationUrl, false) + clean, errCode := migrateDatabase(c.Context, c.UI, dialect, migrationUrl, false, c.DatabaseMaxOpenConnections) defer clean() switch errCode { case 0: diff --git a/internal/cmd/commands/database/migrate.go b/internal/cmd/commands/database/migrate.go index 19d47210c6..63d74de9b4 100644 --- a/internal/cmd/commands/database/migrate.go +++ b/internal/cmd/commands/database/migrate.go @@ -259,7 +259,7 @@ plugins { return base.CommandUserError } - clean, errCode := migrateDatabase(c.Context, c.UI, dialect, migrationUrl, true) + clean, errCode := migrateDatabase(c.Context, c.UI, dialect, migrationUrl, true, c.Config.Controller.Database.MaxOpenConnections) defer clean() if errCode != 0 { return errCode From 1ce4ea9af5fd618897a54ec3750c71b5c5255cb7 Mon Sep 17 00:00:00 2001 From: Timothy Messier Date: Wed, 25 May 2022 14:34:53 -0400 Subject: [PATCH 8/9] chore(docker): Add dockerignore file to reduce context size (#2022) Since the Dockerfile is now at the repository root, when running building a docker image, the entire repository was being added to the context sent to the docker daemon. However, only the compiled binary and a few configs in `.release/docker` are needed to build the docker images. This ignore file will only send necessary fields into the context. This helps speed up the docker image building. For example, when building the dev image, without the ignore file: Sending build context to Docker daemon 2.043GB And with this ignore file: Sending build context to Docker daemon 130.7MB See: https://docs.docker.com/engine/reference/builder/#dockerignore-file --- .dockerignore | 4 ++++ 1 file changed, 4 insertions(+) create mode 100644 .dockerignore diff --git a/.dockerignore b/.dockerignore new file mode 100644 index 0000000000..0b18ed53d4 --- /dev/null +++ b/.dockerignore @@ -0,0 +1,4 @@ +** +!bin/** +!dist/** +!.release/docker/** From b20939ecb4c2a8c85fbcf76a46c7d82e13c857c0 Mon Sep 17 00:00:00 2001 From: Johan Brandhorst-Satzkorn Date: Wed, 25 May 2022 15:40:36 -0400 Subject: [PATCH 9/9] fix(cmd): Fix build error (#2107) This seems to have been missed when #2094 was reviewed and merged. Blame: ec608b79da1646ca098528a77bab2b939236e4c9 --- internal/cmd/commands/database/funcs_test.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/internal/cmd/commands/database/funcs_test.go b/internal/cmd/commands/database/funcs_test.go index fbecd15cc5..5f115abaff 100644 --- a/internal/cmd/commands/database/funcs_test.go +++ b/internal/cmd/commands/database/funcs_test.go @@ -193,7 +193,7 @@ func TestMigrateDatabase(t *testing.T) { t.Run(tc.name, func(t *testing.T) { u := tc.urlProvider() ui := cli.NewMockUi() - clean, errCode := migrateDatabase(ctx, ui, dialect, u, tc.initialized) + clean, errCode := migrateDatabase(ctx, ui, dialect, u, tc.initialized, 10) clean() assert.EqualValues(t, tc.expectedCode, errCode) assert.Equal(t, tc.expectedOutput, ui.OutputWriter.String())