forked from containers/podman
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
add podman volume reload to sync volume plugins
Libpod requires that all volumes are stored in the libpod db. Because volume plugins can be created outside of podman, it will not show all available plugins. This podman volume reload command allows users to sync the libpod db with their external volume plugins. All new volumes from the plugin are also created in the libpod db and when a volume from the db no longer exists it will be removed if possible. There are some problems: - naming conflicts, in this case we only use the first volume we found. This is not deterministic. - race conditions, we have no control over the volume plugins. It is possible that the volumes changed while we run this command. Fixes containers#14207 Signed-off-by: Paul Holzinger <[email protected]>
- Loading branch information
Showing
14 changed files
with
268 additions
and
13 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,52 @@ | ||
package volumes | ||
|
||
import ( | ||
"fmt" | ||
|
||
"github.com/containers/common/pkg/completion" | ||
"github.com/containers/podman/v4/cmd/podman/registry" | ||
"github.com/containers/podman/v4/cmd/podman/utils" | ||
"github.com/containers/podman/v4/cmd/podman/validate" | ||
"github.com/spf13/cobra" | ||
) | ||
|
||
var ( | ||
reloadDescription = `Check all configured volume plugins and update the libpod database with all available volumes. | ||
Existing volumes are also removed from the database when they are no longer present in the plugin.` | ||
reloadCommand = &cobra.Command{ | ||
Use: "reload", | ||
Args: validate.NoArgs, | ||
Short: "reload all volumes from volume plugins", | ||
Long: reloadDescription, | ||
RunE: reload, | ||
ValidArgsFunction: completion.AutocompleteNone, | ||
} | ||
) | ||
|
||
func init() { | ||
registry.Commands = append(registry.Commands, registry.CliCommand{ | ||
Command: reloadCommand, | ||
Parent: volumeCmd, | ||
}) | ||
} | ||
|
||
func reload(cmd *cobra.Command, args []string) error { | ||
report, err := registry.ContainerEngine().VolumeReload(registry.Context()) | ||
if err != nil { | ||
return err | ||
} | ||
printReload("Added", report.Added) | ||
printReload("Removed", report.Removed) | ||
errs := (utils.OutputErrors)(report.Errors) | ||
return errs.PrintErrors() | ||
} | ||
|
||
func printReload(typ string, values []string) { | ||
if len(values) > 0 { | ||
fmt.Println(typ + ":") | ||
for _, name := range values { | ||
fmt.Println(name) | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,29 @@ | ||
% podman-volume-reload(1) | ||
|
||
## NAME | ||
podman\-volume\-reload - Reload all volumes from volumes plugins | ||
|
||
## SYNOPSIS | ||
**podman volume reload** | ||
|
||
## DESCRIPTION | ||
|
||
**podman volume reload** checks all configured volume plugins and updates the libpod database with all available volumes. | ||
Existing volumes are also removed from the database when they are no longer present in the plugin. | ||
|
||
This command it is best effort and cannot guarantee a perfect state because plugins can be modified from the outside at any time. | ||
|
||
Note: This command is not supported with podman-remote. | ||
|
||
## EXAMPLES | ||
|
||
``` | ||
$ podman volume reload | ||
Added: | ||
vol6 | ||
Removed: | ||
t3 | ||
``` | ||
|
||
## SEE ALSO | ||
**[podman(1)](podman.1.md)**, **[podman-volume(1)](podman-volume.1.md)** |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.