mrlhansen / idrac_exporter

Simple iDRAC exporter for Prometheus
MIT License
123 stars 37 forks source link

idrac-exporter 1.3.1 fails to start #87

Closed svenfoo closed 1 month ago

svenfoo commented 1 month ago

After upgrading from 1.1.0 to 1.3.1 the idrac-exporter pod crashes on startup with the following error message:

/app/entrypoint.sh: line 17: /app/config/idrac.yml: No such file or directory                                                                                                                        
2024-07-08T15:39:49.164 FATAL Failed to open configuration file: /etc/prometheus/idrac.yml: open /etc/prometheus/idrac.yml: no such file or directory     

To me it looks like the entrypoint.sh script has two flaws:

  1. It attempts to write to /app/config/idrac.yml but the folder /app/config does not exist in the Docker image.
  2. In https://github.com/mrlhansen/idrac_exporter/blob/master/entrypoint.sh#L17 it writes the file, but it doesn't change the $config variable accordingly.
mrlhansen commented 1 month ago

Hi @svenfoo

Yes, you are right. Thanks for letting me know.

I will merge the fix, but the entrypoint.sh is largely obsolete now that the exporter natively supports configuration via environment variables. I was contemplating removing it when I made the latest release, but decided to keep it for compatibility, but at some point I will probably remove it.

svenfoo commented 1 month ago

I will merge the fix, but the entrypoint.sh is largely obsolete now that the exporter natively supports configuration via environment variables. I was contemplating removing it when I made the latest release, but decided to keep it for compatibility, but at some point I will probably remove it.

Thanks for letting us now. I will update our Kubernetes setup to use environment variables then.

svenfoo commented 1 month ago

Looked into that now and our usage scenario is somewhat difficult to implement only with environment variables. We want to have idrac-exporter running on each node of the cluster, so we are using a daemonset. And each node has its own iDRAC credentials, so we need to look them up at run-time depending on the node name. This is easily implemented by mounting the credentials of all nodes and letting entrypoint.sh do it's magic.

Maybe there's a simpler way to implement this. If idrac-exporter had an environment variable, or configuration option, to tell it to dynamically obtain the credentials based on the node name, that would help a lot.

mrlhansen commented 1 month ago

Alright, so we should probably keep the entry point in that case. However, I guess it can be simplified quite a bit, for example (not actually tested):

#!/bin/bash

auth_file="/authconfig/$NODE_NAME"
if [ -f "$auth_file" ]; then
    export CONFIG_DEFAULT_USERNAME=$(cut -f1  -d= $auth_file)
    export CONFIG_DEFAULT_PASSWORD=$(cut -f2- -d= $auth_file)
fi

exec bin/idrac_exporter "$@"

In this way you will still be able to have the per-node definition of the credentials. The rest of the configuration can either be configured via environment variables, or by mapping a configuration file into the container.

What do you think?

svenfoo commented 1 month ago

What do you think?

That should work for us. It's more or less what I hacked up yesterday by overriding the entrypoint command. But I would prefer if we wouldn't have to do that.

mrlhansen commented 1 month ago

Sounds good, then I will try to push an update later today.

svenfoo commented 1 month ago

Fixed by commit fa0cd16de9414ee9e4dc70f40528f1a88226f467