Skip to content

Commit c40d9b2

Browse files
feat: new user-domain-changed event format
Add the `domains` attribute to event's payload. The value is a list of domains. The old `domain` attribute is still present and will equal to a random list element. This new event format with multiple domains is necessary to reduce the size of the event burst generated by Ldapproxy when a node joins the cluster.
1 parent 2ce7479 commit c40d9b2

File tree

3 files changed

+8
-4
lines changed

3 files changed

+8
-4
lines changed

core/imageroot/var/lib/nethserver/cluster/actions/alter-external-domain/50alter_ldap_domain

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -44,5 +44,6 @@ if protocol == 'ldap':
4444
}))
4545
# Advertise new user domain setup
4646
rdb.publish(os.getenv('AGENT_ID') + '/event/user-domain-changed', json.dumps({
47-
'domain': domain
47+
'domain': domain, # obsolete
48+
'domains': [domain], # since core 3.16.0
4849
}))

docs/core/events.md

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,8 @@ Events should respect the following rules:
2222
Well known events:
2323
- `user-domain-changed`: the user domain has become available, has been
2424
removed, or its configuration has changed. The JSON parameter format is
25-
`{"node_id":INT,"domain":STRING}`. The `node_id` attribute is optional.
25+
`{"node_id":INT,"domains":LIST[STRING]}`. The `node_id` attribute is not
26+
present for external domains. `domains` is a list of domain names.
2627
- `ldap-provider-changed`: an external LDAP account provider was removed
2728
or added to a user-domain. The JSON parameter format is
2829
`{"domain":STRING,"key":STRING}`.

docs/core/user_domains.md

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -61,8 +61,10 @@ event handler. Create an executable script with path
6161
`${AGENT_INSTALL_DIR}/events/user-domain-changed/10handler`. For instance:
6262

6363
```shell
64-
read -r domain < <(jq -r .domain)
65-
if [[ "${domain}" == "mydomain" ]]; then
64+
mydomain="ad.example.org"
65+
66+
# Check if $mydomain is in the list of changed domains
67+
if jq -e --arg d "$mydomain" '.domains | index($d)' >/dev/null; then
6668
systemctl --user reload mymodule.service
6769
fi
6870
```

0 commit comments

Comments
 (0)