install hook failure at apt-key add run by 'ansible-playbook -c local playbook.yaml --tags install'
Affects | Status | Importance | Assigned to | Milestone | |
---|---|---|---|---|---|
Elasticsearch Charm |
Fix Released
|
High
|
Joe Guo |
Bug Description
Solutions QA CI has seen several failures in the elasticsearch charms install hook when apt-key add is call from 'ansible-playbook -c local playbook.yaml --tags install'
The test run details are available here:
https:/
Below is the error output in unit-elasticsea
2020-02-25 19:41:22 DEBUG install TASK [Add an apt key in a raw format.] *******
2020-02-25 19:41:26 DEBUG install fatal: [localhost]: FAILED! => {"changed": false, "cmd": "/usr/bin/apt-key add -", "msg": "Warning: apt-key output should not be parsed (stdout is not a terminal)\ngpg: can't connect to the agent: IPC connect call failed", "rc": 2, "stderr": "Warning: apt-key output should not be parsed (stdout is not a terminal)\ngpg: can't connect to the agent: IPC connect call failed\n", "stderr_lines": ["Warning: apt-key output should not be parsed (stdout is not a terminal)", "gpg: can't connect to the agent: IPC connect call failed"], "stdout": "", "stdout_lines": []}
2020-02-25 19:41:26 DEBUG install to retry, use: --limit @/var/lib/
2020-02-25 19:41:26 DEBUG install
2020-02-25 19:41:26 DEBUG install PLAY RECAP *******
2020-02-25 19:41:26 DEBUG install localhost : ok=1 changed=0 unreachable=0 failed=1
2020-02-25 19:41:26 DEBUG install
2020-02-25 19:41:28 DEBUG install Traceback (most recent call last):
2020-02-25 19:41:28 DEBUG install File "/var/lib/
2020-02-25 19:41:28 DEBUG install hooks.execute(
2020-02-25 19:41:28 DEBUG install File "/var/lib/
2020-02-25 19:41:28 DEBUG install self.playbook_path, tags=[hook_name], extra_vars=
2020-02-25 19:41:28 DEBUG install File "/var/lib/
2020-02-25 19:41:28 DEBUG install subprocess.
2020-02-25 19:41:28 DEBUG install File "/usr/lib/
2020-02-25 19:41:28 DEBUG install raise CalledProcessEr
2020-02-25 19:41:28 DEBUG install subprocess.
2020-02-25 19:41:28 ERROR juju.worker.
Changed in charm-elasticsearch: | |
status: | New → Triaged |
importance: | Undecided → High |
Changed in charm-elasticsearch: | |
assignee: | nobody → Joe Guo (guoqiao) |
status: | Triaged → In Progress |
Changed in charm-elasticsearch: | |
status: | In Progress → Fix Committed |
milestone: | none → 20.05 |
Changed in charm-elasticsearch: | |
status: | In Progress → Fix Committed |
Changed in charm-elasticsearch: | |
status: | Fix Committed → Fix Released |
I am not able to reproduce this issue in local juju env, the add_key task works smoothly for me.
By searching the error message:
gpg: can't connect to the agent: IPC connect call failed
the results show that it is normally because a gpg-agent is already running, but current process can not connect to it.
The suggested solution is to kill it and let it restart.
According to `man gpg-agent`:
1. The agent is automatically started on demand by gpg, gpgsm, gpgconf, or gpg-connect-agent. Thus there is no reason to start it manually.
2. If you want to manually terminate the currently-running agent, you can safely do so with: gpgconf --kill gpg-agent
So it's safe to kill the agent before apt_key, to avoid potential gpg connection issue. It will start on demand.
Add a patch to kill agent before apt_key tasks:
https:/ /code.launchpad .net/~guoqiao/ charm-elasticse arch/+git/ charm-elasticse arch/+merge/ 380940
It may or may not fix this issue, but wouldn't be any harm.
Task tested without issue:
unit-es-0: 22:13:40 DEBUG unit.es/ 0.config- changed TASK [kill gpg-agent] ******* ******* ******* ******* ******* ******* ******* ******* ** 0.config- changed changed: [localhost] 0.config- changed 0.config- changed TASK [Add apt key.] ******* ******* ******* ******* ******* ******* ******* ******* **** 0.config- changed skipping: [localhost] 0.config- changed 0.config- changed TASK [Add an apt key in a raw format.] ******* ******* ******* ******* ******* ****** 0.config- changed ok: [localhost]
unit-es-0: 22:13:41 DEBUG unit.es/
unit-es-0: 22:13:41 DEBUG unit.es/
unit-es-0: 22:13:41 DEBUG unit.es/
unit-es-0: 22:13:41 DEBUG unit.es/
unit-es-0: 22:13:41 DEBUG unit.es/
unit-es-0: 22:13:41 DEBUG unit.es/
unit-es-0: 22:13:44 DEBUG unit.es/