Skip to content

Commit 27398bb

Browse files
doc: add extra info over ansible watches and reconcile period (#3384)
**Description of the change:** - add info over reconcilePeriod similar to the sync period attribute of [manager.Options](https://godoc.org/sigs.k8s.io/controller-runtime/pkg/manager#Options) to make clear that users should avoid small periods - clarifies that users are able to create many CRD's and use the APIs to persuade the concepts such as single responsibility, cohesion and encapsulation which would bring more flexibility and optimization since they are able to do configurations per GKV via the watches file. **Motivation for the change:** #3364
1 parent 60d7572 commit 27398bb

File tree

2 files changed

+33
-4
lines changed

2 files changed

+33
-4
lines changed

website/content/en/docs/ansible/development-tips.md

+5-2
Original file line numberDiff line numberDiff line change
@@ -187,8 +187,7 @@ the below section for Ansible Operator specific annotations.
187187
#### Ansible Operator annotations
188188
This is the list of CR annotations which will modify the behavior of the operator:
189189

190-
**ansible.operator-sdk/reconcile-period**: Used to specify the reconciliation
191-
interval for the CR. This value is parsed using the standard Golang package
190+
**ansible.operator-sdk/reconcile-period**: Specifies the maximum time before a reconciliation is triggered. Note that at scale, this can reduce performance, see [watches][watches] reference for more information. This value is parsed using the standard Golang package
192191
[time][time_pkg]. Specifically [ParseDuration][time_parse_duration] is used
193192
which will apply the default suffix of `s` giving the value in seconds.
194193

@@ -202,6 +201,9 @@ annotations:
202201
ansible.operator-sdk/reconcile-period: "30s"
203202
```
204203

204+
Note that a lower period will correct entropy more quickly, but reduce responsiveness to change
205+
if there are many watched resources. Typically, this option should only be used in advanced use cases where `watchDependentResources` is set to `False` and when is not possible to use the watch feature. E.g To managing external resources that don’t raise Kubernetes events.
206+
205207
### Testing an Ansible operator locally
206208

207209
Once a developer is comfortable working with the above workflow, it will be
@@ -507,3 +509,4 @@ operator. The `meta` fields can be accesses via dot notation in Ansible as so:
507509
[manage_status_proposal]:../../proposals/ansible-operator-status.md
508510
[time_pkg]:https://golang.org/pkg/time/
509511
[time_parse_duration]:https://golang.org/pkg/time/#ParseDuration
512+
[watches]:/docs/ansible/reference/watches

website/content/en/docs/ansible/reference/watches.md

+28-2
Original file line numberDiff line numberDiff line change
@@ -27,8 +27,7 @@ be monitored for updates and cached.
2727
current project directory.
2828
* **vars**: This is an arbitrary map of key-value pairs. The contents will be
2929
passed as `extra_vars` to the playbook or role specified for this watch.
30-
* **reconcilePeriod** (optional): The reconciliation interval, how often the
31-
role/playbook is run, for a given CR.
30+
* **reconcilePeriod** (optional): The maximum interval in seconds that the operator will wait before beginning another reconcile, even if no watched events are received. When an operator watches many resources, each reconcile can become expensive, and a low value here can actually reduce performance. Typically, this option should only be used in advanced use cases where `watchDependentResources` is set to `False` and when is not possible to use the watch feature. E.g To managing external resources that don’t raise Kubernetes events.
3231
* **manageStatus** (optional): When true (default), the operator will manage
3332
the status of the CR generically. Set to false, the status of the CR is
3433
managed elsewhere, by the specified role/playbook or in a separate controller.
@@ -122,3 +121,30 @@ Some features can be overridden per resource via an annotation on that CR. The o
122121
vars:
123122
state: absent
124123
```
124+
125+
**Note:** By using the command `operator-sdk add api` you are able to add additional CRDs to the project API, which can aid in designing your solution using concepts such as encapsulation, single responsibility principle, and cohesion, which could make the project easier to read, debug, and maintain. With this approach, you are able to customize and optimize the configurations more specifically per GKV via the `watches.yaml` file.
126+
127+
**Example:**
128+
129+
```YaML
130+
---
131+
- version: v1alpha1
132+
group: app.example.com
133+
kind: AppService
134+
playbook: playbook.yml
135+
maxRunnerArtifacts: 30
136+
reconcilePeriod: 5s
137+
manageStatus: False
138+
watchDependentResources: False
139+
finalizer:
140+
name: finalizer.app.example.com
141+
vars:
142+
state: absent
143+
144+
- version: v1alpha1
145+
group: app.example.com
146+
kind: Database
147+
playbook: playbook.yml
148+
watchDependentResources: True
149+
manageStatus: True
150+
```

0 commit comments

Comments
 (0)