Adding server prune and undeploy prune #278
No reviewers
Labels
No Label
bug
build
ci/cd
contributing
design
documentation
duplicate
enhancement
help wanted
invalid
meta
question
security
wontfix
No Milestone
No Assignees
2 Participants
Notifications
Due Date
No due date set.
Dependencies
No dependencies set.
Reference: coop-cloud/abra#278
Loading…
Reference in New Issue
No description provided.
Delete Branch "codegod100/abra:prune"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
coop-cloud/organising#417
Adding server prune and undeploy prune #417to Adding server prune and undeploy pruneThis is amazing, great stuff!
@ -14,0 +18,4 @@
var pruneFlag = &cli.BoolFlag{
Name: "prune, p",
Destination: &prune,
Usage: "Prunes unused containers, networks, and dangling images for stack",
stack
👉an app
@ -57,5 +67,39 @@ volumes as eligiblef or pruning once undeployed.
return nil
},
After: func(c *cli.Context) error {
Hmmm, I'm not sure we should be putting this in
After
as it has some not obvious runtime behaviour (see https://pkg.go.dev/github.com/urfave/cli/v2#AfterFunc) and also the--prune
is part of the normal functioning of the sub-command, not a thing to happen after execution? Perhaps abstracting to a function and calling from the mainAction
?this part?
it is run even if Action() panics
The issue I was trying to tackle is that pruning while docker container is still running is kinda pointless. when we run
abra app undeploy
It takes clock time for the container to spin down. maybe we put an arbitrary wait in there? I hate doing that but not sure another way since we are done talking to docker by the time the actual spindown happens.Aha, I see. Could you just poll every second for the stack until it goes away? Then you can drop into the pruning logic after and still keep it all in the main
Action
code path.@ -60,0 +79,4 @@
}
ctx := context.Background()
pruneFilters := filters.NewArgs()
Could this be tucked into
app.Filters
? You might need to add a flag to specify the*
logic? Would be then:Could potentially learn from the new
runtime
package options praxis 🤔 For another day...I'm kinda confused what you mean here. What are those
false,false
args being passed toFilters()
?Yeh it's kinda a mess not of our making, i'll copy in the comments:
Filters
goal was to hide away the weirdness. But I see now again that the function arguments are also confusing. Anyway, feel free to skip this for now and I can loop back after for a re-factor.@ -60,0 +84,4 @@
pruneFilters.Add("label", stackSearch)
cr, err := cl.ContainersPrune(ctx, pruneFilters)
if err != nil {
return err
logrus.Fatal(err)
@ -60,0 +90,4 @@
nr, err := cl.NetworksPrune(ctx, pruneFilters)
if err != nil {
return err
logrus.Fatal(err)
@ -60,0 +96,4 @@
ir, err := cl.ImagesPrune(ctx, pruneFilters)
if err != nil {
return err
logrus.Fatal(err)
@ -0,0 +30,4 @@
Name: "prune",
Aliases: []string{"p"},
Usage: "Prune a managed server; Runs a docker system prune",
Description: `
Could be a
"..."
oneliner after all?@ -0,0 +47,4 @@
cl, err := client.New(serverName)
if err != nil {
return err
logrus.Fatal(err)
@ -0,0 +52,4 @@
ctx := context.Background()
cr, err := cl.ContainersPrune(ctx, args)
if err != nil {
return err
logrus.Fatal(err)
@ -0,0 +58,4 @@
nr, err := cl.NetworksPrune(ctx, args)
if err != nil {
return err
logrus.Fatal(err)
@ -0,0 +68,4 @@
}
ir, err := cl.ImagesPrune(ctx, pruneFilters)
if err != nil {
return err
logrus.Fatal(err)
@ -0,0 +75,4 @@
if volunesFilter {
vr, err := cl.VolumesPrune(ctx, args)
if err != nil {
return err
logrus.Fatal(err)
all changes fixed