canonical / canonical/livepatch-k8s-operator
canonical-livepatch-server-k8s rev 85: hook failed "leader-elected" on deploy (Juju 4.0.12, K8s)
- Dominant language
- Python
- Stars
- 4
- Forks
- 12
- Avg merge
- 13h 21m
- Merged PRs (30d)
- 4
Description
**Note: This issue was generated with AI assistance (GitHub Copilot) based on automated log analysis and triage.**
Filed by @canonical/solutions-qa
## Summary
During integration testing, `canonical-livepatch-server-k8s` revision 85 (`latest/stable`) entered an `error` state with `hook failed: "leader-elected"` shortly after deployment. The test deploying the charm then timed out waiting for the application to settle.
## Observed behaviour
Juju status captured during `test_deploy` (charm deployed as application `neighbor`):
```
App Version Status Scale Charm Channel Rev Message
neighbor v1.21.3 error 1 canonical-livepatch-server-k8s latest/stable 85 hook failed: "leader-elected"
Unit Workload Agent Address Message
neighbor/0* error idle 10.1.3.151 hook failed: "leader-elected"
Integration provider Requirer Interface Type Message
neighbor:livepatch neighbor:livepatch livepatch peer
```
The test harness then failed with:
```
ERROR Failure in test_deploy: juju.backend.JujuWaitTimeoutError: Timed out while waiting for applications: [active, blocked], units: [active, blocked], unit agents: [idle] (applications: ['neighbor'], units: ['neighbor/0'])
```
## Environment
- Charm: `canonical-livepatch-server-k8s`, revision **85**, channel `latest/stable`
- Juju: **4.0.12** (`juju:4/stable`)
- Base: `ubuntu:24.04`
- Substrate: Kubernetes (cross-model relations / CMR)
- Deployed alongside: `prometheus-k8s` (rev 309, `3.11/stable`), `postgresql-k8s` (rev 925, `14/stable`), `grafana-agent-k8s` (rev 221, `2/candidate`)
- Failing test: `test_deploy`
## Steps to reproduce
1. Deploy `canonical-livepatch-server-k8s` rev 85 from `latest/stable` on a Kubernetes model with Juju 4.0.12 / Ubuntu 24.04.
2. Wait for the application to settle.
3. Observe the unit entering `error` with `hook failed: "leader-elected"`.
## Additional notes
- The application-level `livepatch` peer relation is present at the time of failure.
- The juju-logs archive and CI run logs for this run had expired at the time of triage, so the verbatim Python traceback from the `leader-elected` hook could not be captured. The Juju status above is from the test's captured io_log.
## Test Observer
https://test-observer.canonical.com/#/charms/409553?testExecutionId=656538&testResultId=12415963
Contributor guide
Research direction
Start by rerunning the failing test_deploy on the stated Juju, Ubuntu, and Kubernetes environment, then inspect the captured io_log and Test Observer result around the leader-elected hook. Reproduce the deployment failure and identify the available hook error details; done means the application settles successfully and test_deploy passes without the hook-failed state.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- kubernetes, python
- Domain
- devops, testing
- Issue type
- Bug
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Activity status
- Quiet
- Clarity
- Mostly clear
- Newbie friendliness
- 38/100