Skip to content

Commit b1f5956

Browse files
authored
docs: improve testflinger agent host documentation (#924)
* docs: update README and CONTRIBUTING guides * docs: update documentation with agent administration tasks * fixes * fix spell checks * reestructure administrator to be inside how-to * add suggestions made by reviewers * fix title underline * fix other line lengths * modify how-to index
1 parent bd7b20c commit b1f5956

File tree

9 files changed

+451
-127
lines changed

9 files changed

+451
-127
lines changed
Lines changed: 49 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,49 @@
1+
# Contributing to Testflinger
2+
3+
This document outlines contribution guidelines specific to the Testflinger charm.
4+
To learn more about the general contribution guidelines for the Testflinger project, refer to the [Testflinger contribution guide](../../../CONTRIBUTING.md).
5+
6+
To make contributions to this charm, you'll need a working
7+
[development setup][juju-setup]. If you are setting up a VM manually, you may
8+
want to use [`concierge`][concierge]. To get started run:
9+
10+
```shell
11+
concierge prepare --verbose --juju-channel=3/stable --charmcraft-channel=latest/stable -p machine
12+
```
13+
14+
You can create an environment for development with [`uv`][uv] from within the `agent` directory (you can install it as a [snap][uv-snap]):
15+
16+
```shell
17+
uv sync
18+
source .venv/bin/activate
19+
```
20+
21+
## Testing
22+
23+
This project uses [`tox`][tox] for managing test environments. There are some pre-configured environments
24+
that can be used for linting and formatting code when you're preparing contributions to the charm:
25+
26+
```shell
27+
uvx --with tox-uv tox run -e format # update your code according to linting rules
28+
uvx --with tox-uv tox -e lint # code style
29+
uvx --with tox-uv tox -e charm-unit # charm unit tests
30+
uvx --with tox-uv tox -e charm-integration # charm integration tests
31+
```
32+
33+
## Build the charm
34+
35+
Build the charm with [`charmcraft`][charmcraft-snap]:
36+
37+
```shell
38+
charmcraft pack
39+
```
40+
41+
> [!NOTE]
42+
> Before running the integration tests, you require to build the charm
43+
44+
[juju-setup]: https://documentation.ubuntu.com/juju/3.6/howto/manage-your-deployment/#set-up-your-deployment-local-testing-and-development
45+
[concierge]: https://snapcraft.io/concierge
46+
[uv]: https://docs.astral.sh/uv
47+
[uv-snap]: https://snapcraft.io/astral-uv
48+
[tox]: https://tox.wiki/en/4.32.0/
49+
[charmcraft-snap]: https://snapcraft.io/charmcraft
Lines changed: 34 additions & 127 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,9 @@
11
# Testflinger Agent Host Charm
22

3+
[![Charmcraft][charmcraft-badge]][charmcraft-site]
4+
[![uv Status][uv-badge]][uv-site]
5+
[![Ruff status][ruff-badge]][ruff-site]
6+
37
## Overview
48

59
This charm provides the base system for a host system that will be used for
@@ -10,12 +14,12 @@ in `src/tf-cmd-scripts/` to the host system. The scripts would be used by the
1014
`testflinger-agent` to trigger the `testflinger-device-connector` at each
1115
phase.
1216

13-
## Deploying
17+
## Basic Usage
1418

15-
To deploy a Testflinger agent host from charmhub, you can use:
19+
On [Juju-ready][juju] systems, you can deploy it on the command-line with:
1620

1721
```shell
18-
juju deploy testflinger-agent-host --channel=edge
22+
juju deploy testflinger-agent-host
1923
```
2024

2125
## Configuration
@@ -31,45 +35,16 @@ Supported options for this charm are:
3135
- `config-repo`:
3236
Git repository containing device agent configuration data
3337
- `config-branch`:
34-
Git branch to pull for the configuration data
38+
Git branch to pull for the configuration data (default: `main`)
3539
- `config-dir`:
3640
Path from the root of the configuration repository where the
3741
directories and configurations are located for this agent host
38-
39-
To keep the tf-cmd-scripts files up-to-date, run:
40-
41-
```shell
42-
juju upgrade-charm {testflinger-agent-host-application}
43-
```
44-
45-
The `config-repo` where the Testflinger configurations for the agents are stored
46-
should contain a directory tree. The leaf directories should be named the same
47-
as the `agent-id` configured for the agent in the `testflinger-agent.conf`
48-
file, and this directory should contain the configuration files for both the
49-
agent and the device connector. For example, consider a repository containing
50-
the configurations for multiple locations and agents. It might have a structure
51-
like this:
52-
53-
```text
54-
/
55-
- lab1/
56-
- agent-101/
57-
- testflinger-agent.conf
58-
- default.yaml
59-
- agent-102/
60-
- testflinger-agent.conf
61-
- default.yaml
62-
- ...
63-
- lab2/
64-
- agent-201/
65-
- testflinger-agent.conf
66-
- default.yaml
67-
- ...
68-
...
69-
```
70-
71-
In order to make the charm consider only the agents under the `lab1` directory,
72-
you should set the `config-dir` to `lab1`.
42+
- `testflinger-server`:
43+
The hostname of the Testflinger server to connect to, this is required
44+
for authentication (default: `https://testflinger.canonical.com`)
45+
- `credentials-secret`:
46+
URI to the Juju Secret that contains the credentials to perform authentication
47+
against `testflinger-server`
7348

7449
## Actions
7550

@@ -79,7 +54,9 @@ The following actions are supported for this charm:
7954
This action is used to update the `testflinger-agent` and install it to a
8055
location shared by all the agents running on this host.
8156
This action will trigger all running agents to restart when they are not
82-
running a job.
57+
running a job. The following key is optional:
58+
- `branch`: The name of the branch to pull Testflinger agent code
59+
from (default if not specified is `main`)
8360
- `update-configs`:
8461
This action pulls the git repository set in the charm configuration to
8562
update the agent configurations on the agent host.
@@ -90,99 +67,29 @@ The following actions are supported for this charm:
9067
running agents to restart when they are not running a job in case the
9168
Testflinger configuration has changed.
9269

93-
## Building
94-
95-
To build this charm, first install charmcraft:
96-
97-
```shell
98-
sudo snap instsall --classic charmcraft
99-
```
100-
101-
Then build the charm:
102-
103-
```shell
104-
charmcraft pack
105-
```
106-
107-
## Testing
108-
109-
This charm includes both unit and integration tests. The integration tests
110-
take some time to run and require setting up juju in your test environment
111-
as described [here][set-up-juju].
112-
113-
Once you've done that, you can run all the unit and integration tests by
114-
going up 2 directories from here to the `agent` directory, and running:
115-
116-
```shell
117-
tox -e charm
118-
```
119-
120-
For debugging, it can be useful to keep the model that was deployed so that
121-
it can be reused. To do this, you can add a few additional arguments to tox:
122-
123-
```shell
124-
tox -e charm -v -- --model=testmodel --keep-models
125-
```
126-
127-
This will create a model called `testmodel` and keep it after the run is
128-
complete. If you want to reuse it without deploying again, you can
129-
run the same command again with `--no-deploy` at the end.
130-
131-
## Operational Notes
132-
133-
### Using supervisorctl on the agent host to check status
134-
135-
The agent host is configured to use supervisorctl to manage the agents. From the
136-
agent host, you can run `sudo supervisorctl status` to see the status of all the
137-
agents configured on it.
138-
139-
### Viewing the agent logs
140-
141-
To show the logs for a specific agent, run
142-
`sudo supervisorctl tail <agent name>`. You can also use the `-f` option to
143-
follow the logs.
144-
145-
To show the logs for supervisorctl itself, to see what it's recently started,
146-
stopped, or signalled, you can use `supervisorctl maintail`.
147-
148-
### Stopping and restarting agents
14970

150-
You can use `sudo supervisorctl stop <agent name>` to stop a specific agent.
151-
Be aware that other actions on the charm such as `update-configs` might later
152-
cause this to restart the agents. In order to mark it offline so that it will
153-
no longer process jobs, you may want to either remove it completely from the
154-
configurations, or set a disable marker file using
155-
`touch /tmp/TESTFLINGER-DEVICE-OFFLINE-<agent name>` instead.
71+
## Community and Support
15672

157-
To signal an agent to safely restart when it's no longer running a job, you can
158-
run `sudo supervisorctl signal USR1 <agent name>`.
73+
You can report any issues, bugs, or feature requests on the project's
74+
[GitHub repository][canonical/testflinger].
15975

160-
### Updating agent configs
76+
## Contribute to the Testflinger Agent Host Charm
16177

162-
If the agent configurations in the `config-repo` have changed, you can run
163-
`juju run testflinger-agent-host-application/0 update-configs`
164-
(use `run-action` for juju < 3.x) to update the agent configurations on the
165-
agent host. This will automatically add any new agents, remove any agents that
166-
are no longer configured, and all agents will be sent a signal to restart when
167-
they are not running a job.
78+
The Testflinger Agent Host Charm is open source. Contributions are welcome.
16879

169-
### Updating the Testflinger repository
80+
If you're interested, start with the [charm contribution guide](CONTRIBUTING.md).
17081

171-
When the code for the agent or device connectors changes, you can run
172-
`juju run testflinger-agent-host-application/0 update-testflinger` to update
173-
the Testflinger repository on the agent host. This will automatically trigger
174-
a safe restart on all the agents after installing the new code.
82+
## License and Copyright
17583

176-
### Changes to the supervisord configurations
84+
The Testflinger Agent Host Charm is released under the [Apache-2.0 license](LICENSE).
17785

178-
Be aware that if you change anything in the supervisord configurations under
179-
`/etc/supervisor/conf.d`, the agents will be **forced** to restart without
180-
waiting for running jobs to terminate the next time you run the
181-
`update-configs` action or perform a configuration change in the charm. This is
182-
because it runs `supervisorctl update`. This should not normally happen, but if
183-
for some reason you need to make a change to the charm that causes it to write
184-
changes to the supervisord configurations, then you should take precautions to
185-
ensure that the agents are not running jobs when `supervisord update` is run the
186-
next time.
86+
© 2026 Canonical Ltd.
18787

188-
[set-up-juju]: https://juju.is/docs/sdk/dev-setup#heading--manual-set-up-juju
88+
[juju]: https://canonical.com/juju
89+
[charmcraft-badge]: https://charmhub.io/testflinger-agent-host/badge.svg
90+
[charmcraft-site]: https://charmhub.io/testflinger-agent-host
91+
[uv-badge]: https://img.shields.io/endpoint?url=https://raw.githubusercontent.com/astral-sh/uv/main/assets/badge/v0.json
92+
[uv-site]: https://github.com/astral-sh/uv
93+
[ruff-badge]: https://img.shields.io/endpoint?url=https://raw.githubusercontent.com/astral-sh/ruff/main/assets/badge/v2.json
94+
[ruff-site]: https://github.com/astral-sh/ruff
95+
[canonical/testflinger]: https://github.com/canonical/testflinger

docs/.custom_wordlist.txt

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,5 +14,6 @@ Queryable
1414
rclone
1515
SDWire
1616
stderr
17+
supervisorctl
1718
Tegra
1819
WebDAV

docs/explanation/agents.rst

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,8 @@ able to communicate with the server. If an agent has not checked in after 7 days
3333
it will automatically be removed from the database and will no longer appear in
3434
the "Agents" list.
3535

36+
.. _handling-agent-status:
37+
3638
Handling Agent Status
3739
-------------------------------------------
3840

0 commit comments

Comments
 (0)