-
Notifications
You must be signed in to change notification settings - Fork 138
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
gearmand may crash on startup in Kubernetes if service name is gearmand due to conflict with GEARMAND_PORT environment variable #320
Comments
Please provide more information, like the gearmand version and arguments used to startup gearmand. Could this Kubernetes issue be causing your problem? |
|
|
We don't maintain the artefactual/gearmand Docker image. I recommend that you take this up with whoever does. You still haven't specified the gearmand version number being used, and you didn't answer my question about the Kubernetes issues. All I can say is that gearmand version 1.1.19.1 works just fine in my Docker containers, and I don't use Kubernetes. |
See also these issues: kubernetes/kubernetes#76790 It sounds like the problem is with Alpine and/or Kubernetes to me. |
Gearmand version 1.1.19.1. None of the kubernetes problems is suitable. I am entering into correspondence with the creators of the artefactual/gearmand image. I will inform you about the result. I also use germand in docker-compose and there are no problems. |
You're sure? Because one of your previous messages said you were using
Why do you say that? The first two give the exact same error message you are experiencing ("getaddrinfo(Unrecognized service)"), and the third describes the same problem you've described (DNS failure immediately after pod creation when using an Alpine-based Docker image). |
You're sure? Because one of your previous messages said you were using artefactual/gearmand:latest, and Docker Hub says that's 1.1.18. https://hub.docker.com/r/artefactual/gearmand/ docker-compose exec gearmand gearmand -V cat docker-compose.yml | grep gearmand |
Why do you say that? The first two give the exact same error message you are experiencing ("getaddrinfo(Unrecognized service)"), and the third describes the same problem you've described (DNS failure immediately after pod creation when using an Alpine-based Docker image). I'm not sure exactly, but I'll assume that the problem is in the network interaction of kubernet and gearmand, unfortunately the above examples do not fit my case. |
Now I use the following assembly in kubernet and it works containers:
root@gearmand-57b766648d-l4rts:/# gearmand -V Perhaps, as you wrote above, the problem is in the container. But my analysis and my level have not yet allowed me to see the malfunction. |
Well, they sure seem like they fit your case to me.... It seems like your problem is in the network interaction between Kubernetes and Alpine, not gearmand. The artefactual image just happens to be based on Alpine. I don't recommend using clever/gearmand. It's very old. Why don't you build your own Docker image? Maybe base it on Ubuntu instead of Alpine? |
I collected 2 different images, Fedora, Ubuntu. Both work in docker, but they end with errors in kubernetes. FROM Fedora:34 FROM ubuntu:20.4 |
I don't know. Please post your Ubuntu Dockerfile in its entirety here. |
Also, if the Docker image works in Docker but not Kubernetes, have you considered that the problem might be with Kubernetes? That would seem logical to me. |
Also, check out this article: |
ARG USER_ID=101 FROM ubuntu:20.04 RUN apt-get update -y ARG USER_ID RUN apt-get install -y gearman-job-server COPY --chown=gearman:gearman .kubernetes/.docker/images/gearman/gearmand.conf /etc/gearmand.conf USER gearman ARG USER_ID=101 FROM fedora:34 RUN dnf -y update && dnf clean all ARG USER_ID RUN yum install -y gearmand COPY --chown=gearman:gearman .kubernetes/.docker/images/gearman/gearmand.conf /etc/gearmand.conf USER gearman |
Entrypoint gearmand.conf |
My DNS works well, there are no errors or warnings in the logs. |
Huh? Every single log file you've posted has indicated a DNS error. That's what those getaddrinfo errors are. Try getting rid of the |
I've experienced this issue before; the root cause is that K8S auto-injects a Simplest workaround is to explicitly set apiVersion: apps/v1
kind: StatefulSet
metadata:
name: gearmand
spec:
selector:
matchLabels:
app: gearmand
serviceName: gearmand
template:
metadata:
labels:
app: gearmand
spec:
containers:
- image: artefactual/gearmand:1.1.18-alpine
name: gearmand
command: ['gearmand', '--verbose=WARNING']
env:
- name: GEARMAND_PORT
value: '4730'
ports:
- containerPort: 4730
name: gearmand |
Oh that's quite an annoying coincidence. I suppose we should document this
somehow beyond this issue.
…On Wed, Sep 29, 2021 at 3:07 PM Eric Stern ***@***.***> wrote:
I've experienced this issue before; the root cause is that K8S
auto-injects a {SERVICENAME}_PORT={proto}://{addr}:{port} environment
variable. If you've created a service named gearmand in the same
namespace (likely), then the pods have something like GEARMAND_PORT=tcp://
10.0.0.1:4370 set automatically as an environment variable. The gearmand
application reads this, doesn't get an integer in the range of valid ports,
and crashes.
Simplest workaround is to explicitly set GEARMAND_PORT=4370 (or whatever
port you desire) in the pod's spec.containers.env (or, more likely, the
parent statefulset), which will take precedence. Something like this:
apiVersion: apps/v1kind: StatefulSetmetadata:
name: gearmandspec:
selector:
matchLabels:
app: gearmand
serviceName: gearmand
template:
metadata:
labels:
app: gearmand
spec:
containers:
- image: artefactual/gearmand:1.1.18-alpine
name: gearmand
command: ['gearmand', '--verbose=WARNING']
env:
- name: GEARMAND_PORT
value: '4730'
ports:
- containerPort: 4730
name: gearmand
—
You are receiving this because you are subscribed to this thread.
Reply to this email directly, view it on GitHub
<#320 (comment)>,
or unsubscribe
<https://github.com/notifications/unsubscribe-auth/AADS6YCKN4GH25UGJFCTED3UEOE2ZANCNFSM5DK6OOHA>
.
Triage notifications on the go with GitHub Mobile for iOS
<https://apps.apple.com/app/apple-store/id1477376905?ct=notification-email&mt=8&pt=524675>
or Android
<https://play.google.com/store/apps/details?id=com.github.android&referrer=utm_campaign%3Dnotification-email%26utm_medium%3Demail%26utm_source%3Dgithub>.
|
Another solution was posted over in the artefactual-labs/docker-gearmand issue by @blafasel42:
@SpamapS: |
Thank you very much everyone for the clarification. |
@esabol i dont think it is safe to grep the port from the service's ENV-Var. Services have two ports: One they listen to (which is stated in the env var under discussion here) and one the forward requests to (which is the one gearmand needs to listen on). They can be different and then this would make the service disfunctional. I believe it would be better to ignore the GEARMAND_PORT var if the value is not numeric. |
A flag that changes the name of the environment variable would be my preference as a fix, and perhaps also printing out a hint like "GERAMAND_PORT must be numeric" and a cleaner exit value. |
That makes sense to me. I'm not a fan of your other idea though. |
Hello. When creating a pod + service, gearmand stops working.
LOG
INFO 2021-09-03 04:46:16.396362 [ main ] Initializing Gear on port tcp://10.101.82.102:4730 with SSL: false
INFO 2021-09-03 04:46:16.000000 [ main ] Starting up with pid 1, verbose is set to INFO
ERROR 2021-09-03 04:46:16.000000 [ main ] 0.0.0.0:tcp://10.101.82.102:4730 getaddrinfo(Unrecognized service) -> libgearman-server/gearmand.cc:626
INFO 2021-09-03 04:46:16.000000 [ main ] Shutdown complete
The text was updated successfully, but these errors were encountered: