fix(db): warn on missing docker id when migrating to db 31 (#5782)

* fix(db): warn on missing docker id when migrating to db 31

* fix(db): guard against nil exception
pull/5835/head
Chaim Lev-Ari 3 years ago committed by GitHub
parent 9c279e7fae
commit 885ae16278
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

@ -176,7 +176,8 @@ func (m *Migrator) updateVolumeResourceControlToDB32() error {
endpointDockerID, err := snapshotutils.FetchDockerID(snapshot) endpointDockerID, err := snapshotutils.FetchDockerID(snapshot)
if err != nil { if err != nil {
return fmt.Errorf("failed fetching environment docker id: %w", err) log.Printf("[WARN] [bolt,migrator,v31] [message: failed fetching environment docker id] [err: %s]", err)
continue
} }
if volumesData, done := snapshot.SnapshotRaw.Volumes.(map[string]interface{}); done { if volumesData, done := snapshot.SnapshotRaw.Volumes.(map[string]interface{}); done {
@ -213,7 +214,11 @@ func findResourcesToUpdateForDB32(dockerID string, volumesData map[string]interf
volumes := volumesData["Volumes"].([]interface{}) volumes := volumesData["Volumes"].([]interface{})
for _, volumeMeta := range volumes { for _, volumeMeta := range volumes {
volume := volumeMeta.(map[string]interface{}) volume := volumeMeta.(map[string]interface{})
volumeName := volume["Name"].(string) volumeName, nameExist := volume["Name"].(string)
if !nameExist {
continue
}
oldResourceID := fmt.Sprintf("%s%s", volumeName, volume["CreatedAt"].(string)) oldResourceID := fmt.Sprintf("%s%s", volumeName, volume["CreatedAt"].(string))
resourceControl, ok := volumeResourceControls[oldResourceID] resourceControl, ok := volumeResourceControls[oldResourceID]

Loading…
Cancel
Save