Skip to content

ENT-6511: Increase cf-monitord measurement slots from 100 to 300#20

Closed
nickanderson wants to merge 1 commit into
masterfrom
CFE-612-increase-monitor-slots
Closed

ENT-6511: Increase cf-monitord measurement slots from 100 to 300#20
nickanderson wants to merge 1 commit into
masterfrom
CFE-612-increase-monitor-slots

Conversation

@nickanderson

Copy link
Copy Markdown
Owner

Summary

Increased CF_OBSERVABLES from 100 to 300 across all relevant headers to allow cf-monitord to measure up to 300 things.

Changes

  • libpromises/cf3.defs.h: CF_OBSERVABLES 100 -> 300
  • cf-check/observables.h: CF_OBSERVABLES 100 -> 300
  • cf-check/db_structs.h: CF_OBSERVABLES 100 -> 300
  • tests/unit/mon_cpu_test.c: array size [100] -> [300]
  • tests/unit/mon_load_test.c: array size [100] -> [300]
  • tests/unit/mon_processes_test.c: array size [100] -> [300]
  • tests/unit/mon_slots_test.c: new — verifies 300-slot capacity (5 tests)
  • core/NOTES_ENT-6511.md: documentation

Verification

  • CF_OBSERVABLES = 300 consistent in all 3 headers
  • SLOTS[228] custom slots available (300 - 72 built-in)
  • sizeof(Averages) = 9,608 bytes matches across all modules
  • No hardcoded 100 limits in code
  • Unit test mon_slots_test.c passes all 5 assertions
  • Full make succeeds cleanly

@nickanderson
nickanderson force-pushed the CFE-612-increase-monitor-slots branch from 8cf4641 to 3aebd63 Compare July 20, 2026 07:32
@nickanderson nickanderson reopened this Jul 20, 2026
@nickanderson
nickanderson force-pushed the CFE-612-increase-monitor-slots branch 5 times, most recently from 2110807 to 8a9567c Compare July 20, 2026 14:42
Comment thread cf-check/observables.c Fixed
Out of the box ~80 of 100 measurement slots are used by default
measurements, leaving little room for custom measurements. This
change increases the maximum number of slots to 300.

Changes are synchronized across:
  - libpromises/cf3.defs.h (main constant)
  - cf-check/observables.h (cf-check copy)
  - cf-check/db_structs.h (LMDB struct layout)
  - libpromises/constants.c (OBSERVABLES name table)
  - tests/unit/mon_*_test.c (unit test buffers)

The OBSERVABLES name table must have an entry per slot: cf-monitord's
GetObservable() falls back to OBSERVABLES[i] for any slot without a
registered measurement, so leaving the table at 100 entries while raising
CF_OBSERVABLES makes cf-monitord read past its end (NULL) and crash on the
first sampling pass, whether or not any custom measurements are configured.
The table is extended to 300 entries to match.

cf-check dump must tolerate monitoring state written before the upgrade: a
pre-upgrade record is shorter than the enlarged Averages struct, and the
pre-upgrade ts_key has fewer than CF_OBSERVABLES entries. dump.c now accepts a
record up to sizeof(Averages) (copied into a zeroed struct) and
GetObservableNames() fills any missing names with a spare[] fallback instead
of leaving the array partly uninitialized, so `cf-check dump` does not crash on
pre-upgrade state in the brief window before cf-monitord rewrites it.

Ticket: ENT-6511
Changelog: Increased the maximum number of cf-monitord measurement slots (CF_OBSERVABLES) from 100 to 300
@nickanderson

Copy link
Copy Markdown
Owner Author

Superseded by the upstream PR against cfengine/core: cfengine#6239

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants