Setting rules-update-ssh-key results in "invalid format"

Bug #2018932 reported by Chris Johnston
6
This bug affects 1 person
Affects Status Importance Assigned to Milestone
Prometheus2 charm
Fix Released
Undecided
Chris Johnston

Bug Description

When configuring rules-update-ssh-key, I am seeing:

2023-05-08 18:20:22 WARNING unit.prometheus/0.config-changed logger.go:60 Cloning into '/var/snap/prometheus/current/custom.rules.d'...
2023-05-08 18:20:22 WARNING unit.prometheus/0.config-changed logger.go:60 Load key "/root/.ssh/prometheus_git_key": invalid format

This is preventing the ability to clone the repo. If I manually add the key to the machine and then do a diff between the two files I see:

root@prometheus-1:~/.ssh# diff prometheus_git_key prometheus_git_key_manual
38c38
< -----END OPENSSH PRIVATE KEY-----
\ No newline at end of file
---
> -----END OPENSSH PRIVATE KEY-----
root@prometheus-1:~/.ssh#

If I comment out the prometheus_ssh_keyfile portions of prometheus.py [1] and manually add the ssh key, adding the repo works fine.

[1] diff prometheus.py prometheus.py.new
157,159c157,159
< with open(PATHS["prometheus_ssh_keyfile"], "w") as f:
< f.write(config["rules-update-ssh-key"])
< os.chmod(PATHS["prometheus_ssh_keyfile"], 0o600)
---
> #with open(PATHS["prometheus_ssh_keyfile"], "w") as f:
> # f.write(config["rules-update-ssh-key"])
> #os.chmod(PATHS["prometheus_ssh_keyfile"], 0o600)
238,239c238,239
< if os.path.exists(PATHS["prometheus_ssh_keyfile"]):
< os.unlink(PATHS["prometheus_ssh_keyfile"])
---
> #if os.path.exists(PATHS["prometheus_ssh_keyfile"]):
> # os.unlink(PATHS["prometheus_ssh_keyfile"])

Related branches

Revision history for this message
Chris Johnston (cjohnston) wrote :

With help from SEG, we found out that doing `juju config prometheus2 rules-update-ssh-key=@private_ssh_key_file` worked, where the following did not work in my scenario:

`juju config prometheus rules-update-ssh-key="$(cat <private_ssh_key_file>)"`
`juju config prometheus rules-update-ssh-key="<pasted contents of the file>"

This is believed to possibly be related to the way the key was generated (probably PuTTY).

Changed in charm-prometheus2:
assignee: nobody → Chris Johnston (cjohnston)
status: New → Fix Committed
Ashley James (dashmage)
Changed in charm-prometheus2:
milestone: none → 23.07
Ashley James (dashmage)
Changed in charm-prometheus2:
status: Fix Committed → Fix Released
To post a comment you must log in.
This report contains Public information  
Everyone can see this information.

Other bug subscribers

Remote bug watches

Bug watches keep track of this bug in other bug trackers.