2020-06-25 03:25:51 +00:00
|
|
|
package snapshot
|
|
|
|
|
|
|
|
import (
|
2021-04-06 10:08:43 +00:00
|
|
|
"context"
|
2022-08-11 04:32:12 +00:00
|
|
|
"crypto/tls"
|
2021-07-19 07:43:49 +00:00
|
|
|
"errors"
|
2020-06-25 03:25:51 +00:00
|
|
|
"time"
|
|
|
|
|
2021-02-19 01:19:01 +00:00
|
|
|
portainer "github.com/portainer/portainer/api"
|
2022-08-11 04:32:12 +00:00
|
|
|
"github.com/portainer/portainer/api/agent"
|
|
|
|
"github.com/portainer/portainer/api/crypto"
|
chore(store) EE-1981: Refactor/store/error checking, and other refactoring (#6173)
* use the Store interface IsErrObjectNotFound() to avoid revealing internal errors
Signed-off-by: Sven Dowideit <sven.dowideit@portainer.io>
* what happens when you extract the datastore interfaces into their own package
Signed-off-by: Sven Dowideit <sven.dowideit@portainer.io>
* Start renaming Storage methods
Signed-off-by: Sven Dowideit <sven.dowideit@portainer.io>
* extract the boltdb specific code from the Portainer storage code (example, the others need the same)
Signed-off-by: Sven Dowideit <sven.dowideit@portainer.io>
* more extract bolt.Tx from datastore code
Signed-off-by: Sven Dowideit <sven.dowideit@portainer.io>
* minimise imports by putting moving the struct definition into the file that needs the Service imports
Signed-off-by: Sven Dowideit <sven.dowideit@portainer.io>
* more extraction of boltdb.Tx
Signed-off-by: Sven Dowideit <sven.dowideit@portainer.io>
* extract the use of bucket.SetSequence
Signed-off-by: Sven Dowideit <sven.dowideit@portainer.io>
* almost done - just endpoint.Synchonise :/
Signed-off-by: Sven Dowideit <sven.dowideit@portainer.io>
* so, endpoint.Synchonize looks hard, but i can't find where we use it, so 'delete first refactoring'
Signed-off-by: Sven Dowideit <sven.dowideit@portainer.io>
* fix test compile errors
Signed-off-by: Sven Dowideit <sven.dowideit@portainer.io>
* test compile fixes after rebase
Signed-off-by: Sven Dowideit <sven.dowideit@portainer.io>
* fix a mis-remembering I had wrt deserialisation - last time i used AnyData - jsoniter's bindTo looks interesting for the same reason
Signed-off-by: Sven Dowideit <sven.dowideit@portainer.io>
* set us up to make the connection an interface
Signed-off-by: Sven Dowideit <sven.dowideit@portainer.io>
* make the db connection a datastore interface, and separate out our datastore services from the bolt ones
Signed-off-by: Sven Dowideit <sven.dowideit@portainer.io>
* rename methods to something less oltdb internals specific
Signed-off-by: Sven Dowideit <sven.dowideit@portainer.io>
* these errors are not boltdb secific
Signed-off-by: Sven Dowideit <sven.dowideit@portainer.io>
* start using the db-backend factory method too
Signed-off-by: Sven Dowideit <sven.dowideit@portainer.io>
* export boltdb raw in case we can't export from the service layer
Signed-off-by: Sven Dowideit <sven.dowideit@portainer.io>
* add a raw export from boltdb to yaml for broken db's, and an export services to yaml in backup
Signed-off-by: Sven Dowideit <sven.dowideit@portainer.io>
* add the version info by hand for now
Signed-off-by: Sven Dowideit <sven.dowideit@portainer.io>
* actually, the export from services can be fully typed - its the import that needs to do more work
Signed-off-by: Sven Dowideit <sven.dowideit@portainer.io>
* redo raw export, and make import capable of using it
Signed-off-by: Sven Dowideit <sven.dowideit@portainer.io>
* add DockerHub
Signed-off-by: Sven Dowideit <sven.dowideit@portainer.io>
* migration from anything older than v1.21.0 has been broken for quite a while, deleting the un-tested code
Signed-off-by: Sven Dowideit <sven.dowideit@portainer.io>
* fix go test ./... again
Signed-off-by: Sven Dowideit <sven.dowideit@portainer.io>
* my goland wasn't setup to gofmt
Signed-off-by: Sven Dowideit <sven.dowideit@portainer.io>
* move the two extremely dubious migration tests down into store, so they can use the test store code
Signed-off-by: Sven Dowideit <sven.dowideit@portainer.io>
* the migrator is now free of boltdb
Signed-off-by: Sven Dowideit <sven.dowideit@portainer.io>
* reverse goland overzealous replcement of internal with boltdb
Signed-off-by: Sven Dowideit <sven.dowideit@portainer.io>
* more undo over-zealous goland internal->boltdb
Signed-off-by: Sven Dowideit <sven.dowideit@portainer.io>
* yay, now bolt is only mentioned inside the api/database/ dir
Signed-off-by: Sven Dowideit <sven.dowideit@portainer.io>
* and this might be the last of the boltdb references?
Signed-off-by: Sven Dowideit <sven.dowideit@portainer.io>
* add todo
Signed-off-by: Sven Dowideit <sven.dowideit@portainer.io>
* extract the store code into a separate module too
Signed-off-by: Sven Dowideit <sven.dowideit@portainer.io>
* don't need the fileService in boltdb anymore
Signed-off-by: Sven Dowideit <sven.dowideit@portainer.io>
* use IsErrObjectNotFound()
Signed-off-by: Sven Dowideit <sven.dowideit@portainer.io>
* use a string to select what database backend we use
Signed-off-by: Sven Dowideit <sven.dowideit@portainer.io>
* make isNew store an ephemeral bool that doesn't stay true after we've initialised it
Signed-off-by: Sven Dowideit <sven.dowideit@portainer.io>
* move the import.json wip to a separate file so its more obvious - we'll be using it for testing, emergency fixups, and in the next part of the store work, when we improve migrations and data model lifecycles
Signed-off-by: Sven Dowideit <sven.dowideit@portainer.io>
* undo vscode formatting html
Signed-off-by: Sven Dowideit <sven.dowideit@portainer.io>
* fix app templates symbol (#6221)
* feat(webhook) EE-2125 send registry auth haeder when update swarms service via webhook (#6220)
* feat(webhook) EE-2125 add some helpers to registry utils
* feat(webhook) EE-2125 persist registryID when creating a webhook
* feat(webhook) EE-2125 send registry auth header when executing a webhook
* feat(webhook) EE-2125 send registryID to backend when creating a service with webhook
* feat(webhook) EE-2125 use the initial registry ID to create webhook on editing service screen
* feat(webhook) EE-2125 update webhook when update registry
* feat(webhook) EE-2125 add endpoint of update webhook
* feat(webhook) EE-2125 code cleanup
* feat(webhook) EE-2125 fix a typo
* feat(webhook) EE-2125 fix circle import issue with unit test
Co-authored-by: Simon Meng <simon.meng@portainer.io>
* fix(kubeconfig): show kubeconfig download button for non admin users [EE-2123] (#6204)
Co-authored-by: Simon Meng <simon.meng@portainer.io>
* fix data-cy for k8s cluster menu (#6226)
LGTM
* feat(stack): make stack created from app template editable EE-1941 (#6104)
feat(stack): make stack from app template editable
* fix(container):disable Duplicate/Edit button when the container is portainer (#6223)
* fix/ee-1909/show-pull-image-error (#6195)
Co-authored-by: sunportainer <ericsun@SG1.local>
* feat(cy): add data-cy to helm install button (#6241)
* feat(cy): add data-cy to add registry button (#6242)
* refactor(app): convert root folder files to es6 (#4159)
* refactor(app): duplicate constants as es6 exports (#4158)
* fix(docker): provide workaround to save network name variable (#6080)
* fix/EE-1862/unable-to-stop-or-remove-stack workaround for var without default value in yaml file
* fix/EE-1862/unable-to-stop-or-remove-stack check yaml file
* fixed func and var names
* wrapper error and used bool for stringset
* UT case for createNetworkEnvFile
* UT case for %s=%s
* powerful StringSet
* wrapper error for extract network name
* wrapper all the return err
* store more env
* put to env file
* make default value None
* feat: gzip static resources (#6258)
* fix(ssl)//handle --sslcert and --sslkey ee-2106 (#6203)
* fix/ee-2106/handle-sslcert-sslkey
Co-authored-by: sunportainer <ericsun@SG1.local>
* fix(server):support disable https only ee-2068 (#6232)
* fix/ee-2068/disable-forcely-https
* feat(store): implement store tests EE-2112 (#6224)
* add store tests
* add some more tests
* Update missing helm user repo methods
* remove redundant comments
* add webhook export
* update webhooks
* use the Store interface IsErrObjectNotFound() to avoid revealing internal errors
Signed-off-by: Sven Dowideit <sven.dowideit@portainer.io>
* what happens when you extract the datastore interfaces into their own package
Signed-off-by: Sven Dowideit <sven.dowideit@portainer.io>
* Start renaming Storage methods
Signed-off-by: Sven Dowideit <sven.dowideit@portainer.io>
* extract the boltdb specific code from the Portainer storage code (example, the others need the same)
Signed-off-by: Sven Dowideit <sven.dowideit@portainer.io>
* more extract bolt.Tx from datastore code
Signed-off-by: Sven Dowideit <sven.dowideit@portainer.io>
* minimise imports by putting moving the struct definition into the file that needs the Service imports
Signed-off-by: Sven Dowideit <sven.dowideit@portainer.io>
* more extraction of boltdb.Tx
Signed-off-by: Sven Dowideit <sven.dowideit@portainer.io>
* extract the use of bucket.SetSequence
Signed-off-by: Sven Dowideit <sven.dowideit@portainer.io>
* almost done - just endpoint.Synchonise :/
Signed-off-by: Sven Dowideit <sven.dowideit@portainer.io>
* so, endpoint.Synchonize looks hard, but i can't find where we use it, so 'delete first refactoring'
Signed-off-by: Sven Dowideit <sven.dowideit@portainer.io>
* fix test compile errors
Signed-off-by: Sven Dowideit <sven.dowideit@portainer.io>
* test compile fixes after rebase
Signed-off-by: Sven Dowideit <sven.dowideit@portainer.io>
* fix a mis-remembering I had wrt deserialisation - last time i used AnyData - jsoniter's bindTo looks interesting for the same reason
Signed-off-by: Sven Dowideit <sven.dowideit@portainer.io>
* set us up to make the connection an interface
Signed-off-by: Sven Dowideit <sven.dowideit@portainer.io>
* make the db connection a datastore interface, and separate out our datastore services from the bolt ones
Signed-off-by: Sven Dowideit <sven.dowideit@portainer.io>
* rename methods to something less oltdb internals specific
Signed-off-by: Sven Dowideit <sven.dowideit@portainer.io>
* these errors are not boltdb secific
Signed-off-by: Sven Dowideit <sven.dowideit@portainer.io>
* start using the db-backend factory method too
Signed-off-by: Sven Dowideit <sven.dowideit@portainer.io>
* export boltdb raw in case we can't export from the service layer
Signed-off-by: Sven Dowideit <sven.dowideit@portainer.io>
* add a raw export from boltdb to yaml for broken db's, and an export services to yaml in backup
Signed-off-by: Sven Dowideit <sven.dowideit@portainer.io>
* add the version info by hand for now
Signed-off-by: Sven Dowideit <sven.dowideit@portainer.io>
* actually, the export from services can be fully typed - its the import that needs to do more work
Signed-off-by: Sven Dowideit <sven.dowideit@portainer.io>
* redo raw export, and make import capable of using it
Signed-off-by: Sven Dowideit <sven.dowideit@portainer.io>
* add DockerHub
Signed-off-by: Sven Dowideit <sven.dowideit@portainer.io>
* migration from anything older than v1.21.0 has been broken for quite a while, deleting the un-tested code
Signed-off-by: Sven Dowideit <sven.dowideit@portainer.io>
* fix go test ./... again
Signed-off-by: Sven Dowideit <sven.dowideit@portainer.io>
* my goland wasn't setup to gofmt
Signed-off-by: Sven Dowideit <sven.dowideit@portainer.io>
* move the two extremely dubious migration tests down into store, so they can use the test store code
Signed-off-by: Sven Dowideit <sven.dowideit@portainer.io>
* the migrator is now free of boltdb
Signed-off-by: Sven Dowideit <sven.dowideit@portainer.io>
* reverse goland overzealous replcement of internal with boltdb
Signed-off-by: Sven Dowideit <sven.dowideit@portainer.io>
* more undo over-zealous goland internal->boltdb
Signed-off-by: Sven Dowideit <sven.dowideit@portainer.io>
* yay, now bolt is only mentioned inside the api/database/ dir
Signed-off-by: Sven Dowideit <sven.dowideit@portainer.io>
* and this might be the last of the boltdb references?
Signed-off-by: Sven Dowideit <sven.dowideit@portainer.io>
* add todo
Signed-off-by: Sven Dowideit <sven.dowideit@portainer.io>
* extract the store code into a separate module too
Signed-off-by: Sven Dowideit <sven.dowideit@portainer.io>
* don't need the fileService in boltdb anymore
Signed-off-by: Sven Dowideit <sven.dowideit@portainer.io>
* use IsErrObjectNotFound()
Signed-off-by: Sven Dowideit <sven.dowideit@portainer.io>
* use a string to select what database backend we use
Signed-off-by: Sven Dowideit <sven.dowideit@portainer.io>
* make isNew store an ephemeral bool that doesn't stay true after we've initialised it
Signed-off-by: Sven Dowideit <sven.dowideit@portainer.io>
* move the import.json wip to a separate file so its more obvious - we'll be using it for testing, emergency fixups, and in the next part of the store work, when we improve migrations and data model lifecycles
Signed-off-by: Sven Dowideit <sven.dowideit@portainer.io>
* undo vscode formatting html
Signed-off-by: Sven Dowideit <sven.dowideit@portainer.io>
* Update missing helm user repo methods
* feat(store): implement store tests EE-2112 (#6224)
* add store tests
* add some more tests
* remove redundant comments
* add webhook export
* update webhooks
* fix build issues after rebasing
* move migratorparams
* remove unneeded integer type conversions
* disable the db import/export for now
Co-authored-by: Richard Wei <54336863+WaysonWei@users.noreply.github.com>
Co-authored-by: cong meng <mcpacino@gmail.com>
Co-authored-by: Simon Meng <simon.meng@portainer.io>
Co-authored-by: Marcelo Rydel <marcelorydel26@gmail.com>
Co-authored-by: Hao Zhang <hao.zhang@portainer.io>
Co-authored-by: sunportainer <93502624+sunportainer@users.noreply.github.com>
Co-authored-by: sunportainer <ericsun@SG1.local>
Co-authored-by: wheresolivia <78844659+wheresolivia@users.noreply.github.com>
Co-authored-by: Chaim Lev-Ari <chiptus@users.noreply.github.com>
Co-authored-by: Chao Geng <93526589+chaogeng77977@users.noreply.github.com>
Co-authored-by: Dmitry Salakhov <to@dimasalakhov.com>
Co-authored-by: Matt Hook <hookenz@gmail.com>
2021-12-15 02:26:09 +00:00
|
|
|
"github.com/portainer/portainer/api/dataservices"
|
2023-07-14 15:34:50 +00:00
|
|
|
"github.com/portainer/portainer/api/internal/endpointutils"
|
2023-05-17 14:57:05 +00:00
|
|
|
"github.com/portainer/portainer/pkg/featureflags"
|
2022-09-16 16:18:44 +00:00
|
|
|
|
|
|
|
"github.com/rs/zerolog/log"
|
2020-06-25 03:25:51 +00:00
|
|
|
)
|
|
|
|
|
2021-09-20 00:14:22 +00:00
|
|
|
// Service repesents a service to manage environment(endpoint) snapshots.
|
2020-07-05 23:21:03 +00:00
|
|
|
// It provides an interface to start background snapshots as well as
|
2021-09-20 00:14:22 +00:00
|
|
|
// specific Docker/Kubernetes environment(endpoint) snapshot methods.
|
2020-06-25 03:25:51 +00:00
|
|
|
type Service struct {
|
chore(store) EE-1981: Refactor/store/error checking, and other refactoring (#6173)
* use the Store interface IsErrObjectNotFound() to avoid revealing internal errors
Signed-off-by: Sven Dowideit <sven.dowideit@portainer.io>
* what happens when you extract the datastore interfaces into their own package
Signed-off-by: Sven Dowideit <sven.dowideit@portainer.io>
* Start renaming Storage methods
Signed-off-by: Sven Dowideit <sven.dowideit@portainer.io>
* extract the boltdb specific code from the Portainer storage code (example, the others need the same)
Signed-off-by: Sven Dowideit <sven.dowideit@portainer.io>
* more extract bolt.Tx from datastore code
Signed-off-by: Sven Dowideit <sven.dowideit@portainer.io>
* minimise imports by putting moving the struct definition into the file that needs the Service imports
Signed-off-by: Sven Dowideit <sven.dowideit@portainer.io>
* more extraction of boltdb.Tx
Signed-off-by: Sven Dowideit <sven.dowideit@portainer.io>
* extract the use of bucket.SetSequence
Signed-off-by: Sven Dowideit <sven.dowideit@portainer.io>
* almost done - just endpoint.Synchonise :/
Signed-off-by: Sven Dowideit <sven.dowideit@portainer.io>
* so, endpoint.Synchonize looks hard, but i can't find where we use it, so 'delete first refactoring'
Signed-off-by: Sven Dowideit <sven.dowideit@portainer.io>
* fix test compile errors
Signed-off-by: Sven Dowideit <sven.dowideit@portainer.io>
* test compile fixes after rebase
Signed-off-by: Sven Dowideit <sven.dowideit@portainer.io>
* fix a mis-remembering I had wrt deserialisation - last time i used AnyData - jsoniter's bindTo looks interesting for the same reason
Signed-off-by: Sven Dowideit <sven.dowideit@portainer.io>
* set us up to make the connection an interface
Signed-off-by: Sven Dowideit <sven.dowideit@portainer.io>
* make the db connection a datastore interface, and separate out our datastore services from the bolt ones
Signed-off-by: Sven Dowideit <sven.dowideit@portainer.io>
* rename methods to something less oltdb internals specific
Signed-off-by: Sven Dowideit <sven.dowideit@portainer.io>
* these errors are not boltdb secific
Signed-off-by: Sven Dowideit <sven.dowideit@portainer.io>
* start using the db-backend factory method too
Signed-off-by: Sven Dowideit <sven.dowideit@portainer.io>
* export boltdb raw in case we can't export from the service layer
Signed-off-by: Sven Dowideit <sven.dowideit@portainer.io>
* add a raw export from boltdb to yaml for broken db's, and an export services to yaml in backup
Signed-off-by: Sven Dowideit <sven.dowideit@portainer.io>
* add the version info by hand for now
Signed-off-by: Sven Dowideit <sven.dowideit@portainer.io>
* actually, the export from services can be fully typed - its the import that needs to do more work
Signed-off-by: Sven Dowideit <sven.dowideit@portainer.io>
* redo raw export, and make import capable of using it
Signed-off-by: Sven Dowideit <sven.dowideit@portainer.io>
* add DockerHub
Signed-off-by: Sven Dowideit <sven.dowideit@portainer.io>
* migration from anything older than v1.21.0 has been broken for quite a while, deleting the un-tested code
Signed-off-by: Sven Dowideit <sven.dowideit@portainer.io>
* fix go test ./... again
Signed-off-by: Sven Dowideit <sven.dowideit@portainer.io>
* my goland wasn't setup to gofmt
Signed-off-by: Sven Dowideit <sven.dowideit@portainer.io>
* move the two extremely dubious migration tests down into store, so they can use the test store code
Signed-off-by: Sven Dowideit <sven.dowideit@portainer.io>
* the migrator is now free of boltdb
Signed-off-by: Sven Dowideit <sven.dowideit@portainer.io>
* reverse goland overzealous replcement of internal with boltdb
Signed-off-by: Sven Dowideit <sven.dowideit@portainer.io>
* more undo over-zealous goland internal->boltdb
Signed-off-by: Sven Dowideit <sven.dowideit@portainer.io>
* yay, now bolt is only mentioned inside the api/database/ dir
Signed-off-by: Sven Dowideit <sven.dowideit@portainer.io>
* and this might be the last of the boltdb references?
Signed-off-by: Sven Dowideit <sven.dowideit@portainer.io>
* add todo
Signed-off-by: Sven Dowideit <sven.dowideit@portainer.io>
* extract the store code into a separate module too
Signed-off-by: Sven Dowideit <sven.dowideit@portainer.io>
* don't need the fileService in boltdb anymore
Signed-off-by: Sven Dowideit <sven.dowideit@portainer.io>
* use IsErrObjectNotFound()
Signed-off-by: Sven Dowideit <sven.dowideit@portainer.io>
* use a string to select what database backend we use
Signed-off-by: Sven Dowideit <sven.dowideit@portainer.io>
* make isNew store an ephemeral bool that doesn't stay true after we've initialised it
Signed-off-by: Sven Dowideit <sven.dowideit@portainer.io>
* move the import.json wip to a separate file so its more obvious - we'll be using it for testing, emergency fixups, and in the next part of the store work, when we improve migrations and data model lifecycles
Signed-off-by: Sven Dowideit <sven.dowideit@portainer.io>
* undo vscode formatting html
Signed-off-by: Sven Dowideit <sven.dowideit@portainer.io>
* fix app templates symbol (#6221)
* feat(webhook) EE-2125 send registry auth haeder when update swarms service via webhook (#6220)
* feat(webhook) EE-2125 add some helpers to registry utils
* feat(webhook) EE-2125 persist registryID when creating a webhook
* feat(webhook) EE-2125 send registry auth header when executing a webhook
* feat(webhook) EE-2125 send registryID to backend when creating a service with webhook
* feat(webhook) EE-2125 use the initial registry ID to create webhook on editing service screen
* feat(webhook) EE-2125 update webhook when update registry
* feat(webhook) EE-2125 add endpoint of update webhook
* feat(webhook) EE-2125 code cleanup
* feat(webhook) EE-2125 fix a typo
* feat(webhook) EE-2125 fix circle import issue with unit test
Co-authored-by: Simon Meng <simon.meng@portainer.io>
* fix(kubeconfig): show kubeconfig download button for non admin users [EE-2123] (#6204)
Co-authored-by: Simon Meng <simon.meng@portainer.io>
* fix data-cy for k8s cluster menu (#6226)
LGTM
* feat(stack): make stack created from app template editable EE-1941 (#6104)
feat(stack): make stack from app template editable
* fix(container):disable Duplicate/Edit button when the container is portainer (#6223)
* fix/ee-1909/show-pull-image-error (#6195)
Co-authored-by: sunportainer <ericsun@SG1.local>
* feat(cy): add data-cy to helm install button (#6241)
* feat(cy): add data-cy to add registry button (#6242)
* refactor(app): convert root folder files to es6 (#4159)
* refactor(app): duplicate constants as es6 exports (#4158)
* fix(docker): provide workaround to save network name variable (#6080)
* fix/EE-1862/unable-to-stop-or-remove-stack workaround for var without default value in yaml file
* fix/EE-1862/unable-to-stop-or-remove-stack check yaml file
* fixed func and var names
* wrapper error and used bool for stringset
* UT case for createNetworkEnvFile
* UT case for %s=%s
* powerful StringSet
* wrapper error for extract network name
* wrapper all the return err
* store more env
* put to env file
* make default value None
* feat: gzip static resources (#6258)
* fix(ssl)//handle --sslcert and --sslkey ee-2106 (#6203)
* fix/ee-2106/handle-sslcert-sslkey
Co-authored-by: sunportainer <ericsun@SG1.local>
* fix(server):support disable https only ee-2068 (#6232)
* fix/ee-2068/disable-forcely-https
* feat(store): implement store tests EE-2112 (#6224)
* add store tests
* add some more tests
* Update missing helm user repo methods
* remove redundant comments
* add webhook export
* update webhooks
* use the Store interface IsErrObjectNotFound() to avoid revealing internal errors
Signed-off-by: Sven Dowideit <sven.dowideit@portainer.io>
* what happens when you extract the datastore interfaces into their own package
Signed-off-by: Sven Dowideit <sven.dowideit@portainer.io>
* Start renaming Storage methods
Signed-off-by: Sven Dowideit <sven.dowideit@portainer.io>
* extract the boltdb specific code from the Portainer storage code (example, the others need the same)
Signed-off-by: Sven Dowideit <sven.dowideit@portainer.io>
* more extract bolt.Tx from datastore code
Signed-off-by: Sven Dowideit <sven.dowideit@portainer.io>
* minimise imports by putting moving the struct definition into the file that needs the Service imports
Signed-off-by: Sven Dowideit <sven.dowideit@portainer.io>
* more extraction of boltdb.Tx
Signed-off-by: Sven Dowideit <sven.dowideit@portainer.io>
* extract the use of bucket.SetSequence
Signed-off-by: Sven Dowideit <sven.dowideit@portainer.io>
* almost done - just endpoint.Synchonise :/
Signed-off-by: Sven Dowideit <sven.dowideit@portainer.io>
* so, endpoint.Synchonize looks hard, but i can't find where we use it, so 'delete first refactoring'
Signed-off-by: Sven Dowideit <sven.dowideit@portainer.io>
* fix test compile errors
Signed-off-by: Sven Dowideit <sven.dowideit@portainer.io>
* test compile fixes after rebase
Signed-off-by: Sven Dowideit <sven.dowideit@portainer.io>
* fix a mis-remembering I had wrt deserialisation - last time i used AnyData - jsoniter's bindTo looks interesting for the same reason
Signed-off-by: Sven Dowideit <sven.dowideit@portainer.io>
* set us up to make the connection an interface
Signed-off-by: Sven Dowideit <sven.dowideit@portainer.io>
* make the db connection a datastore interface, and separate out our datastore services from the bolt ones
Signed-off-by: Sven Dowideit <sven.dowideit@portainer.io>
* rename methods to something less oltdb internals specific
Signed-off-by: Sven Dowideit <sven.dowideit@portainer.io>
* these errors are not boltdb secific
Signed-off-by: Sven Dowideit <sven.dowideit@portainer.io>
* start using the db-backend factory method too
Signed-off-by: Sven Dowideit <sven.dowideit@portainer.io>
* export boltdb raw in case we can't export from the service layer
Signed-off-by: Sven Dowideit <sven.dowideit@portainer.io>
* add a raw export from boltdb to yaml for broken db's, and an export services to yaml in backup
Signed-off-by: Sven Dowideit <sven.dowideit@portainer.io>
* add the version info by hand for now
Signed-off-by: Sven Dowideit <sven.dowideit@portainer.io>
* actually, the export from services can be fully typed - its the import that needs to do more work
Signed-off-by: Sven Dowideit <sven.dowideit@portainer.io>
* redo raw export, and make import capable of using it
Signed-off-by: Sven Dowideit <sven.dowideit@portainer.io>
* add DockerHub
Signed-off-by: Sven Dowideit <sven.dowideit@portainer.io>
* migration from anything older than v1.21.0 has been broken for quite a while, deleting the un-tested code
Signed-off-by: Sven Dowideit <sven.dowideit@portainer.io>
* fix go test ./... again
Signed-off-by: Sven Dowideit <sven.dowideit@portainer.io>
* my goland wasn't setup to gofmt
Signed-off-by: Sven Dowideit <sven.dowideit@portainer.io>
* move the two extremely dubious migration tests down into store, so they can use the test store code
Signed-off-by: Sven Dowideit <sven.dowideit@portainer.io>
* the migrator is now free of boltdb
Signed-off-by: Sven Dowideit <sven.dowideit@portainer.io>
* reverse goland overzealous replcement of internal with boltdb
Signed-off-by: Sven Dowideit <sven.dowideit@portainer.io>
* more undo over-zealous goland internal->boltdb
Signed-off-by: Sven Dowideit <sven.dowideit@portainer.io>
* yay, now bolt is only mentioned inside the api/database/ dir
Signed-off-by: Sven Dowideit <sven.dowideit@portainer.io>
* and this might be the last of the boltdb references?
Signed-off-by: Sven Dowideit <sven.dowideit@portainer.io>
* add todo
Signed-off-by: Sven Dowideit <sven.dowideit@portainer.io>
* extract the store code into a separate module too
Signed-off-by: Sven Dowideit <sven.dowideit@portainer.io>
* don't need the fileService in boltdb anymore
Signed-off-by: Sven Dowideit <sven.dowideit@portainer.io>
* use IsErrObjectNotFound()
Signed-off-by: Sven Dowideit <sven.dowideit@portainer.io>
* use a string to select what database backend we use
Signed-off-by: Sven Dowideit <sven.dowideit@portainer.io>
* make isNew store an ephemeral bool that doesn't stay true after we've initialised it
Signed-off-by: Sven Dowideit <sven.dowideit@portainer.io>
* move the import.json wip to a separate file so its more obvious - we'll be using it for testing, emergency fixups, and in the next part of the store work, when we improve migrations and data model lifecycles
Signed-off-by: Sven Dowideit <sven.dowideit@portainer.io>
* undo vscode formatting html
Signed-off-by: Sven Dowideit <sven.dowideit@portainer.io>
* Update missing helm user repo methods
* feat(store): implement store tests EE-2112 (#6224)
* add store tests
* add some more tests
* remove redundant comments
* add webhook export
* update webhooks
* fix build issues after rebasing
* move migratorparams
* remove unneeded integer type conversions
* disable the db import/export for now
Co-authored-by: Richard Wei <54336863+WaysonWei@users.noreply.github.com>
Co-authored-by: cong meng <mcpacino@gmail.com>
Co-authored-by: Simon Meng <simon.meng@portainer.io>
Co-authored-by: Marcelo Rydel <marcelorydel26@gmail.com>
Co-authored-by: Hao Zhang <hao.zhang@portainer.io>
Co-authored-by: sunportainer <93502624+sunportainer@users.noreply.github.com>
Co-authored-by: sunportainer <ericsun@SG1.local>
Co-authored-by: wheresolivia <78844659+wheresolivia@users.noreply.github.com>
Co-authored-by: Chaim Lev-Ari <chiptus@users.noreply.github.com>
Co-authored-by: Chao Geng <93526589+chaogeng77977@users.noreply.github.com>
Co-authored-by: Dmitry Salakhov <to@dimasalakhov.com>
Co-authored-by: Matt Hook <hookenz@gmail.com>
2021-12-15 02:26:09 +00:00
|
|
|
dataStore dataservices.DataStore
|
2022-03-16 14:27:28 +00:00
|
|
|
snapshotIntervalCh chan time.Duration
|
2020-06-25 03:25:51 +00:00
|
|
|
snapshotIntervalInSeconds float64
|
2020-07-05 23:21:03 +00:00
|
|
|
dockerSnapshotter portainer.DockerSnapshotter
|
|
|
|
kubernetesSnapshotter portainer.KubernetesSnapshotter
|
2021-04-06 10:08:43 +00:00
|
|
|
shutdownCtx context.Context
|
2020-06-25 03:25:51 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
// NewService creates a new instance of a service
|
2022-01-28 12:28:34 +00:00
|
|
|
func NewService(snapshotIntervalFromFlag string, dataStore dataservices.DataStore, dockerSnapshotter portainer.DockerSnapshotter, kubernetesSnapshotter portainer.KubernetesSnapshotter, shutdownCtx context.Context) (*Service, error) {
|
2022-03-16 14:27:28 +00:00
|
|
|
interval, err := parseSnapshotFrequency(snapshotIntervalFromFlag, dataStore)
|
2020-06-25 03:25:51 +00:00
|
|
|
if err != nil {
|
|
|
|
return nil, err
|
|
|
|
}
|
|
|
|
|
|
|
|
return &Service{
|
|
|
|
dataStore: dataStore,
|
2022-03-16 14:27:28 +00:00
|
|
|
snapshotIntervalCh: make(chan time.Duration),
|
|
|
|
snapshotIntervalInSeconds: interval,
|
2020-07-05 23:21:03 +00:00
|
|
|
dockerSnapshotter: dockerSnapshotter,
|
|
|
|
kubernetesSnapshotter: kubernetesSnapshotter,
|
2021-04-06 10:08:43 +00:00
|
|
|
shutdownCtx: shutdownCtx,
|
2020-06-25 03:25:51 +00:00
|
|
|
}, nil
|
|
|
|
}
|
|
|
|
|
2023-07-14 15:34:50 +00:00
|
|
|
// NewBackgroundSnapshotter queues snapshots of existing edge environments that
|
|
|
|
// do not have one already
|
|
|
|
func NewBackgroundSnapshotter(dataStore dataservices.DataStore, tunnelService portainer.ReverseTunnelService) {
|
|
|
|
var endpointIDs []portainer.EndpointID
|
|
|
|
|
|
|
|
err := dataStore.ViewTx(func(tx dataservices.DataStoreTx) error {
|
|
|
|
endpoints, err := tx.Endpoint().Endpoints()
|
|
|
|
if err != nil {
|
|
|
|
return err
|
|
|
|
}
|
|
|
|
|
|
|
|
for _, e := range endpoints {
|
|
|
|
if !endpointutils.IsEdgeEndpoint(&e) {
|
|
|
|
continue
|
|
|
|
}
|
|
|
|
|
|
|
|
s, err := tx.Snapshot().Read(e.ID)
|
|
|
|
if dataservices.IsErrObjectNotFound(err) ||
|
|
|
|
(err == nil && s.Docker == nil && s.Kubernetes == nil) {
|
|
|
|
endpointIDs = append(endpointIDs, e.ID)
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
return nil
|
|
|
|
})
|
|
|
|
if err != nil {
|
|
|
|
log.Error().Err(err).Msg("background snapshotter failure")
|
|
|
|
return
|
|
|
|
}
|
|
|
|
|
|
|
|
for _, endpointID := range endpointIDs {
|
|
|
|
tunnelService.SetTunnelStatusToActive(endpointID)
|
|
|
|
time.Sleep(10 * time.Second)
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2022-01-28 12:28:34 +00:00
|
|
|
func parseSnapshotFrequency(snapshotInterval string, dataStore dataservices.DataStore) (float64, error) {
|
|
|
|
if snapshotInterval == "" {
|
|
|
|
settings, err := dataStore.Settings().Settings()
|
|
|
|
if err != nil {
|
|
|
|
return 0, err
|
|
|
|
}
|
2023-05-17 14:57:05 +00:00
|
|
|
|
2022-01-28 12:28:34 +00:00
|
|
|
snapshotInterval = settings.SnapshotInterval
|
|
|
|
if snapshotInterval == "" {
|
|
|
|
snapshotInterval = portainer.DefaultSnapshotInterval
|
|
|
|
}
|
|
|
|
}
|
2023-05-17 14:57:05 +00:00
|
|
|
|
2022-01-28 12:28:34 +00:00
|
|
|
snapshotFrequency, err := time.ParseDuration(snapshotInterval)
|
|
|
|
if err != nil {
|
|
|
|
return 0, err
|
|
|
|
}
|
2023-05-17 14:57:05 +00:00
|
|
|
|
2022-01-28 12:28:34 +00:00
|
|
|
return snapshotFrequency.Seconds(), nil
|
|
|
|
}
|
|
|
|
|
2021-09-20 00:14:22 +00:00
|
|
|
// Start will start a background routine to execute periodic snapshots of environments(endpoints)
|
2020-06-25 03:25:51 +00:00
|
|
|
func (service *Service) Start() {
|
2022-03-16 14:27:28 +00:00
|
|
|
go service.startSnapshotLoop()
|
2020-06-25 03:25:51 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
// SetSnapshotInterval sets the snapshot interval and resets the service
|
|
|
|
func (service *Service) SetSnapshotInterval(snapshotInterval string) error {
|
2022-03-16 14:27:28 +00:00
|
|
|
interval, err := time.ParseDuration(snapshotInterval)
|
2020-06-25 03:25:51 +00:00
|
|
|
if err != nil {
|
|
|
|
return err
|
|
|
|
}
|
|
|
|
|
2022-03-16 14:27:28 +00:00
|
|
|
service.snapshotIntervalCh <- interval
|
2020-06-25 03:25:51 +00:00
|
|
|
|
|
|
|
return nil
|
|
|
|
}
|
|
|
|
|
2021-09-20 00:14:22 +00:00
|
|
|
// SupportDirectSnapshot checks whether an environment(endpoint) can be used to trigger a direct a snapshot.
|
|
|
|
// It is mostly true for all environments(endpoints) except Edge and Azure environments(endpoints).
|
2020-07-05 23:21:03 +00:00
|
|
|
func SupportDirectSnapshot(endpoint *portainer.Endpoint) bool {
|
|
|
|
switch endpoint.Type {
|
|
|
|
case portainer.EdgeAgentOnDockerEnvironment, portainer.EdgeAgentOnKubernetesEnvironment, portainer.AzureEnvironment:
|
|
|
|
return false
|
|
|
|
}
|
2023-05-17 14:57:05 +00:00
|
|
|
|
2020-07-05 23:21:03 +00:00
|
|
|
return true
|
|
|
|
}
|
|
|
|
|
2021-09-20 00:14:22 +00:00
|
|
|
// SnapshotEndpoint will create a snapshot of the environment(endpoint) based on the environment(endpoint) type.
|
|
|
|
// If the snapshot is a success, it will be associated to the environment(endpoint).
|
2020-07-05 23:21:03 +00:00
|
|
|
func (service *Service) SnapshotEndpoint(endpoint *portainer.Endpoint) error {
|
2022-08-11 04:32:12 +00:00
|
|
|
if endpoint.Type == portainer.AgentOnDockerEnvironment || endpoint.Type == portainer.AgentOnKubernetesEnvironment {
|
|
|
|
var err error
|
|
|
|
var tlsConfig *tls.Config
|
|
|
|
if endpoint.TLSConfig.TLS {
|
|
|
|
tlsConfig, err = crypto.CreateTLSConfigurationFromDisk(endpoint.TLSConfig.TLSCACertPath, endpoint.TLSConfig.TLSCertPath, endpoint.TLSConfig.TLSKeyPath, endpoint.TLSConfig.TLSSkipVerify)
|
|
|
|
if err != nil {
|
|
|
|
return err
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
_, version, err := agent.GetAgentVersionAndPlatform(endpoint.URL, tlsConfig)
|
|
|
|
if err != nil {
|
|
|
|
return err
|
|
|
|
}
|
|
|
|
|
|
|
|
endpoint.Agent.Version = version
|
|
|
|
}
|
|
|
|
|
2020-07-05 23:21:03 +00:00
|
|
|
switch endpoint.Type {
|
|
|
|
case portainer.AzureEnvironment:
|
|
|
|
return nil
|
|
|
|
case portainer.KubernetesLocalEnvironment, portainer.AgentOnKubernetesEnvironment, portainer.EdgeAgentOnKubernetesEnvironment:
|
|
|
|
return service.snapshotKubernetesEndpoint(endpoint)
|
|
|
|
}
|
|
|
|
|
|
|
|
return service.snapshotDockerEndpoint(endpoint)
|
|
|
|
}
|
|
|
|
|
2022-09-22 20:05:10 +00:00
|
|
|
func (service *Service) Create(snapshot portainer.Snapshot) error {
|
|
|
|
return service.dataStore.Snapshot().Create(&snapshot)
|
|
|
|
}
|
|
|
|
|
|
|
|
func (service *Service) FillSnapshotData(endpoint *portainer.Endpoint) error {
|
2022-11-16 16:38:39 +00:00
|
|
|
return FillSnapshotData(service.dataStore, endpoint)
|
|
|
|
}
|
|
|
|
|
2023-05-17 14:57:05 +00:00
|
|
|
func FillSnapshotData(tx dataservices.DataStoreTx, endpoint *portainer.Endpoint) error {
|
2023-06-22 21:28:07 +00:00
|
|
|
snapshot, err := tx.Snapshot().Read(endpoint.ID)
|
2023-05-17 14:57:05 +00:00
|
|
|
if tx.IsErrObjectNotFound(err) {
|
2022-09-22 20:05:10 +00:00
|
|
|
endpoint.Snapshots = []portainer.DockerSnapshot{}
|
|
|
|
endpoint.Kubernetes.Snapshots = []portainer.KubernetesSnapshot{}
|
|
|
|
|
|
|
|
return nil
|
|
|
|
}
|
|
|
|
|
|
|
|
if err != nil {
|
|
|
|
return err
|
|
|
|
}
|
|
|
|
|
|
|
|
if snapshot.Docker != nil {
|
|
|
|
endpoint.Snapshots = []portainer.DockerSnapshot{*snapshot.Docker}
|
|
|
|
}
|
|
|
|
|
|
|
|
if snapshot.Kubernetes != nil {
|
|
|
|
endpoint.Kubernetes.Snapshots = []portainer.KubernetesSnapshot{*snapshot.Kubernetes}
|
|
|
|
}
|
|
|
|
|
|
|
|
return nil
|
|
|
|
}
|
|
|
|
|
2020-07-05 23:21:03 +00:00
|
|
|
func (service *Service) snapshotKubernetesEndpoint(endpoint *portainer.Endpoint) error {
|
2022-09-22 20:05:10 +00:00
|
|
|
kubernetesSnapshot, err := service.kubernetesSnapshotter.CreateSnapshot(endpoint)
|
2020-07-05 23:21:03 +00:00
|
|
|
if err != nil {
|
|
|
|
return err
|
|
|
|
}
|
|
|
|
|
2022-09-22 20:05:10 +00:00
|
|
|
if kubernetesSnapshot != nil {
|
|
|
|
snapshot := &portainer.Snapshot{EndpointID: endpoint.ID, Kubernetes: kubernetesSnapshot}
|
|
|
|
|
|
|
|
return service.dataStore.Snapshot().Create(snapshot)
|
2020-07-05 23:21:03 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
return nil
|
|
|
|
}
|
|
|
|
|
|
|
|
func (service *Service) snapshotDockerEndpoint(endpoint *portainer.Endpoint) error {
|
2022-09-22 20:05:10 +00:00
|
|
|
dockerSnapshot, err := service.dockerSnapshotter.CreateSnapshot(endpoint)
|
2020-07-05 23:21:03 +00:00
|
|
|
if err != nil {
|
|
|
|
return err
|
|
|
|
}
|
|
|
|
|
2022-09-22 20:05:10 +00:00
|
|
|
if dockerSnapshot != nil {
|
|
|
|
snapshot := &portainer.Snapshot{EndpointID: endpoint.ID, Docker: dockerSnapshot}
|
|
|
|
|
|
|
|
return service.dataStore.Snapshot().Create(snapshot)
|
2020-07-05 23:21:03 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
return nil
|
|
|
|
}
|
|
|
|
|
2022-03-16 14:27:28 +00:00
|
|
|
func (service *Service) startSnapshotLoop() {
|
2020-06-25 03:25:51 +00:00
|
|
|
ticker := time.NewTicker(time.Duration(service.snapshotIntervalInSeconds) * time.Second)
|
|
|
|
|
2022-03-16 14:27:28 +00:00
|
|
|
err := service.snapshotEndpoints()
|
|
|
|
if err != nil {
|
2022-09-16 16:18:44 +00:00
|
|
|
log.Error().Err(err).Msg("background schedule error (environment snapshot)")
|
2022-03-16 14:27:28 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
for {
|
|
|
|
select {
|
|
|
|
case <-ticker.C:
|
|
|
|
err := service.snapshotEndpoints()
|
|
|
|
if err != nil {
|
2022-09-16 16:18:44 +00:00
|
|
|
log.Error().Err(err).Msg("background schedule error (environment snapshot)")
|
2020-06-25 03:25:51 +00:00
|
|
|
}
|
2022-03-16 14:27:28 +00:00
|
|
|
case <-service.shutdownCtx.Done():
|
2022-09-16 16:18:44 +00:00
|
|
|
log.Debug().Msg("shutting down snapshotting")
|
2022-03-16 14:27:28 +00:00
|
|
|
ticker.Stop()
|
|
|
|
return
|
|
|
|
case interval := <-service.snapshotIntervalCh:
|
|
|
|
ticker.Reset(interval)
|
2020-06-25 03:25:51 +00:00
|
|
|
}
|
2022-03-16 14:27:28 +00:00
|
|
|
}
|
2020-06-25 03:25:51 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
func (service *Service) snapshotEndpoints() error {
|
|
|
|
endpoints, err := service.dataStore.Endpoint().Endpoints()
|
|
|
|
if err != nil {
|
|
|
|
return err
|
|
|
|
}
|
|
|
|
|
|
|
|
for _, endpoint := range endpoints {
|
2023-05-17 14:57:05 +00:00
|
|
|
if !SupportDirectSnapshot(&endpoint) || endpoint.URL == "" {
|
2022-09-28 17:56:32 +00:00
|
|
|
continue
|
|
|
|
}
|
|
|
|
|
2020-07-05 23:21:03 +00:00
|
|
|
snapshotError := service.SnapshotEndpoint(&endpoint)
|
2020-06-25 03:25:51 +00:00
|
|
|
|
2023-05-17 14:57:05 +00:00
|
|
|
if featureflags.IsEnabled(portainer.FeatureNoTx) {
|
|
|
|
updateEndpointStatus(service.dataStore, &endpoint, snapshotError)
|
|
|
|
} else {
|
|
|
|
service.dataStore.UpdateTx(func(tx dataservices.DataStoreTx) error {
|
|
|
|
updateEndpointStatus(tx, &endpoint, snapshotError)
|
|
|
|
return nil
|
|
|
|
})
|
2020-06-25 03:25:51 +00:00
|
|
|
}
|
2023-05-17 14:57:05 +00:00
|
|
|
}
|
2020-06-25 03:25:51 +00:00
|
|
|
|
2023-05-17 14:57:05 +00:00
|
|
|
return nil
|
|
|
|
}
|
2022-09-16 16:18:44 +00:00
|
|
|
|
2023-05-17 14:57:05 +00:00
|
|
|
func updateEndpointStatus(tx dataservices.DataStoreTx, endpoint *portainer.Endpoint, snapshotError error) {
|
|
|
|
latestEndpointReference, err := tx.Endpoint().Endpoint(endpoint.ID)
|
|
|
|
if latestEndpointReference == nil {
|
|
|
|
log.Debug().
|
|
|
|
Str("endpoint", endpoint.Name).
|
|
|
|
Str("URL", endpoint.URL).Err(err).
|
|
|
|
Msg("background schedule error (environment snapshot), environment not found inside the database anymore")
|
2020-06-25 03:25:51 +00:00
|
|
|
|
2023-05-17 14:57:05 +00:00
|
|
|
return
|
|
|
|
}
|
2020-06-25 03:25:51 +00:00
|
|
|
|
2023-05-17 14:57:05 +00:00
|
|
|
latestEndpointReference.Status = portainer.EndpointStatusUp
|
|
|
|
if snapshotError != nil {
|
|
|
|
log.Debug().
|
|
|
|
Str("endpoint", endpoint.Name).
|
|
|
|
Str("URL", endpoint.URL).Err(err).
|
|
|
|
Msg("background schedule error (environment snapshot), unable to create snapshot")
|
2022-09-16 16:18:44 +00:00
|
|
|
|
2023-05-17 14:57:05 +00:00
|
|
|
latestEndpointReference.Status = portainer.EndpointStatusDown
|
2020-06-25 03:25:51 +00:00
|
|
|
}
|
|
|
|
|
2023-05-17 14:57:05 +00:00
|
|
|
latestEndpointReference.Agent.Version = endpoint.Agent.Version
|
|
|
|
|
|
|
|
err = tx.Endpoint().UpdateEndpoint(latestEndpointReference.ID, latestEndpointReference)
|
|
|
|
if err != nil {
|
|
|
|
log.Debug().
|
|
|
|
Str("endpoint", endpoint.Name).
|
|
|
|
Str("URL", endpoint.URL).Err(err).
|
|
|
|
Msg("background schedule error (environment snapshot), unable to update environment")
|
|
|
|
}
|
2020-06-25 03:25:51 +00:00
|
|
|
}
|
2021-07-19 07:43:49 +00:00
|
|
|
|
2021-09-20 00:14:22 +00:00
|
|
|
// FetchDockerID fetches info.Swarm.Cluster.ID if environment(endpoint) is swarm and info.ID otherwise
|
2021-07-19 07:43:49 +00:00
|
|
|
func FetchDockerID(snapshot portainer.DockerSnapshot) (string, error) {
|
2022-05-31 10:03:10 +00:00
|
|
|
info := snapshot.SnapshotRaw.Info
|
2021-07-19 07:43:49 +00:00
|
|
|
|
|
|
|
if !snapshot.Swarm {
|
2022-05-31 10:03:10 +00:00
|
|
|
return info.ID, nil
|
2021-07-19 07:43:49 +00:00
|
|
|
}
|
|
|
|
|
2022-05-31 10:03:10 +00:00
|
|
|
swarmInfo := info.Swarm
|
|
|
|
if swarmInfo.Cluster == nil {
|
2021-09-08 08:42:17 +00:00
|
|
|
return "", errors.New("swarm environment is missing cluster info snapshot")
|
2021-07-19 07:43:49 +00:00
|
|
|
}
|
|
|
|
|
2022-05-31 10:03:10 +00:00
|
|
|
clusterInfo := swarmInfo.Cluster
|
|
|
|
return clusterInfo.ID, nil
|
2021-07-19 07:43:49 +00:00
|
|
|
}
|