Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

The birth of a new river #1135

Merged
merged 29 commits into from
Jan 31, 2024
Merged
Show file tree
Hide file tree
Changes from 28 commits
Commits
Show all changes
29 commits
Select commit Hold shift + click to select a range
3863b4f
init commit
mina1460 Jan 16, 2024
954cead
fix broken tests
mina1460 Jan 17, 2024
e05b6f6
refactored to serialize properly and reuse clients
mina1460 Jan 17, 2024
fe173d3
reorder
mina1460 Jan 17, 2024
9092270
new logic
mina1460 Jan 19, 2024
cc39091
running tests
mina1460 Jan 19, 2024
cac4351
Changing river cleanup
kian99 Jan 25, 2024
d5ed3f3
Minor tweaks to River setup
kian99 Jan 25, 2024
3b5f5ba
Remove unneeded lines
kian99 Jan 25, 2024
6c7296f
Max connection=1
kian99 Jan 25, 2024
6f9d691
Fixed tests
kian99 Jan 25, 2024
77a48e6
Ensure river is cleaned up in cmd package tests
kian99 Jan 25, 2024
e57826a
River tweaks
kian99 Jan 26, 2024
c568390
Merge pull request #1 from kian99/distributed_transactions
mina1460 Jan 26, 2024
5c57872
pass structs as args, and use max attempts = 1 for tests
mina1460 Jan 29, 2024
a1d33fa
use max of 1 and x not min
mina1460 Jan 29, 2024
b1b1f68
use max of 1 and x not min
mina1460 Jan 29, 2024
41d00cf
resolving Ales comments
mina1460 Jan 29, 2024
a4fd254
some refactoring and fixing errors
mina1460 Jan 29, 2024
b933177
resolving Alex's comments
mina1460 Jan 29, 2024
a652b2f
handling timeouts in an elegant way
mina1460 Jan 30, 2024
4816192
refactoring river config
mina1460 Jan 30, 2024
b45ec0a
river max attempts added to params
mina1460 Jan 30, 2024
b10e350
check job id
mina1460 Jan 30, 2024
7b8dc99
migrate first
mina1460 Jan 30, 2024
8f921cd
fixed test
mina1460 Jan 30, 2024
33ac1a2
move insert and wait to river.go
mina1460 Jan 31, 2024
68b58ff
sensible overwrites for max attempts
mina1460 Jan 31, 2024
94d9327
refactor Ales's comments
mina1460 Jan 31, 2024
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions cmd/jimmctl/cmd/jimmsuite_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -156,6 +156,9 @@ func (s *jimmSuite) TearDownTest(c *gc.C) {
if s.HTTP != nil {
s.HTTP.Close()
}
if err := s.JIMM.River.Cleanup(context.Background()); err != nil {
mina1460 marked this conversation as resolved.
Show resolved Hide resolved
c.Logf("failed to cleanup river client: %s", err)
}
if err := s.JIMM.Database.Close(); err != nil {
c.Logf("failed to close database connections at tear down: %s", err)
}
Expand Down
10 changes: 10 additions & 0 deletions cmd/jimmsrv/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ import (
"context"
"net/http"
"os"
"strconv"
"strings"
"syscall"
"time"
Expand Down Expand Up @@ -74,6 +75,14 @@ func start(ctx context.Context, s *service.Service) error {
if _, ok := os.LookupEnv("INSECURE_JWKS_LOOKUP"); ok {
insecureJwksLookup = true
}
maxAttemptsStr := os.Getenv("RIVER_MAX_ATTEMPTS")
maxAttempts := 5
if maxAttemptsStr != "" {
maxAttemptsInt, err := strconv.Atoi(maxAttemptsStr)
if err == nil {
maxAttempts = maxAttemptsInt
}
}
jimmsvc, err := jimm.NewService(ctx, jimm.Params{
ControllerUUID: os.Getenv("JIMM_UUID"),
DSN: os.Getenv("JIMM_DSN"),
Expand Down Expand Up @@ -102,6 +111,7 @@ func start(ctx context.Context, s *service.Service) error {
JWTExpiryDuration: jwtExpiryDuration,
InsecureSecretStorage: insecureSecretStorage,
InsecureJwksLookup: insecureJwksLookup,
RiverMaxAttempts: maxAttempts,
})
if err != nil {
return err
Expand Down
14 changes: 10 additions & 4 deletions go.mod
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
module github.com/canonical/jimm

go 1.21.3
go 1.21.4

require (
github.com/canonical/candid v1.12.2
Expand Down Expand Up @@ -111,7 +111,7 @@ require (
github.com/cncf/xds/go v0.0.0-20230607035331-e9ce68804cb4 // indirect
github.com/coreos/go-semver v0.3.0 // indirect
github.com/coreos/go-systemd/v22 v22.3.2 // indirect
github.com/cpuguy83/go-md2man/v2 v2.0.2 // indirect
github.com/cpuguy83/go-md2man/v2 v2.0.3 // indirect
github.com/creack/pty v1.1.15 // indirect
github.com/davecgh/go-spew v1.1.1 // indirect
github.com/decred/dcrd/dcrec/secp256k1/v4 v4.2.0 // indirect
Expand Down Expand Up @@ -183,6 +183,8 @@ require (
github.com/jackc/pgproto3/v2 v2.3.1 // indirect
github.com/jackc/pgservicefile v0.0.0-20231201235250-de7065d80cb9 // indirect
github.com/jackc/pgtype v1.12.0 // indirect
github.com/jackc/pgx/v5 v5.5.1
github.com/jackc/puddle/v2 v2.2.1 // indirect
github.com/jhump/protoreflect v1.8.2 // indirect
github.com/jinzhu/inflection v1.0.0 // indirect
github.com/jinzhu/now v1.1.5 // indirect
Expand Down Expand Up @@ -290,6 +292,9 @@ require (
github.com/prometheus/client_model v0.3.0 // indirect
github.com/prometheus/common v0.37.0 // indirect
github.com/prometheus/procfs v0.11.0 // indirect
github.com/riverqueue/river v0.0.16
github.com/riverqueue/river/riverdriver v0.0.15 // indirect
github.com/riverqueue/river/riverdriver/riverpgxv5 v0.0.16
github.com/rivo/tview v0.0.0-20220610163003-691f46d6f500 // indirect
github.com/rivo/uniseg v0.4.4 // indirect
github.com/robfig/cron/v3 v3.0.1 // indirect
Expand All @@ -304,7 +309,7 @@ require (
github.com/sony/gobreaker v0.5.0 // indirect
github.com/spf13/afero v1.9.5 // indirect
github.com/spf13/cast v1.5.1 // indirect
github.com/spf13/cobra v1.7.0 // indirect
github.com/spf13/cobra v1.8.0 // indirect
github.com/spf13/jwalterweatherman v1.1.0 // indirect
github.com/spf13/pflag v1.0.5 // indirect
github.com/spf13/viper v1.16.0 // indirect
Expand Down Expand Up @@ -339,7 +344,8 @@ require (
go.uber.org/mock v0.2.0 // indirect
go.uber.org/multierr v1.8.0 // indirect
golang.org/x/crypto v0.16.0 // indirect
golang.org/x/mod v0.13.0 // indirect
golang.org/x/exp v0.0.0-20230522175609-2e198f4a06a1 // indirect
golang.org/x/mod v0.14.0 // indirect
golang.org/x/oauth2 v0.13.0 // indirect
golang.org/x/sys v0.15.0 // indirect
golang.org/x/term v0.15.0 // indirect
Expand Down
34 changes: 24 additions & 10 deletions go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -455,8 +455,8 @@ github.com/coreos/pkg v0.0.0-20180928190104-399ea9e2e55f/go.mod h1:E3G3o1h8I7cfc
github.com/cpuguy83/go-md2man v1.0.10/go.mod h1:SmD6nW6nTyfqj6ABTjUi3V3JVMnlJmwcJI5acqYI6dE=
github.com/cpuguy83/go-md2man/v2 v2.0.0-20190314233015-f79a8a8ca69d/go.mod h1:maD7wRr/U5Z6m/iR4s+kqSMx2CaBsrgA7czyZG/E6dU=
github.com/cpuguy83/go-md2man/v2 v2.0.0/go.mod h1:maD7wRr/U5Z6m/iR4s+kqSMx2CaBsrgA7czyZG/E6dU=
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/cpuguy83/go-md2man/v2 v2.0.3 h1:qMCsGGgs+MAzDFyp9LpAe1Lqy/fY/qCovCm0qnXZOBM=
github.com/cpuguy83/go-md2man/v2 v2.0.3/go.mod h1:tgQtvFlXSQOSOSIRvRPT7W67SCa46tRHOmNcaadrF8o=
github.com/creack/pty v1.1.7/go.mod h1:lj5s0c3V2DBrqTV7llrYr5NG6My20zk30Fl46Y7DoTY=
github.com/creack/pty v1.1.9/go.mod h1:oKZEueFk5CKHvIhNR5MUki03XCEU+Q6VDXinZuGJ33E=
github.com/creack/pty v1.1.11/go.mod h1:oKZEueFk5CKHvIhNR5MUki03XCEU+Q6VDXinZuGJ33E=
Expand Down Expand Up @@ -959,6 +959,8 @@ github.com/jackc/pgconn v1.9.0/go.mod h1:YctiPyvzfU11JFxoXokUOOKQXQmDMoJL9vJzHH8
github.com/jackc/pgconn v1.9.1-0.20210724152538-d89c8390a530/go.mod h1:4z2w8XhRbP1hYxkpTuBjTS3ne3J48K83+u0zoyvg2pI=
github.com/jackc/pgconn v1.13.0 h1:3L1XMNV2Zvca/8BYhzcRFS70Lr0WlDg16Di6SFGAbys=
github.com/jackc/pgconn v1.13.0/go.mod h1:AnowpAqO4CMIIJNZl2VJp+KrkAZciAkhEl0W0JIobpI=
github.com/jackc/pgerrcode v0.0.0-20220416144525-469b46aa5efa h1:s+4MhCQ6YrzisK6hFJUX53drDT4UsSW3DEhKn0ifuHw=
github.com/jackc/pgerrcode v0.0.0-20220416144525-469b46aa5efa/go.mod h1:a/s9Lp5W7n/DD0VrVoyJ00FbP2ytTPDVOivvn2bMlds=
github.com/jackc/pgio v1.0.0 h1:g12B9UwVnzGhueNavwioyEEpAmqMe1E/BN9ES+8ovkE=
github.com/jackc/pgio v1.0.0/go.mod h1:oP+2QK2wFfUWgr+gxjoBH9KGBb31Eio69xUb0w5bYf8=
github.com/jackc/pgmock v0.0.0-20190831213851-13a1b77aafa2/go.mod h1:fGZlG77KXmcq05nJLRkk0+p82V8B8Dw8KN2/V9c/OAE=
Expand Down Expand Up @@ -1002,13 +1004,17 @@ github.com/jackc/pgx/v4 v4.9.0/go.mod h1:MNGWmViCgqbZck9ujOOBN63gK9XVGILXWCvKLGK
github.com/jackc/pgx/v4 v4.12.1-0.20210724153913-640aa07df17c/go.mod h1:1QD0+tgSXP7iUjYm9C1NxKhny7lq6ee99u/z+IHFcgs=
github.com/jackc/pgx/v4 v4.17.2 h1:0Ut0rpeKwvIVbMQ1KbMBU4h6wxehBI535LK6Flheh8E=
github.com/jackc/pgx/v4 v4.17.2/go.mod h1:lcxIZN44yMIrWI78a5CpucdD14hX0SBDbNRvjDBItsw=
github.com/jackc/pgx/v5 v5.5.1 h1:5I9etrGkLrN+2XPCsi6XLlV5DITbSL/xBZdmAxFcXPI=
github.com/jackc/pgx/v5 v5.5.1/go.mod h1:Ig06C2Vu0t5qXC60W8sqIthScaEnFvojjj9dSljmHRA=
github.com/jackc/puddle v0.0.0-20190413234325-e4ced69a3a2b/go.mod h1:m4B5Dj62Y0fbyuIc15OsIqK0+JU8nkqQjsgx7dvjSWk=
github.com/jackc/puddle v0.0.0-20190608224051-11cab39313c9/go.mod h1:m4B5Dj62Y0fbyuIc15OsIqK0+JU8nkqQjsgx7dvjSWk=
github.com/jackc/puddle v1.1.0/go.mod h1:m4B5Dj62Y0fbyuIc15OsIqK0+JU8nkqQjsgx7dvjSWk=
github.com/jackc/puddle v1.1.1/go.mod h1:m4B5Dj62Y0fbyuIc15OsIqK0+JU8nkqQjsgx7dvjSWk=
github.com/jackc/puddle v1.1.2/go.mod h1:m4B5Dj62Y0fbyuIc15OsIqK0+JU8nkqQjsgx7dvjSWk=
github.com/jackc/puddle v1.1.3/go.mod h1:m4B5Dj62Y0fbyuIc15OsIqK0+JU8nkqQjsgx7dvjSWk=
github.com/jackc/puddle v1.3.0/go.mod h1:m4B5Dj62Y0fbyuIc15OsIqK0+JU8nkqQjsgx7dvjSWk=
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/jarcoal/httpmock v1.0.5/go.mod h1:ATjnClrvW/3tijVmpL/va5Z3aAyGvqU3gCT8nX0Txik=
github.com/jarcoal/httpmock v1.3.0 h1:2RJ8GP0IIaWwcC9Fp2BmVi8Kog3v2Hn7VXM3fTd+nuc=
github.com/jarcoal/httpmock v1.3.0/go.mod h1:3yb8rc4BI7TCBhFY8ng0gjuLKJNquuDNiPaZjnENuYg=
Expand Down Expand Up @@ -1305,8 +1311,8 @@ github.com/lib/pq v1.2.0/go.mod h1:5WUZQaWbwv1U+lTReE5YruASi9Al49XbQIvNi/34Woo=
github.com/lib/pq v1.3.0/go.mod h1:5WUZQaWbwv1U+lTReE5YruASi9Al49XbQIvNi/34Woo=
github.com/lib/pq v1.10.1/go.mod h1:AlVN5x4E4T544tWzH6hKfbfQvm3HdbOxrmggDNAPY9o=
github.com/lib/pq v1.10.2/go.mod h1:AlVN5x4E4T544tWzH6hKfbfQvm3HdbOxrmggDNAPY9o=
github.com/lib/pq v1.10.7 h1:p7ZhMD+KsSRozJr34udlUrhboJwWAgCg34+/ZZNvZZw=
github.com/lib/pq v1.10.7/go.mod h1:AlVN5x4E4T544tWzH6hKfbfQvm3HdbOxrmggDNAPY9o=
github.com/lib/pq v1.10.9 h1:YXG7RB+JIjhP29X+OtkiDnYaXQwpS4JEWq7dtCCRUEw=
github.com/lib/pq v1.10.9/go.mod h1:AlVN5x4E4T544tWzH6hKfbfQvm3HdbOxrmggDNAPY9o=
github.com/lightstep/lightstep-tracer-common/golang/gogo v0.0.0-20190605223551-bc2310a04743/go.mod h1:qklhhLq1aX+mtWk9cPHPzaBjWImj5ULL6C7HFJtXQMM=
github.com/lightstep/lightstep-tracer-go v0.18.1/go.mod h1:jlF1pusYV4pidLvZ+XD0UBX0ZE6WURAspgAczcDHrL4=
github.com/lucasb-eyer/go-colorful v1.2.0 h1:1nnpGOrhyZZuNyfu1QjKiUICQ74+3FNCN69Aj6K7nkY=
Expand Down Expand Up @@ -1648,6 +1654,14 @@ github.com/prometheus/tsdb v0.7.1/go.mod h1:qhTCs0VvXwvX/y3TZrWD7rabWM+ijKTux40T
github.com/pseudomuto/protoc-gen-doc v1.4.1/go.mod h1:exDTOVwqpp30eV/EDPFLZy3Pwr2sn6hBC1WIYH/UbIg=
github.com/pseudomuto/protokit v0.2.0/go.mod h1:2PdH30hxVHsup8KpBTOXTBeMVhJZVio3Q8ViKSAXT0Q=
github.com/rcrowley/go-metrics v0.0.0-20181016184325-3113b8401b8a/go.mod h1:bCqnVzQkZxMG4s8nGwiZ5l3QUCyqpo9Y+/ZMZ9VjZe4=
github.com/riverqueue/river v0.0.16 h1:rqbWGyiGMLD2OkzzPHhyR1Oh0l80ZPavXLH8+cerTIs=
github.com/riverqueue/river v0.0.16/go.mod h1:1zLtldMgoTfDj4ouXFNGsF4bzqb9Y2Ds3WuDFanugJ0=
github.com/riverqueue/river/riverdriver v0.0.15 h1:BB26eGIB+xK4dpQ9w5WUxWHbDZbk0E+tmajGRYvI/hM=
github.com/riverqueue/river/riverdriver v0.0.15/go.mod h1:vtgL7tRTSB6rzeVEDppehd/rPx3Is+WBYb17Zj0+KsE=
github.com/riverqueue/river/riverdriver/riverdatabasesql v0.0.15 h1:vBS22g1I3gaSRnYnk9yrvn+oTk0odVTmJw1pIDAFD5w=
github.com/riverqueue/river/riverdriver/riverdatabasesql v0.0.15/go.mod h1:ERxJyW2g+1oBzTn5MRfSWi6Z83I5Dumj9J+E4rCe2kc=
github.com/riverqueue/river/riverdriver/riverpgxv5 v0.0.16 h1:kUr40A6sVrw3blSxQQo3T0LgiO6qRbSzK2u4Vjml6Ww=
github.com/riverqueue/river/riverdriver/riverpgxv5 v0.0.16/go.mod h1:w365SHh6QB96Yea/SsGBdUAhGGvlWhU9+v2AVwJSjBc=
github.com/rivo/tview v0.0.0-20220610163003-691f46d6f500 h1:KvoRB2TMfMqK2NF2mIvZprDT/Ofvsa4RphWLoCmUDag=
github.com/rivo/tview v0.0.0-20220610163003-691f46d6f500/go.mod h1:WIfMkQNY+oq/mWwtsjOYHIZBuwthioY2srOmljJkTnk=
github.com/rivo/uniseg v0.1.0/go.mod h1:J6wj4VEh+S6ZtnVlnTBMWIodfgj8LQOQFoIToxlJtxc=
Expand Down Expand Up @@ -1742,8 +1756,8 @@ github.com/spf13/cobra v1.0.0/go.mod h1:/6GTrnGXV9HjY+aR4k0oJ5tcvakLuG6EuKReYlHN
github.com/spf13/cobra v1.1.1/go.mod h1:WnodtKOvamDL/PwE2M4iKs8aMDBZ5Q5klgD3qfVJQMI=
github.com/spf13/cobra v1.1.3/go.mod h1:pGADOWyqRD/YMrPZigI/zbliZ2wVD/23d+is3pSWzOo=
github.com/spf13/cobra v1.2.1/go.mod h1:ExllRjgxM/piMAM+3tAZvg8fsklGAf3tPfi+i8t68Nk=
github.com/spf13/cobra v1.7.0 h1:hyqWnYt1ZQShIddO5kBpj3vu05/++x6tJ6dg8EC572I=
github.com/spf13/cobra v1.7.0/go.mod h1:uLxZILRyS/50WlhOIKD7W6V5bgeIt+4sICxh6uRMrb0=
github.com/spf13/cobra v1.8.0 h1:7aJaZx1B85qltLMc546zn58BxxfZdR/W22ej9CFoEf0=
github.com/spf13/cobra v1.8.0/go.mod h1:WXLWApfZ71AjXPya3WOlMsY9yMs7YeiHhFVlvLyhcho=
github.com/spf13/jwalterweatherman v1.0.0/go.mod h1:cQK4TGJAtQXfYWX+Ddv3mKDzgVb68N+wFjFa4jdeBTo=
github.com/spf13/jwalterweatherman v1.1.0 h1:ue6voC5bR5F8YxI5S67j9i582FU4Qvo2bmqnqMYADFk=
github.com/spf13/jwalterweatherman v1.1.0/go.mod h1:aNWZUN0dPAAO/Ljvb5BEdw96iTZ0EXowPYD95IqWIGo=
Expand Down Expand Up @@ -1936,8 +1950,8 @@ go.uber.org/atomic v1.6.0/go.mod h1:sABNBOSYdrvTF6hTgEIbc7YasKWGhgEQZyfxyTvoXHQ=
go.uber.org/atomic v1.7.0/go.mod h1:fEN4uk6kAWBTFdckzkM89CLk9XfWZrxpCo0nPH17wJc=
go.uber.org/atomic v1.9.0 h1:ECmE8Bn/WFTYwEW/bpKD3M8VtR/zQVbavAoalC1PYyE=
go.uber.org/atomic v1.9.0/go.mod h1:fEN4uk6kAWBTFdckzkM89CLk9XfWZrxpCo0nPH17wJc=
go.uber.org/goleak v1.1.11 h1:wy28qYRKZgnJTxGxvye5/wgWr1EKjmUDGYox5mGlRlI=
go.uber.org/goleak v1.1.11/go.mod h1:cwTWslyiVhfpKIDGSZEM2HlOvcqm+tG4zioyIeLoqMQ=
go.uber.org/goleak v1.3.0 h1:2K3zAYmnTNqV73imy9J1T3WC+gmCePx2hEGkimedGto=
go.uber.org/goleak v1.3.0/go.mod h1:CoHD4mav9JJNrW/WLlf7HGZPjdw8EucARQHekz1X6bE=
go.uber.org/mock v0.2.0 h1:TaP3xedm7JaAgScZO7tlvlKrqT0p7I6OsdGB5YNSMDU=
go.uber.org/mock v0.2.0/go.mod h1:J0y0rp9L3xiff1+ZBfKxlC1fz2+aO16tw0tsDOixfuM=
go.uber.org/multierr v1.1.0/go.mod h1:wR5kodmAFQ0UK8QlbwjlSNy0Z68gJhDJUG5sjR94q/0=
Expand Down Expand Up @@ -2044,8 +2058,8 @@ golang.org/x/mod v0.4.1/go.mod h1:s0Qsj1ACt9ePp/hMypM3fl4fZqREWJwdYDEqhRiZZUA=
golang.org/x/mod v0.4.2/go.mod h1:s0Qsj1ACt9ePp/hMypM3fl4fZqREWJwdYDEqhRiZZUA=
golang.org/x/mod v0.6.0-dev.0.20220419223038-86c51ed26bb4/go.mod h1:jJ57K6gSWd91VN4djpZkiMVwK6gcyfeH4XE8wZrZaV4=
golang.org/x/mod v0.8.0/go.mod h1:iBbtSCu2XBx23ZKBPSOrRkjjQPZFPuis4dIYUhu/chs=
golang.org/x/mod v0.13.0 h1:I/DsJXRlw/8l/0c24sM9yb0T4z9liZTduXvdAWYiysY=
golang.org/x/mod v0.13.0/go.mod h1:hTbmBsO62+eylJbnUtE2MGJUyE7QWk4xUqPFrRgJ+7c=
golang.org/x/mod v0.14.0 h1:dGoOF9QVLYng8IHTm7BAyWqCqSheQ5pYWGhzW00YJr0=
golang.org/x/mod v0.14.0/go.mod h1:hTbmBsO62+eylJbnUtE2MGJUyE7QWk4xUqPFrRgJ+7c=
golang.org/x/net v0.0.0-20150829230318-ea47fc708ee3/go.mod h1:mL1N/T3taQHkDXs73rZJwtUhF3w3ftmwwsq0BUmARs4=
golang.org/x/net v0.0.0-20180406214816-61147c48b25b/go.mod h1:mL1N/T3taQHkDXs73rZJwtUhF3w3ftmwwsq0BUmARs4=
golang.org/x/net v0.0.0-20180724234803-3673e40ba225/go.mod h1:mL1N/T3taQHkDXs73rZJwtUhF3w3ftmwwsq0BUmARs4=
Expand Down
3 changes: 1 addition & 2 deletions internal/jimm/applicationoffer_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -720,7 +720,6 @@ func TestGetApplicationOfferConsumeDetails(t *testing.T) {
},
},
}

tests := []struct {
about string
user *dbmodel.User
Expand Down Expand Up @@ -938,7 +937,6 @@ func TestGetApplicationOffer(t *testing.T) {
},
},
}

err = j.Database.Migrate(ctx, false)
c.Assert(err, qt.IsNil)

Expand Down Expand Up @@ -1856,6 +1854,7 @@ func TestOffer(t *testing.T) {
}

ctx := context.Background()

err = j.Database.Migrate(ctx, false)
c.Assert(err, qt.IsNil)

Expand Down
41 changes: 21 additions & 20 deletions internal/jimm/cloudcredential_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -675,6 +675,7 @@ func TestUpdateCloudCredential(t *testing.T) {
}}
for _, test := range tests {
c.Run(test.about, func(c *qt.C) {
ctx := context.Background()
checkErrors := test.checkCredentialErrors
updateErrors := test.updateCredentialErrors
api := &jimmtest.API{
Expand Down Expand Up @@ -777,22 +778,22 @@ func TestUpdateCloudCredential(t *testing.T) {

client, _, _, err := jimmtest.SetupTestOFGAClient(c.Name())
c.Assert(err, qt.IsNil)

jimmDb := db.Database{
DB: jimmtest.PostgresDB(c, func() time.Time { return now }),
}
err = jimmDb.Migrate(ctx, false)
c.Assert(err, qt.IsNil)
river := jimmtest.NewRiver(c, nil, client, &jimmDb)
j := &jimm.JIMM{
UUID: uuid.NewString(),
Database: db.Database{
DB: jimmtest.PostgresDB(c, func() time.Time { return now }),
},
UUID: uuid.NewString(),
Database: jimmDb,
Dialer: &jimmtest.Dialer{
API: api,
},
OpenFGAClient: client,
River: river,
}

ctx := context.Background()
err = j.Database.Migrate(ctx, false)
c.Assert(err, qt.IsNil)

u, arg, expectedCredential, expectedError := test.createEnv(c, j, client)
user := openfga.NewUser(u, client)
user.JimmAdmin = test.jimmAdmin
Expand Down Expand Up @@ -845,7 +846,6 @@ users:
},
OpenFGAClient: client,
}

err = j.Database.Migrate(ctx, false)
c.Assert(err, qt.IsNil)
env.PopulateDBAndPermissions(c, j.ResourceTag(), j.Database, client)
Expand Down Expand Up @@ -1240,22 +1240,24 @@ func TestRevokeCloudCredential(t *testing.T) {

client, _, _, err := jimmtest.SetupTestOFGAClient(c.Name(), test.about)
c.Assert(err, qt.IsNil)

ctx := context.Background()
jimmDb := db.Database{
DB: jimmtest.PostgresDB(c, func() time.Time { return now }),
}
err = jimmDb.Migrate(ctx, false)
c.Assert(err, qt.IsNil)
river := jimmtest.NewRiver(c, nil, client, &jimmDb)
c.Assert(err, qt.IsNil)
j := &jimm.JIMM{
UUID: uuid.NewString(),
Database: db.Database{
DB: jimmtest.PostgresDB(c, func() time.Time { return now }),
},
UUID: uuid.NewString(),
Database: jimmDb,
Dialer: &jimmtest.Dialer{
API: api,
},
OpenFGAClient: client,
River: river,
}

ctx := context.Background()
err = j.Database.Migrate(ctx, false)
c.Assert(err, qt.IsNil)

user, tag, expectedError := test.createEnv(c, j, client)

err = j.RevokeCloudCredential(ctx, user, tag, false)
Expand Down Expand Up @@ -1382,7 +1384,6 @@ func TestGetCloudCredential(t *testing.T) {
},
OpenFGAClient: client,
}

ctx := context.Background()
err = j.Database.Migrate(ctx, false)
c.Assert(err, qt.IsNil)
Expand Down
10 changes: 6 additions & 4 deletions internal/jimm/jimm.go
Original file line number Diff line number Diff line change
Expand Up @@ -79,6 +79,8 @@ type JIMM struct {
JWKService *jimmjwx.JWKSService

JWTService *jimmjwx.JWTService

River *River
}

// ResourceTag returns JIMM's controller tag stating its UUID.
Expand Down Expand Up @@ -116,14 +118,14 @@ type permission struct {
// dial dials the controller and model specified by the given Controller
// and ModelTag. If no Dialer has been configured then an error with a
// code of CodeConnectionFailed will be returned.
func (j *JIMM) dial(ctx context.Context, ctl *dbmodel.Controller, modelTag names.ModelTag, permissons ...permission) (API, error) {
func (j *JIMM) dial(ctx context.Context, ctl *dbmodel.Controller, modelTag names.ModelTag, permissions ...permission) (API, error) {
if j == nil || j.Dialer == nil {
return nil, errors.E(errors.CodeConnectionFailed, "no dialer configured")
}
var permissionMap map[string]string
if len(permissons) > 0 {
permissionMap = make(map[string]string, len(permissons))
for _, p := range permissons {
if len(permissions) > 0 {
permissionMap = make(map[string]string, len(permissions))
for _, p := range permissions {
permissionMap[p.resource] = p.relation
}
}
Expand Down
1 change: 0 additions & 1 deletion internal/jimm/jimm_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,6 @@ func TestFindAuditEvents(t *testing.T) {
},
OpenFGAClient: client,
}

ctx := context.Background()

err = j.Database.Migrate(ctx, true)
Expand Down
Loading
Loading