Skip to content

Commit 5c40404

Browse files
committed
docs: add debugging tips to DEVELOPMENT.md
Adds a 'Debugging the controller locally' section covering the knobs that come up most often when reproducing issues: - RUNTIME_NAMESPACE to limit watched namespaces - --concurrent=1 to serialize reconciles - flux suspend for unrelated objects - cross-controller setup for paths that need events from source/kustomize/helm controllers Fixes #362 Signed-off-by: alliasgher <alliasgher123@gmail.com>
1 parent b4f379e commit 5c40404

1 file changed

Lines changed: 50 additions & 1 deletion

File tree

DEVELOPMENT.md

Lines changed: 50 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -77,4 +77,53 @@ Deploy `notification-controller` into the cluster that is configured in the loca
7777

7878
```sh
7979
make deploy
80-
```
80+
```
81+
82+
## Debugging the controller locally
83+
84+
When reproducing an issue or stepping through reconciliation logic, the
85+
following knobs make local runs cheaper and the resulting logs easier to
86+
read.
87+
88+
### Limit the watched namespace
89+
90+
The controller watches every namespace by default. To narrow it to a single
91+
namespace, set the `RUNTIME_NAMESPACE` environment variable before invoking
92+
`make run`:
93+
94+
```sh
95+
RUNTIME_NAMESPACE=flux-system make run
96+
```
97+
98+
### Reduce reconcile concurrency
99+
100+
Each `Alert`, `Provider`, and `Receiver` reconcile is processed concurrently
101+
(default `--concurrent=4`). When debugging it is almost always easier to
102+
follow a serial trace; pass `--concurrent=1` so reconciles run one at a
103+
time:
104+
105+
```sh
106+
go run ./main.go --concurrent=1
107+
```
108+
109+
### Suspend unrelated objects
110+
111+
If the controller is sharing a cluster with other Flux objects, suspend
112+
anything not relevant to the test you're running so their reconciles don't
113+
interleave with yours:
114+
115+
```sh
116+
flux suspend alert <name>
117+
flux suspend receiver <name>
118+
```
119+
120+
Resume them with `flux resume` when you're done.
121+
122+
### Cross-controller interactions
123+
124+
`notification-controller` reads `Event` resources produced by
125+
`source-controller`, `kustomize-controller`, and `helm-controller`. When
126+
testing a path that requires those events, run the relevant controller
127+
locally too (or keep its in-cluster instance running) and point both at the
128+
same management cluster. Suspending the unrelated controllers' objects per
129+
the previous step avoids racing reconciles.

0 commit comments

Comments
 (0)