Adding server prune and undeploy prune #278
Merged
decentral1se
merged 2 commits from 2023-02-17 08:53:47 +00:00
codegod100/abra:prune into main
Labels
Clear labels
bug
build
ci/cd
critical fix
design
documentation
duplicate
easy-first-issue
enhancement
help wanted
i10n
i18n
installer
invalid
question
release
release-candidate
security
tech-debt
test
wontfix
Something is not working
go build related issues
Building things with CI/CD
https://docs.coopcloud.tech/federation/resolutions/passed/010/
UI/UX
Documenting all the things
This issue or pull request already exists
Something for new people to get stuck into. We hope it's easy!
New feature
Need some help
Everything to do with localisation
Everything to do with internationalisation
Everything to do with the install script.
Something is wrong
More information is needed
Release management
Related to the new release candidate
Security related
Unit/integration testing
This won't be fixed
No labels
Milestone
No items
No Milestone
Projects
Clear projects
No projects
Assignees
3wordchant
aadil (Aadil Ayub)
abra-bot (Abra Bot)
ammaratef45
amras (Sarma)
Apfelwurm
BornDeleuze
Brooke
carla
cas (Cassowary)
coopcloud
cyrnel
decentral1se (d1)
dede
devydave
fauno (fauno)
iexos
jade (Jade Ambrose)
jjsfunhouse
jmakdah2 (Jackie Makdah)
joe-irving (Joe Irving)
kawaiipunk (KawaiiPunk)
knoflook
kolaente
lambdabundesverband
linnealovespie (April)
moosemower
moritz
notplants
oxaliq (sorrel)
p4u1
pharaohgraphy (Andrew 🐦🔥❤️🔥✴️)
renovate-bot (Comrade Renovate Bot)
ripclap
simon
sixsmith (Sixsmith)
stevensting
trav (Trav Fryer)
val (val (he/him))
yksflip
Clear assignees
No Assignees
Notifications
Due Date
No due date set.
Dependencies
No dependencies set.
Reference: toolshed/abra#278
Reference in New Issue
Block a user
Blocking a user prevents them from interacting with repositories, such as opening or commenting on pull requests or issues. Learn more about blocking a user.
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
Afteras it has some not obvious runtime behaviour (see https://pkg.go.dev/github.com/urfave/cli/v2#AfterFunc) and also the--pruneis 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() panicsThe issue I was trying to tackle is that pruning while docker container is still running is kinda pointless. when we run
abra app undeployIt 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
Actioncode 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
runtimepackage options praxis 🤔 For another day...I'm kinda confused what you mean here. What are those
false,falseargs being passed toFilters()?Yeh it's kinda a mess not of our making, i'll copy in the comments:
Filtersgoal 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 errlogrus.Fatal(err)@@ -60,0 +90,4 @@nr, err := cl.NetworksPrune(ctx, pruneFilters)if err != nil {return errlogrus.Fatal(err)@@ -60,0 +96,4 @@ir, err := cl.ImagesPrune(ctx, pruneFilters)if err != nil {return errlogrus.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 errlogrus.Fatal(err)@@ -0,0 +52,4 @@ctx := context.Background()cr, err := cl.ContainersPrune(ctx, args)if err != nil {return errlogrus.Fatal(err)@@ -0,0 +58,4 @@nr, err := cl.NetworksPrune(ctx, args)if err != nil {return errlogrus.Fatal(err)@@ -0,0 +68,4 @@}ir, err := cl.ImagesPrune(ctx, pruneFilters)if err != nil {return errlogrus.Fatal(err)@@ -0,0 +75,4 @@if volunesFilter {vr, err := cl.VolumesPrune(ctx, args)if err != nil {return errlogrus.Fatal(err)all changes fixed