semaphore: Docker Image CrashLoop since v2.9.21 value of field 'Port' is not valid! (Must match regex: '^:([0-9]{1,5})$')
I noticed that since the version v2.9.21 that was released a few days ago there is a problem with the validation of the postgres port in the connection string.
When I jump back to the docker image v2.9.19 everything works fine again.
I’ve tested from version v2.9.21 - v2.8.34 all have the same problem.
Now the question is, is this an expected behaviour since this version or is this just a bug?
Here is the full container log:
Attempting to connect to database semaphore on postgresql.postgresql.svc.cluster.local:5432 with user postgres ...
Loading config
Validating config
panic: value of field 'Port' is not valid! (Must match regex: '^:([0-9]{1,5})$')
goroutine 1 [running]:
github.com/ansible-semaphore/semaphore/util.validateConfig(...)
/go/src/github.com/ansible-semaphore/semaphore/util/config.go:397
github.com/ansible-semaphore/semaphore/util.ConfigInit({0x7ffc0163aaa1, 0x1a})
/go/src/github.com/ansible-semaphore/semaphore/util/config.go:197 +0x24b
github.com/ansible-semaphore/semaphore/cli/cmd.createStore({0xbf2252, 0x4})
/go/src/github.com/ansible-semaphore/semaphore/cli/cmd/root.go:92 +0x3b
github.com/ansible-semaphore/semaphore/cli/cmd.runService()
/go/src/github.com/ansible-semaphore/semaphore/cli/cmd/root.go:43 +0x48
github.com/ansible-semaphore/semaphore/cli/cmd.glob..func4(0x273a1a0?, {0xbf2056?, 0x2?, 0x2?})
About this issue
- Original URL
- State: open
- Created 3 years ago
- Comments: 17
You are all victims of the automatically generated environment variables by the Kubelet. See https://kubernetes.io/docs/tutorials/services/connect-applications-service/#environment-variables
So if you name your Service
semaphore, Kubernetes will automatically add the env-varSEMAPHORE_PORTto the Pods, which of course clashes with Semaphore’s own environment variables: https://github.com/ansible-semaphore/semaphore/blob/v2.9.45/util/config.go#L118Proper fix: If you run Kubernetes with an integrated DNS server (like 99% of people do), you can disable the auto-generated service links. Just add this to your podSpec:
See https://kubernetes.io/docs/tutorials/services/connect-applications-service/#accessing-the-service
Hi @fiftin, I stumbled upon this issue and was able to implement a workaround based on your comments. I’m running the docker image on Kubernetes with a
config.jsonfile to set the configuration parameters, theport:value is empty in order to use the default value.It seems that value is not set when using the
config.jsonfile, this might have been introduced with the refactor of the configuration system. If I addSEMAPHORE_PORTwith value":3000"to the environment variables, the container image starts and works as expected.I hope this additional information helps. In the meantime it should provide a workaround to anybody else that comes across this issue. Looking forward to the definite fix.
Thanks to @ChristianCiach , it really helps !!
Thanks for the insight @ChristianCiach, great catch!! I can confirm that renaming the service to
semaphoreui, fixes the issue. If the service is renamed, there is no need to change anything on thepod spec. The values from theconfig.jsonare used and defaults are honored.@fiftin, I think this solves this particular issue.
Hi @SwitzerChees Thank you! Working on issue
Hello @fiftin
Ok I tried it again but this still fails:
with these container logs:
I am using the docker image from docker hub but on a Kubernetes cluster. I noticed the issue because I had the :latest tag. Now I switched to a specific version tag and here it works from version v2.9.19 downwards.
Hi @SwitzerChees It was fixed in v2.9.23.
In your error message I see old Regexp
^:([0-9]{1,5})$. It was changed to^:?([0-9]{1,5})$.Are you use Docker or binary?