mirror of
https://github.com/grafana/grafana.git
synced 2024-11-26 02:40:26 -06:00
Cloudmigration: Sets the runID correctly when saving (#85661)
Sets the runID correctly instead of setting it to the same as the migration id.
This commit is contained in:
parent
58f32150c2
commit
1332d8ba24
@ -199,7 +199,7 @@ func (cma *CloudMigrationAPI) RunMigration(c *contextmodel.ReqContext) response.
|
||||
return response.Error(http.StatusInternalServerError, "migration data get error", err)
|
||||
}
|
||||
|
||||
req, err := http.NewRequest("POST", path, bytes.NewReader(body))
|
||||
req, err := http.NewRequest(http.MethodPost, path, bytes.NewReader(body))
|
||||
if err != nil {
|
||||
cma.log.Error("error creating http request for cloud migration run", "err", err.Error())
|
||||
return response.Error(http.StatusInternalServerError, "http request error", err)
|
||||
@ -235,7 +235,7 @@ func (cma *CloudMigrationAPI) RunMigration(c *contextmodel.ReqContext) response.
|
||||
return response.Error(http.StatusInternalServerError, "unmarshalling migration run response", err)
|
||||
}
|
||||
|
||||
_, err = cma.cloudMigrationService.SaveMigrationRun(ctx, &cloudmigration.CloudMigrationRun{
|
||||
runID, err := cma.cloudMigrationService.SaveMigrationRun(ctx, &cloudmigration.CloudMigrationRun{
|
||||
CloudMigrationUID: stringID,
|
||||
Result: respData,
|
||||
})
|
||||
@ -243,6 +243,8 @@ func (cma *CloudMigrationAPI) RunMigration(c *contextmodel.ReqContext) response.
|
||||
response.Error(http.StatusInternalServerError, "migration run save error", err)
|
||||
}
|
||||
|
||||
result.RunID = runID
|
||||
|
||||
return response.JSON(http.StatusOK, result)
|
||||
}
|
||||
|
||||
|
@ -16,7 +16,7 @@ type Service interface {
|
||||
GetMigrationStatus(context.Context, string, string) (*CloudMigrationRun, error)
|
||||
GetMigrationStatusList(context.Context, string) ([]*CloudMigrationRun, error)
|
||||
DeleteMigration(context.Context, int64) (*CloudMigration, error)
|
||||
SaveMigrationRun(context.Context, *CloudMigrationRun) (string, error)
|
||||
SaveMigrationRun(context.Context, *CloudMigrationRun) (int64, error)
|
||||
|
||||
ParseCloudMigrationConfig() (string, error)
|
||||
}
|
||||
|
@ -442,16 +442,16 @@ func (s *Service) getDashboards(ctx context.Context, id int64) ([]dashboards.Das
|
||||
return result, nil
|
||||
}
|
||||
|
||||
func (s *Service) SaveMigrationRun(ctx context.Context, cmr *cloudmigration.CloudMigrationRun) (string, error) {
|
||||
func (s *Service) SaveMigrationRun(ctx context.Context, cmr *cloudmigration.CloudMigrationRun) (int64, error) {
|
||||
cmr.Created = time.Now()
|
||||
cmr.Updated = time.Now()
|
||||
cmr.Finished = time.Now()
|
||||
err := s.store.SaveMigrationRun(ctx, cmr)
|
||||
if err != nil {
|
||||
s.log.Error("Failed to save migration run", "err", err)
|
||||
return "", err
|
||||
return -1, err
|
||||
}
|
||||
return cmr.CloudMigrationUID, nil
|
||||
return cmr.ID, nil
|
||||
}
|
||||
|
||||
func (s *Service) GetMigrationStatus(ctx context.Context, id string, runID string) (*cloudmigration.CloudMigrationRun, error) {
|
||||
|
@ -50,8 +50,8 @@ func (s *NoopServiceImpl) DeleteMigration(ctx context.Context, id int64) (*cloud
|
||||
return nil, cloudmigration.ErrFeatureDisabledError
|
||||
}
|
||||
|
||||
func (s *NoopServiceImpl) SaveMigrationRun(ctx context.Context, cmr *cloudmigration.CloudMigrationRun) (string, error) {
|
||||
return "", cloudmigration.ErrInternalNotImplementedError
|
||||
func (s *NoopServiceImpl) SaveMigrationRun(ctx context.Context, cmr *cloudmigration.CloudMigrationRun) (int64, error) {
|
||||
return -1, cloudmigration.ErrInternalNotImplementedError
|
||||
}
|
||||
|
||||
func (s *NoopServiceImpl) GetMigrationDataJSON(ctx context.Context, id int64) ([]byte, error) {
|
||||
|
Loading…
Reference in New Issue
Block a user