Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: prune volumes without all flag for pre-Docker v1.42 #2781

Conversation

aloisklink
Copy link
Contributor

What kind of change does this PR introduce?

Bug fix for supabase stop --no-backup for users on old versions of Docker or on Podman.

What is the current behavior?

Before Docker API version 1.42, the all flag in Docker.VolumePrune is not required.

Podman prints an error like the following when the all flag is passed (Podman's only compatible with Docker API v1.41), e.g. when running supabase stop --no-backup:

alois@pc:~/app (develop)$ npx [email protected] stop --no-backup
failed to prune volumes: Error response from daemon: failed to parse filters for all=true&label=com.supabase.cli.project%3Dapp: "all" is an invalid volume filter
Try rerunning the command with --debug to troubleshoot the error.

See: #2348 (comment), who had this same issue.
See: #1989 (which added the all flag)

What is the new behavior?

I've added an if versions.GreaterThanOrEqualTo(Docker.ClientVersion(), "1.42") check before adding the all flag.

A similar check is done by the official Docker CLI: https://github.com/docker/cli/blob/062eecf14af34d7295da16c23c2578fcf4aa0196/cli/command/volume/prune.go#L67-L78

This works on Podman. I suspect it would work on older versions of Docker too, but I don't have one of those environments to test with!

Additional context

I'm a complete beginner in golang (this is only my second time writing a golang PR), so please review my code carefully. It's very likely I made a dumb mistake since I didn't know any better.

Before Docker API version 1.42, the `all` flag in Docker.VolumePrune`
is not required.

Podman prints an error like the following when the `all` flag
is passed ([Podman's only compatible with Docker API v1.41][1]):

```
failed to parse filters for all=true&label=com.supabase.cli.project%3Dtest: "all" is an invalid volume filter
```

[1]: https://github.com/containers/podman/blob/290d94d3c00857dd582ffbee6bd0677a0904c783/version/version.go#L46

Fixes: bec537e
Fixes: supabase#2348 (comment)
@coveralls
Copy link

Pull Request Test Coverage Report for Build 11425763976

Details

  • 11 of 11 (100.0%) changed or added relevant lines in 2 files are covered.
  • 5 unchanged lines in 1 file lost coverage.
  • Overall coverage decreased (-0.001%) to 59.775%

Files with Coverage Reduction New Missed Lines %
internal/gen/keys/keys.go 5 12.9%
Totals Coverage Status
Change from base Build 11400461733: -0.001%
Covered Lines: 6363
Relevant Lines: 10645

💛 - Coveralls

Copy link
Contributor

@sweatybridge sweatybridge left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for contributing this fix with unit tests!

@sweatybridge sweatybridge merged commit 47b7e9a into supabase:develop Oct 21, 2024
12 checks passed
@aloisklink aloisklink deleted the fix/support-stop-with-no-backup-on-podman branch October 22, 2024 06:07
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants