CloudMigrations: Query Grafana Migration Status for status while the snapshot is in the cloud (#90314)

* implement querying gms for snapshot status

* add some documentation

* provide snapshot resources after snapshot is created

* add rate limiting to backend

* fix compilation error

* fix typo

* add unit tests

* finish merge

* lint

* swagger gen

* more testing

* remove duplicate test

* address a couple PR comments

* update switch statement to a map

* add timeouts to gms client through the http client

* remove extra whitespace

* put method back where it was so the PR is less confusing

* fix tests

* add todo

* fix final unit test
This commit is contained in:
Michael Mandrus
2024-07-15 09:22:57 -04:00
committed by GitHub
parent 5beaae8561
commit 542a1bf3ac
19 changed files with 532 additions and 125 deletions
+29 -13
View File
@@ -55,25 +55,24 @@ type CloudMigrationSnapshot struct {
type SnapshotStatus string
const (
SnapshotStatusInitializing = "initializing"
SnapshotStatusCreating = "creating"
SnapshotStatusPendingUpload = "pending_upload"
SnapshotStatusUploading = "uploading"
SnapshotStatusPendingProcessing = "pending_processing"
SnapshotStatusProcessing = "processing"
SnapshotStatusFinished = "finished"
SnapshotStatusError = "error"
SnapshotStatusUnknown = "unknown"
SnapshotStatusCreating SnapshotStatus = "creating"
SnapshotStatusPendingUpload SnapshotStatus = "pending_upload"
SnapshotStatusUploading SnapshotStatus = "uploading"
SnapshotStatusPendingProcessing SnapshotStatus = "pending_processing"
SnapshotStatusProcessing SnapshotStatus = "processing"
SnapshotStatusFinished SnapshotStatus = "finished"
SnapshotStatusCanceled SnapshotStatus = "canceled"
SnapshotStatusError SnapshotStatus = "error"
)
type CloudMigrationResource struct {
ID int64 `xorm:"pk autoincr 'id'"`
UID string `xorm:"uid"`
Type MigrateDataType `xorm:"resource_type"`
RefID string `xorm:"resource_uid"`
Status ItemStatus `xorm:"status"`
Error string `xorm:"error_string"`
Type MigrateDataType `xorm:"resource_type" json:"type"`
RefID string `xorm:"resource_uid" json:"refId"`
Status ItemStatus `xorm:"status" json:"status"`
Error string `xorm:"error_string" json:"error"`
SnapshotUID string `xorm:"snapshot_uid"`
}
@@ -212,3 +211,20 @@ type StartSnapshotResponse struct {
UploadURL string `json:"uploadURL"`
EncryptionKey string `json:"encryptionKey"`
}
// Based on Grafana Migration Service DTOs
type GetSnapshotStatusResponse struct {
State SnapshotState `json:"state"`
Results []CloudMigrationResource `json:"results"`
}
type SnapshotState string
const (
SnapshotStateInitialized SnapshotState = "INITIALIZED"
SnapshotStateProcessing SnapshotState = "PROCESSING"
SnapshotStateFinished SnapshotState = "FINISHED"
SnapshotStateCanceled SnapshotState = "CANCELED"
SnapshotStateError SnapshotState = "ERROR"
SnapshotStateUnknown SnapshotState = "UNKNOWN"
)