You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
libpod: defer volume plugin init when loading volumes from DB
Do not contact volume plugins in finalizeVolume or when loading from the
DB. Initialize lazily on inspect/mount/unmount/remove; fail eagerly on create.
Fixes#28110
Signed-off-by: Yoonseo Han <yooncer00@gmail.com>
// We want to fail gracefully here, to ensure that we
306
-
// can still remove volumes even if their plugin is
307
-
// missing. Otherwise, we end up with volumes that
308
-
// cannot even be retrieved from the database and will
309
-
// cause things like `volume ls` to fail.
310
-
logrus.Errorf("Volume %s uses volume plugin %s, but it cannot be accessed - some functionality may not be available: %v", volume.Name(), volume.config.Driver, err)
@@ -437,27 +439,22 @@ func (r *Runtime) removeVolume(ctx context.Context, v *Volume, force bool, timeo
437
439
ifv.UsesVolumeDriver() &&!ignoreVolumePlugin {
438
440
canRemove:=true
439
441
440
-
// Do we have a volume driver?
441
-
ifv.plugin==nil {
442
+
plugin, err:=v.getPlugin()
443
+
iferr!=nil {
442
444
canRemove=false
443
-
removalErr=fmt.Errorf("cannot remove volume %s from plugin %s, but it has been removed from Podman: %w", v.Name(), v.Driver(), define.ErrMissingPlugin)
445
+
removalErr=fmt.Errorf("cannot remove volume %s from plugin %s, but it has been removed from Podman: %w", v.Name(), v.Driver(), err)
444
446
} else {
445
-
// Ping the plugin first to verify the volume still
446
-
// exists.
447
-
// We're trying to be very tolerant of missing volumes
448
-
// in the backend, to avoid the problems we see with
449
-
// sync between c/storage and the Libpod DB.
450
447
getReq:=new(pluginapi.GetRequest)
451
448
getReq.Name=v.Name()
452
-
if_, err:=v.plugin.GetVolume(getReq); err!=nil {
449
+
if_, err:=plugin.GetVolume(getReq); err!=nil {
453
450
canRemove=false
454
451
removalErr=fmt.Errorf("volume %s could not be retrieved from plugin %s, but it has been removed from Podman: %w", v.Name(), v.Driver(), err)
455
452
}
456
453
}
457
454
ifcanRemove {
458
455
req:=new(pluginapi.RemoveRequest)
459
456
req.Name=v.Name()
460
-
iferr:=v.plugin.RemoveVolume(req); err!=nil {
457
+
iferr:=plugin.RemoveVolume(req); err!=nil {
461
458
returnfmt.Errorf("volume %s could not be removed from plugin %s: %w", v.Name(), v.Driver(), err)
// We want to fail gracefully here, to ensure that we
358
-
// can still remove volumes even if their plugin is
359
-
// missing. Otherwise, we end up with volumes that
360
-
// cannot even be retrieved from the database and will
361
-
// cause things like `volume ls` to fail.
362
-
logrus.Errorf("Volume %s uses volume plugin %s, but it cannot be accessed - some functionality may not be available: %v", vol.Name(), vol.config.Driver, err)
logrus.Debugf("Querying volume plugin %s for status", v.config.Driver)
33
33
data.Mountpoint=v.state.MountPoint
34
34
35
-
ifv.plugin==nil {
36
-
returnnil, fmt.Errorf("volume %s uses volume plugin %s but it is not available, cannot inspect: %w", v.Name(), v.config.Driver, define.ErrMissingPlugin)
35
+
plugin, err:=v.getPlugin()
36
+
iferr!=nil {
37
+
returnnil, fmt.Errorf("volume %s uses volume plugin %s but it is not available, cannot inspect: %w", v.Name(), v.config.Driver, err)
37
38
}
38
39
39
40
// Retrieve status for the volume.
40
41
// Need to query the volume driver.
41
42
req:=new(pluginapi.GetRequest)
42
43
req.Name=v.Name()
43
-
resp, err:=v.plugin.GetVolume(req)
44
+
resp, err:=plugin.GetVolume(req)
44
45
iferr!=nil {
45
46
returnnil, fmt.Errorf("retrieving volume %s information from plugin %s: %w", v.Name(), v.Driver(), err)
0 commit comments