mirror of
https://github.com/portainer/portainer.git
synced 2025-08-04 21:35:23 +02:00
fix(edgegroups): fix data-race in edgeGroupCreate EE-4435 (#8477)
This commit is contained in:
parent
e66dea44e3
commit
f081631808
15 changed files with 800 additions and 317 deletions
|
@ -8,6 +8,7 @@ import (
|
|||
"time"
|
||||
|
||||
portainer "github.com/portainer/portainer/api"
|
||||
"github.com/portainer/portainer/api/dataservices"
|
||||
portainerErrors "github.com/portainer/portainer/api/dataservices/errors"
|
||||
|
||||
"github.com/rs/zerolog/log"
|
||||
|
@ -61,6 +62,24 @@ func (store *Store) Close() error {
|
|||
return store.connection.Close()
|
||||
}
|
||||
|
||||
func (store *Store) UpdateTx(fn func(dataservices.DataStoreTx) error) error {
|
||||
return store.connection.UpdateTx(func(tx portainer.Transaction) error {
|
||||
return fn(&StoreTx{
|
||||
store: store,
|
||||
tx: tx,
|
||||
})
|
||||
})
|
||||
}
|
||||
|
||||
func (store *Store) ViewTx(fn func(dataservices.DataStoreTx) error) error {
|
||||
return store.connection.ViewTx(func(tx portainer.Transaction) error {
|
||||
return fn(&StoreTx{
|
||||
store: store,
|
||||
tx: tx,
|
||||
})
|
||||
})
|
||||
}
|
||||
|
||||
// BackupTo backs up db to a provided writer.
|
||||
// It does hot backup and doesn't block other database reads and writes
|
||||
func (store *Store) BackupTo(w io.Writer) error {
|
||||
|
|
48
api/datastore/services_tx.go
Normal file
48
api/datastore/services_tx.go
Normal file
|
@ -0,0 +1,48 @@
|
|||
package datastore
|
||||
|
||||
import (
|
||||
portainer "github.com/portainer/portainer/api"
|
||||
"github.com/portainer/portainer/api/dataservices"
|
||||
)
|
||||
|
||||
type StoreTx struct {
|
||||
store *Store
|
||||
tx portainer.Transaction
|
||||
}
|
||||
|
||||
func (tx *StoreTx) IsErrObjectNotFound(err error) bool {
|
||||
return tx.store.IsErrObjectNotFound(err)
|
||||
}
|
||||
|
||||
func (tx *StoreTx) CustomTemplate() dataservices.CustomTemplateService { return nil }
|
||||
|
||||
func (tx *StoreTx) EdgeGroup() dataservices.EdgeGroupService {
|
||||
return tx.store.EdgeGroupService.Tx(tx.tx)
|
||||
}
|
||||
|
||||
func (tx *StoreTx) EdgeJob() dataservices.EdgeJobService { return nil }
|
||||
func (tx *StoreTx) EdgeStack() dataservices.EdgeStackService { return nil }
|
||||
|
||||
func (tx *StoreTx) Endpoint() dataservices.EndpointService {
|
||||
return tx.store.EndpointService.Tx(tx.tx)
|
||||
}
|
||||
|
||||
func (tx *StoreTx) EndpointGroup() dataservices.EndpointGroupService { return nil }
|
||||
func (tx *StoreTx) EndpointRelation() dataservices.EndpointRelationService { return nil }
|
||||
func (tx *StoreTx) FDOProfile() dataservices.FDOProfileService { return nil }
|
||||
func (tx *StoreTx) HelmUserRepository() dataservices.HelmUserRepositoryService { return nil }
|
||||
func (tx *StoreTx) Registry() dataservices.RegistryService { return nil }
|
||||
func (tx *StoreTx) ResourceControl() dataservices.ResourceControlService { return nil }
|
||||
func (tx *StoreTx) Role() dataservices.RoleService { return nil }
|
||||
func (tx *StoreTx) APIKeyRepository() dataservices.APIKeyRepository { return nil }
|
||||
func (tx *StoreTx) Settings() dataservices.SettingsService { return nil }
|
||||
func (tx *StoreTx) Snapshot() dataservices.SnapshotService { return nil }
|
||||
func (tx *StoreTx) SSLSettings() dataservices.SSLSettingsService { return nil }
|
||||
func (tx *StoreTx) Stack() dataservices.StackService { return nil }
|
||||
func (tx *StoreTx) Tag() dataservices.TagService { return nil }
|
||||
func (tx *StoreTx) TeamMembership() dataservices.TeamMembershipService { return nil }
|
||||
func (tx *StoreTx) Team() dataservices.TeamService { return nil }
|
||||
func (tx *StoreTx) TunnelServer() dataservices.TunnelServerService { return nil }
|
||||
func (tx *StoreTx) User() dataservices.UserService { return nil }
|
||||
func (tx *StoreTx) Version() dataservices.VersionService { return nil }
|
||||
func (tx *StoreTx) Webhook() dataservices.WebhookService { return nil }
|
Loading…
Add table
Add a link
Reference in a new issue