Cloud migrations: store snapshots in the database (#108551)
* Cloud migrations: store snapshots in the database * update github.com/grafana/grafana-cloud-migration-snapshot to v1.9.0 * make update-workspace * use new field name in test * return error after call to fmt.Errorf * create methods for readability / fix session deletiong not deleting snapshots * remove debugging changes * update sample.ini * update tests to include OrgID in ListSnapshotsQuery * lint * lint * Update pkg/services/cloudmigration/cloudmigrationimpl/snapshot_mgmt.go Co-authored-by: Matheus Macabu <macabu@users.noreply.github.com> * remove TODO * Update pkg/services/cloudmigration/cloudmigrationimpl/snapshot_mgmt.go Co-authored-by: Matheus Macabu <macabu@users.noreply.github.com> * remove one of the debug logs --------- Co-authored-by: Matheus Macabu <macabu@users.noreply.github.com>
This commit is contained in:
@@ -35,17 +35,21 @@ type CloudMigrationSession struct {
|
||||
|
||||
// CloudMigrationSnapshot contains all of the metadata about a snapshot
|
||||
type CloudMigrationSnapshot struct {
|
||||
ID int64 `xorm:"pk autoincr 'id'"`
|
||||
UID string `xorm:"uid"`
|
||||
SessionUID string `xorm:"session_uid"`
|
||||
Status SnapshotStatus
|
||||
EncryptionKey []byte `xorm:"-"` // stored in the unified secrets table
|
||||
LocalDir string `xorm:"local_directory"`
|
||||
GMSSnapshotUID string `xorm:"gms_snapshot_uid"`
|
||||
ErrorString string `xorm:"error_string"`
|
||||
Created time.Time
|
||||
Updated time.Time
|
||||
Finished time.Time
|
||||
ID int64 `xorm:"pk autoincr 'id'"`
|
||||
UID string `xorm:"uid"`
|
||||
SessionUID string `xorm:"session_uid"`
|
||||
Status SnapshotStatus
|
||||
GMSPublicKey []byte `xorm:"-"` // stored in the unified secrets table
|
||||
PublicKey []byte `xorm:"public_key"`
|
||||
LocalDir string `xorm:"local_directory"`
|
||||
GMSSnapshotUID string `xorm:"gms_snapshot_uid"`
|
||||
ErrorString string `xorm:"error_string"`
|
||||
ResourceStorageType string `xorm:"resource_storage_type"`
|
||||
EncryptionAlgo string `xorm:"encryption_algo"`
|
||||
Metadata []byte `xorm:"'metadata'"`
|
||||
Created time.Time
|
||||
Updated time.Time
|
||||
Finished time.Time
|
||||
|
||||
// Stored in the cloud_migration_resource table
|
||||
Resources []CloudMigrationResource `xorm:"-"`
|
||||
@@ -53,6 +57,20 @@ type CloudMigrationSnapshot struct {
|
||||
StatsRollup SnapshotResourceStats `xorm:"-"`
|
||||
}
|
||||
|
||||
type CloudMigrationSnapshotPartition struct {
|
||||
SnapshotUID string `xorm:"snapshot_uid"`
|
||||
ResourceType string `xorm:"resource_type"`
|
||||
PartitionNumber int `xorm:"partition_number"`
|
||||
Data []byte `xorm:"data"`
|
||||
}
|
||||
|
||||
type CloudMigrationSnapshotIndex struct {
|
||||
EncryptionAlgo string
|
||||
PublicKey []byte
|
||||
Metadata []byte
|
||||
Items map[string][]int
|
||||
}
|
||||
|
||||
type SnapshotStatus string
|
||||
|
||||
const (
|
||||
@@ -226,6 +244,7 @@ type UpdateSnapshotCmd struct {
|
||||
UID string
|
||||
SessionID string
|
||||
Status SnapshotStatus
|
||||
PublicKey []byte
|
||||
|
||||
// LocalResourcesToCreate represents the local state of a resource before it has been uploaded to GMS
|
||||
LocalResourcesToCreate []CloudMigrationResource
|
||||
@@ -293,7 +312,7 @@ type StartSnapshotResponse struct {
|
||||
SnapshotID string `json:"snapshotID"`
|
||||
MaxItemsPerPartition uint32 `json:"maxItemsPerPartition"`
|
||||
Algo string `json:"algo"`
|
||||
EncryptionKey []byte `json:"encryptionKey"`
|
||||
GMSPublicKey []byte `json:"encryptionKey"`
|
||||
Metadata []byte `json:"metadata"`
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user