acouvreur / sablier

Start your containers on demand, shut them down automatically when there's no activity. Docker, Docker Swarm Mode and Kubernetes compatible.
https://acouvreur.github.io/sablier/
GNU Affero General Public License v3.0
1.17k stars 44 forks source link

--storage.file error #172

Closed danteali closed 1 week ago

danteali commented 10 months ago

Describe the bug When using command --storage.file="/etc/sablier/my-states.json" the container won't start and outputs error:

Bringing up specified services: sablier
[+] Running 1/1
 ✔ Container sablier  Started                                                                                                                                                                                                                                                    0.5s 
time="2023-08-27T00:14:59Z" level=info msg="(version=1.4.0-beta.4, branch=HEAD, revision=720dc57935715b17fa0ae848554f8fae96a7730b)"
time="2023-08-27T00:14:59Z" level=info msg="using provider \"docker\""
panic: open "/etc/sablier/my-states.json": no such file or directory

goroutine 1 [running]:
github.com/acouvreur/sablier/cmd.glob..func2.1(0xc000450f00?, {0x195d987?, 0x8?, 0x8?})
        /go/src/sablier/cmd/start.go:18 +0x98
github.com/spf13/cobra.(*Command).execute(0xc000450f00, {0xc0000ae080, 0x8, 0x8})
        /go/pkg/mod/github.com/spf13/cobra@v1.6.1/command.go:920 +0x847
github.com/spf13/cobra.(*Command).ExecuteC(0xc000450c00)
        /go/pkg/mod/github.com/spf13/cobra@v1.6.1/command.go:1044 +0x3bc
github.com/spf13/cobra.(*Command).Execute(...)
        /go/pkg/mod/github.com/spf13/cobra@v1.6.1/command.go:968
github.com/acouvreur/sablier/cmd.Execute()
        /go/src/sablier/cmd/root.go:26 +0x1e
main.main()
        /go/src/sablier/main.go:10 +0x5a

The same error occurs whether I try to mount the file to the local filesystem or not (i.e. even if I have mounted a file to the correct path in the container it still says that no file exists).

If I instead try to do it with an environment variable (- STORAGE_FILE="/etc/sablier/my-states.json") the container does start but no file is created.

I also note that the docs for this setting state:

# File path to save the state (default stateless)

So by default (i.e. without specifying this config value) I didn't expect any state to be saved. But when the container is run without using this command arg or the environment variable the docker logs indicate that /etc/sablier/state.json is being used to save the state:

time="2023-08-27T00:17:08Z" level=info msg="initialized storage to /etc/sablier/state.json"

And the default /etc/cablier/sablier.yaml config file inside the container specifies:

storage:
  file: /etc/sablier/state.json

So it looks like the service is trying to save the state. However nothing seems to be written to this file at all, it remains unchanged when containers are started/stopped.

Context

acouvreur commented 5 months ago

That's right, the default config is stateful

https://github.com/acouvreur/sablier/blob/15de0fd3e44b909b6a1c353005ab83688321ad4e/docker/sablier.yaml#L5

I'll probably change that in the next release.

I'll investigate your storage initialization issue. Any update since ?

danteali commented 5 months ago

I haven't tried playing with saving states since I logged this. I'm fine using using stateless.

If I get time later I'll try to re-start with save states enabled and let you know.

github-actions[bot] commented 4 months ago

This issue is stale because it has been open 30 days with no activity. Remove stale label or comment or this will be closed in 5 days.