logdna / logdna-agent-v2

The blazingly fast, resource efficient log collection client
https://logdna.com
MIT License
65 stars 46 forks source link

/etc/hostname no longer present on OpenShift workers #415

Open thanusiak opened 2 years ago

thanusiak commented 2 years ago

Testing agent-resources-openshift.yaml with: Server Version: 4.10.18

I got the following error:

Events:
  Type     Reason          Age              From               Message
  ----     ------          ----             ----               -------
  Normal   Scheduled       8s               default-scheduler  Successfully assigned ibm-observe/logdna-agent-test-znlr2 to worker12.test.com
  Normal   AddedInterface  7s               multus             Add eth0 [10.254.60.102/22] from openshift-sdn
  Normal   Pulled          5s               kubelet            Successfully pulled image "icr.io/ext/logdna-agent:3.5.2" in 1.319768025s
  Normal   Pulling         4s (x2 over 6s)  kubelet            Pulling image "icr.io/ext/logdna-agent:3.5.2"
  Warning  Failed          3s (x2 over 5s)  kubelet            Error: Cannot mount /etc/hostname: path does not exist and will cause issues as a directory
  Normal   Pulled          3s               kubelet            Successfully pulled image "icr.io/ext/logdna-agent:3.5.2" in 1.282495926s

due to

- name: logdnahostname
          hostPath:
            path: /etc/hostname

Not sure when the change happened in OCP, but workers in fact don't have the hostname file by default.

Replacing path: /etc/hostname with : path: /proc/sys/kernel/hostname

seems to resolve the problem.

dkhokhlov commented 2 years ago

that hostname line has not been touched for very long time and that file should exist in Linux.

I see that file when I run the image:

~$ docker run -it icr.io/ext/logdna-agent:3.5.2 bash
Unable to find image 'icr.io/ext/logdna-agent:3.5.2' locally
3.5.2: Pulling from ext/logdna-agent
54e56e6f8572: Pull complete
4f8ddd7f5a75: Pull complete
769927f5652f: Pull complete
1e852efbf2ff: Pull complete
Digest: sha256:1bb082da732c6e2d6bda583832c4f4dd3f2891cd824682b61c80988d52dc0dcb
Status: Downloaded newer image for icr.io/ext/logdna-agent:3.5.2

[root@ec6a9b7c3744 work]# cat /etc/hostname
ec6a9b7c3744
thanusiak commented 2 years ago

If you run it via docker locally or on standard Linux box it will be present, however it will not be present when run off a CoreOs worker (Openshift). See similar discussion (it does not seem to be specific to FCOS): https://ask.fedoraproject.org/t/location-of-etc-hostname-on-coreos/13426

dkhokhlov commented 2 years ago

ic, you are using FCOS.

Probably something todo with FCOS vs RHCOS.

Red Hat Enterprise Linux CoreOS (RHCOS) is the only operating system supported on the OpenShift control plane nodes. https://cloud.redhat.com/blog/red-hat-enterprise-linux-coreos-customization

@c-nixon ?

thanusiak commented 2 years ago

@dkhokhlov Im referring to RHCOS, just couldnt find any discussion specific to it.

dkhokhlov commented 2 years ago

ic. might be OCP 4 vs OCP 3. some search on RH portal: https://access.redhat.com/search/#/?q=%22%2Fetc%2Fhostname%22%20openshift

@thanusiak are you happy with proc/sys/kernel/hostname solution?

thanusiak commented 2 years ago

It seems to works as expected, so Im good with this solution