forked from containers/storage
-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add a Shutdown() method to the Store
Add a method for calling the underlying driver's Cleanup() method, preferably when it's not going to disrupt another user of the same data store, and try to give other users of the store a way to notice that the driver's been cleaned up, so they need to reinitialize things before continuing to use them. Signed-off-by: Nalin Dahyabhai <nalin@redhat.com>
- Loading branch information
Showing
5 changed files
with
177 additions
and
34 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,46 @@ | ||
package main | ||
|
||
import ( | ||
"encoding/json" | ||
"fmt" | ||
"os" | ||
|
||
"github.com/containers/storage/pkg/mflag" | ||
"github.com/containers/storage/storage" | ||
) | ||
|
||
var ( | ||
forceShutdown = false | ||
) | ||
|
||
func shutdown(flags *mflag.FlagSet, action string, m storage.Store, args []string) int { | ||
_, err := m.Shutdown(forceShutdown) | ||
if jsonOutput { | ||
if err == nil { | ||
json.NewEncoder(os.Stdout).Encode(string("")) | ||
} else { | ||
json.NewEncoder(os.Stdout).Encode(err) | ||
} | ||
} else { | ||
if err != nil { | ||
fmt.Fprintf(os.Stderr, "%s: %v\n", action, err) | ||
} | ||
} | ||
if err != nil { | ||
return 1 | ||
} | ||
return 0 | ||
} | ||
|
||
func init() { | ||
commands = append(commands, command{ | ||
names: []string{"shutdown"}, | ||
usage: "Shut down layer storage", | ||
minArgs: 0, | ||
action: shutdown, | ||
addFlags: func(flags *mflag.FlagSet, cmd *command) { | ||
flags.BoolVar(&jsonOutput, []string{"-json", "j"}, jsonOutput, "Prefer JSON output") | ||
flags.BoolVar(&forceShutdown, []string{"-force", "f"}, forceShutdown, "Unmount mounted layers first") | ||
}, | ||
}) | ||
} |
This file was deleted.
Oops, something went wrong.
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,20 @@ | ||
## oci-storage-shutdown 1 "October 2016" | ||
|
||
## NAME | ||
oci-storage shutdown - Shut down layer storage | ||
|
||
## SYNOPSIS | ||
**oci-storage** **shutdown** [*options* [...]] | ||
|
||
## DESCRIPTION | ||
Shuts down the layer storage driver, which may be using kernel resources. | ||
|
||
## OPTIONS | ||
**-f | --force** | ||
|
||
Attempt to unmount any mounted layers before attempting to shut down the | ||
driver. If this option is not specified, if any layers are mounted, shutdown | ||
will not be attempted. | ||
|
||
## EXAMPLE | ||
**oci-storage shutdown** |
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