Skip to content

Commit 010ee1b

Browse files
authored
Merge pull request #3645 from larsewi/federated-reporting-duplicate-hosts
Clarify duplicate host management in federated reporting docs
2 parents a693072 + fa3acd6 commit 010ee1b

1 file changed

Lines changed: 38 additions & 14 deletions

File tree

content/web-ui/federated-reporting.markdown

Lines changed: 38 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -169,14 +169,23 @@ the superhub.
169169

170170
## Duplicate host management
171171

172-
There are situations where feeder hubs may have hosts with duplicate hostkeys:
172+
When using federated reporting, the superhub can end up importing the same hostkey from more than one feeder.
173+
This typically happens when a host is re-bootstrapped to a different feeder, when a VM is re-spawned from an image that preserves the existing key material, or when a host is cloned without regenerating its key pair with `cf-key` and refreshing `$(sys.workdir)/ppkeys/localhost.pub`.
174+
In all of these cases, multiple feeders hold a record under the same hostkey.
173175

174-
- hosts are able to "float", re-bootstrap or failover to several different feeder hubs
175-
- hosts may be cloned and not have their hostkey refreshed by running `cf-key` and refreshing `$(sys.workdir)/ppkeys/localhost.pub`.
176+
CFEngine provides two mechanisms for resolving these cross-feeder duplicates.
177+
They address the same underlying problem with different approaches:
176178

177-
In the first case you will likely want to remove entries for hosts which are not the latest since the latest data will be most accurate.
179+
- [Distributed cleanup][Federated reporting#Distributed cleanup] is a cleanup on the feeders.
180+
A script on the superhub identifies the feeder with the most recent contact for each hostkey and then calls back into the other feeders to delete the stale records at the source, so they are never re-imported.
178181

179-
There are two options available for handling these situations depending on your environment: Distributed Cleanup or Handle Duplicate Hostkeys.
182+
- [Handle duplicate hostkeys][Federated reporting#Handle duplicate hostkeys] is a filter on the superhub.
183+
During each import cycle on the superhub, duplicate rows for the same hostkey are compared by `__hosts.lastreporttimestamp`, and all but the most recent are moved out of the per-feeder schemas into a separate `dup` schema for later analysis, so only the most recently reporting host remains visible in Mission Portal.
184+
185+
Note that neither mechanism deduplicates hosts that share a hostkey but report to the _same_ feeder — a feeder's database is keyed on hostkey alone.
186+
Hence, the most recent report simply overwrites the previous one there.
187+
A health diagnostic alert should be visible in Mission Portal in this case.
188+
Regardless of whether you are using federedated reporting or not, the recommended fix is to regenerate the conflicting key pairs.
180189

181190
### Distributed cleanup
182191

@@ -221,21 +230,36 @@ This will distribute the needed certificates from feeders to superhub so that th
221230
When run manually for the first time the utility will create a limited privileges user to view and delete hosts on the feeders.
222231
You will need to enter the following information at the prompts when running the utility manually:
223232

224-
- admin password for the superhub
225-
- email address for the fr_distributed_cleanup limited privileges user
226-
- admin password for each feeder
233+
- admin username and password for the superhub (the username defaults to `admin` if left blank)
234+
- a 2FA code for the superhub, if 2FA is enabled for the admin account
235+
- email address for the `fr_distributed_cleanup` limited privileges user
236+
- admin username and password for each feeder (the username defaults to `admin` if left blank)
237+
- a 2FA code for each feeder, if 2FA is enabled for the admin account
227238

228239
After confirming all feeder certs and public keys are present on the superhub, run the distributed cleanup script manually.
229240

230-
```bash
231-
# ls /opt/cfengine/federation/cftransport/distributed_cleanup/
241+
```command
242+
ls /opt/cfengine/federation/cftransport/distributed_cleanup/
243+
```
244+
245+
```output
232246
superhub.pub feeder1.cert feeder1.pub feeder2.cert feeder2.pub
247+
```
233248

234-
# /opt/cfengine/federation/bin/distributed_cleanup.py
235-
Enter admin credentials for superhub https://superhub.domain/api:
249+
```command
250+
/opt/cfengine/federation/bin/distributed_cleanup.py
251+
```
252+
253+
```output
254+
Enter admin username for superhub superhub.domain [admin]:
255+
Enter admin password for superhub superhub.domain:
236256
Enter email for fr_distributed_cleanup accounts:
237-
Enter admin credentials for feeder1 at https://feeder1.domain/api:
238-
Enter admin credentials for feeder2 at https://feeder2.domain/api:
257+
258+
Enter admin username for feeder1 [admin]:
259+
Enter admin password for feeder1:
260+
261+
Enter admin username for feeder2 [admin]:
262+
Enter admin password for feeder2:
239263
```
240264

241265
The passwords are only kept for the duration of the script execution and are not saved.

0 commit comments

Comments
 (0)