From a66e8636464ef92ea60d75ccb501ebb3fef6913a Mon Sep 17 00:00:00 2001 From: andres-portainer <91705312+andres-portainer@users.noreply.github.com> Date: Fri, 18 Mar 2022 13:16:31 -0300 Subject: [PATCH] fix(boltdb): upgrade to the latest version to avoid problems with the race detector EE-2729 (#6638) --- api/database/boltdb/db.go | 7 ++----- api/database/boltdb/export.go | 2 +- api/datastore/init.go | 11 +++-------- api/go.mod | 2 +- api/go.sum | 5 +++-- 5 files changed, 10 insertions(+), 17 deletions(-) diff --git a/api/database/boltdb/db.go b/api/database/boltdb/db.go index e8d52286b..2741492a3 100644 --- a/api/database/boltdb/db.go +++ b/api/database/boltdb/db.go @@ -10,9 +10,9 @@ import ( "path" "time" - "github.com/boltdb/bolt" dserrors "github.com/portainer/portainer/api/dataservices/errors" "github.com/sirupsen/logrus" + bolt "go.etcd.io/bbolt" ) const ( @@ -181,10 +181,7 @@ func (connection *DbConnection) ConvertToKey(v int) []byte { func (connection *DbConnection) SetServiceName(bucketName string) error { return connection.Batch(func(tx *bolt.Tx) error { _, err := tx.CreateBucketIfNotExists([]byte(bucketName)) - if err != nil { - return err - } - return nil + return err }) } diff --git a/api/database/boltdb/export.go b/api/database/boltdb/export.go index 3d04f2aab..4d48442f8 100644 --- a/api/database/boltdb/export.go +++ b/api/database/boltdb/export.go @@ -4,8 +4,8 @@ import ( "encoding/json" "time" - "github.com/boltdb/bolt" "github.com/sirupsen/logrus" + bolt "go.etcd.io/bbolt" ) // inspired by github.com/konoui/boltdb-exporter (which has no license) diff --git a/api/datastore/init.go b/api/datastore/init.go index a2a6309b9..13f218886 100644 --- a/api/datastore/init.go +++ b/api/datastore/init.go @@ -22,23 +22,18 @@ func (store *Store) Init() error { return err } - err = store.checkOrCreateDefaultData() - if err != nil { - return err - } - - return nil + return store.checkOrCreateDefaultData() } func (store *Store) checkOrCreateInstanceID() error { - instanceID, err := store.VersionService.InstanceID() + _, err := store.VersionService.InstanceID() if store.IsErrObjectNotFound(err) { uid, err := uuid.NewV4() if err != nil { return err } - instanceID = uid.String() + instanceID := uid.String() return store.VersionService.StoreInstanceID(instanceID) } return err diff --git a/api/go.mod b/api/go.mod index 91d19086d..ecfb2a0da 100644 --- a/api/go.mod +++ b/api/go.mod @@ -9,7 +9,6 @@ require ( github.com/aws/aws-sdk-go-v2 v1.11.1 github.com/aws/aws-sdk-go-v2/credentials v1.6.2 github.com/aws/aws-sdk-go-v2/service/ecr v1.10.1 - github.com/boltdb/bolt v1.3.1 github.com/coreos/go-semver v0.3.0 github.com/dchest/uniuri v0.0.0-20160212164326-8902c56451e9 github.com/dgrijalva/jwt-go v3.2.0+incompatible @@ -38,6 +37,7 @@ require ( github.com/robfig/cron/v3 v3.0.1 github.com/sirupsen/logrus v1.8.1 github.com/stretchr/testify v1.7.0 + go.etcd.io/bbolt v1.3.6 golang.org/x/crypto v0.0.0-20220307211146-efcb8507fb70 golang.org/x/oauth2 v0.0.0-20200107190931-bf48bf16ab8d golang.org/x/sync v0.0.0-20210220032951-036812b2e83c diff --git a/api/go.sum b/api/go.sum index b565d8cd0..7ef7439bc 100644 --- a/api/go.sum +++ b/api/go.sum @@ -114,8 +114,6 @@ github.com/bits-and-blooms/bitset v1.2.0/go.mod h1:gIdJ4wp64HaoK2YrL1Q5/N7Y16edY github.com/blang/semver v3.1.0+incompatible/go.mod h1:kRBLl5iJ+tD4TcOOxsy/0fnwebNt5EWlYSAyrTnjyyk= github.com/blang/semver v3.5.1+incompatible/go.mod h1:kRBLl5iJ+tD4TcOOxsy/0fnwebNt5EWlYSAyrTnjyyk= github.com/bmizerany/assert v0.0.0-20160611221934-b7ed37b82869/go.mod h1:Ekp36dRnpXw/yCqJaO+ZrUyxD+3VXMFFr56k5XYrpB4= -github.com/boltdb/bolt v1.3.1 h1:JQmyP4ZBrce+ZQu0dY660FMfatumYDLun9hBCUVIkF4= -github.com/boltdb/bolt v1.3.1/go.mod h1:clJnj/oiGkjum5o1McbSZDSLxVThjynRyGBgiAx27Ps= github.com/bshuster-repo/logrus-logstash-hook v0.4.1/go.mod h1:zsTqEiSzDgAa/8GZR7E1qaXrhYNDKBYy5/dWPTIflbk= github.com/buger/jsonparser v0.0.0-20180808090653-f4dd9f5a6b44/go.mod h1:bbYlZJ7hK1yFx9hf58LP0zeX7UjIGs20ufpu3evjr+s= github.com/bugsnag/bugsnag-go v0.0.0-20141110184014-b1d153021fcd/go.mod h1:2oa8nejYd4cQ/b0hMIopN0lCRxU0bueqREvZLWFrtK8= @@ -749,6 +747,8 @@ github.com/yvasiyarov/newrelic_platform_go v0.0.0-20140908184405-b21fdbd4370f/go go.etcd.io/bbolt v1.3.2/go.mod h1:IbVyRI1SCnLcuJnV2u8VeU0CEYM7e686BmAb1XKL+uU= go.etcd.io/bbolt v1.3.3/go.mod h1:IbVyRI1SCnLcuJnV2u8VeU0CEYM7e686BmAb1XKL+uU= go.etcd.io/bbolt v1.3.5/go.mod h1:G5EMThwa9y8QZGBClrRx5EY+Yw9kAhnjy3bSjsnlVTQ= +go.etcd.io/bbolt v1.3.6 h1:/ecaJf0sk1l4l6V4awd65v2C3ILy7MSj+s/x1ADCIMU= +go.etcd.io/bbolt v1.3.6/go.mod h1:qXsaaIqmgQH0T+OPdb99Bf+PKfBBQVAdyD6TY9G8XM4= go.etcd.io/etcd v0.5.0-alpha.5.0.20200910180754-dd1b699fc489/go.mod h1:yVHk9ub3CSBatqGNg7GRmsnfLWtoW60w4eDYfh7vHDg= go.mozilla.org/pkcs7 v0.0.0-20200128120323-432b2356ecb1/go.mod h1:SNgMg+EgDFwmvSmLRTNKC5fegJjB7v23qTQ0XLGUNHk= go.opencensus.io v0.21.0/go.mod h1:mSImk1erAIZhrmZN+AvHh14ztQfjbGwt4TtuofqLduU= @@ -917,6 +917,7 @@ golang.org/x/sys v0.0.0-20200817155316-9781c653f443/go.mod h1:h1NjWce9XRLGQEsW7w golang.org/x/sys v0.0.0-20200909081042-eff7692f9009/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= golang.org/x/sys v0.0.0-20200916030750-2334cc1a136f/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= golang.org/x/sys v0.0.0-20200922070232-aee5d888a860/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= +golang.org/x/sys v0.0.0-20200923182605-d9f96fdee20d/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= golang.org/x/sys v0.0.0-20200930185726-fdedc70b468f/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= golang.org/x/sys v0.0.0-20201112073958-5cba982894dd/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= golang.org/x/sys v0.0.0-20201117170446-d9b008d0a637/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=