Skip to content

Commit 5c9d090

Browse files
committed
lxd/images: Support retrying image record deletion in autoUpdateImages
Previously the tx.DeleteImage error was not returned to the calling s.DB.Cluster.Transaction function which meant the built in retry logic LXD has when the table is locked was not being used. Instead return the error and let the retry mechanisms have a go at retrying the request. Signed-off-by: Thomas Parrott <thomas.parrott@canonical.com>
1 parent c83b9c1 commit 5c9d090

1 file changed

Lines changed: 5 additions & 2 deletions

File tree

lxd/images.go

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2004,17 +2004,20 @@ func autoUpdateImages(ctx context.Context, s *state.State) error {
20042004
}
20052005
}
20062006

2007-
_ = s.DB.Cluster.Transaction(context.TODO(), func(ctx context.Context, tx *db.ClusterTx) error {
2007+
err = s.DB.Cluster.Transaction(context.TODO(), func(ctx context.Context, tx *db.ClusterTx) error {
20082008
for _, ID := range deleteIDs {
20092009
// Remove the database entry for the image after distributing to cluster members.
20102010
err := tx.DeleteImage(ctx, ID)
20112011
if err != nil {
2012-
logger.Error("Error deleting old image from database", logger.Ctx{"member": s.ServerName, "fingerprint": fingerprint, "ID": ID, "err": err})
2012+
return fmt.Errorf(`Failed deleting image record with ID "%d": %w`, ID, err)
20132013
}
20142014
}
20152015

20162016
return nil
20172017
})
2018+
if err != nil {
2019+
logger.Error("Error deleting old image(s) records", logger.Ctx{"member": s.ServerName, "fingerprint": fingerprint, "err": err})
2020+
}
20182021
}
20192022
}
20202023

0 commit comments

Comments
 (0)