Skip to content

ENT-14692: Added modular interface for event types - #6403

Open
victormlg wants to merge 6 commits into
cfengine:masterfrom
victormlg:cf-reactor.AllFileEventTypes
Open

victormlg wants to merge 6 commits into
cfengine:masterfrom
victormlg:cf-reactor.AllFileEventTypes

Conversation

@victormlg

@victormlg victormlg commented Oct 13, 2026 •

Copy link
Copy Markdown
Contributor

All event types are mutually exclusive:

# this is valid

body when file_deleted(file)
{
  file_deleted => "$(file)";
}

# this is not:

body when file_deleted(file)
{
  file_deleted => "$(file)";
  file_modified => "$(file)";
}

new interval attribute

body when file_deleted(file)
{
  file_deleted => "$(file)";
  interval => 30; # waits 30 seconds between polls
}

event types that need several values, expect a set of attributes

body when file_exceeds_1GB(file)
{
  file_size_exceeds => "$(file)";
  size_threshold => "1G";
}

Comment thread libpromises/promises.c Fixed
Comment thread libpromises/promises.c Fixed
Comment thread libpromises/syntax.c Fixed
Comment thread libpromises/syntax.c Fixed
Comment thread libpromises/syntax.c Fixed
@victormlg
victormlg force-pushed the cf-reactor.AllFileEventTypes branch 2 times, most recently from a417845 to 3f5cbb2 Compare October 14, 2026 14:49
@victormlg
victormlg marked this pull request as ready for review October 14, 2026 14:49
@victormlg victormlg changed the title ENT-14692: All file event types ENT-14692: Added modular interface for event types Oct 14, 2026
Comment thread cf-reactor/watcher.c Fixed
Comment thread cf-reactor/watcher.c Fixed
Comment thread cf-reactor/watcher.c Fixed
Comment thread cf-reactor/watcher.c Fixed
Comment thread cf-reactor/watcher.c Fixed
Comment thread cf-reactor/watcher.c Fixed
Comment thread cf-reactor/watcher.c Fixed
Comment thread cf-reactor/watcher.c Fixed
@victormlg
victormlg force-pushed the cf-reactor.AllFileEventTypes branch from 3f5cbb2 to 036767c Compare October 15, 2026 07:28

@larsewi larsewi left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The first commit mixes refactors, API changes, behavior changes and a new interval attribute. Please split it into one commit per change.

Comment thread cf-reactor/file_watcher.c
@victormlg
victormlg force-pushed the cf-reactor.AllFileEventTypes branch from 036767c to 869e4b3 Compare October 15, 2026 09:27
@victormlg
victormlg requested a review from larsewi October 15, 2026 10:33

@larsewi larsewi left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Some nits

Comment thread cf-reactor/file_watcher.c Outdated
Comment thread cf-reactor/file_watcher.c Outdated
Comment thread cf-reactor/watcher.c Outdated
Comment thread cf-reactor/watcher.c Outdated
Comment thread cf-reactor/watcher.c Outdated
Comment thread libpromises/mod_reactor.c Outdated
Comment thread cf-reactor/reactor_transform.c Outdated
Comment thread cf-reactor/reactor_transform.c Outdated
Comment thread cf-reactor/reactor_transform.c Outdated
Comment thread cf-reactor/reactor_transform.c
victormlg and others added 6 commits October 16, 2026 13:56
Ticket: ENT-14692
Signed-off-by: Victor Moene <victor.moene@northern.tech>
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
The reference check of a new watcher is now done by WatcherRegister(),
without holding the registry lock as it may block. If it fails, the
watcher is not registered and WatcherRegister() returns false, so that
the events promise fails.

Ticket: ENT-14692
Signed-off-by: Victor Moene <victor.moene@northern.tech>
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
WatcherRegister() now takes a pointer to the options, which include
the interval between two checks.

Ticket: ENT-14692
Signed-off-by: Victor Moene <victor.moene@northern.tech>
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Ticket: ENT-14692
Signed-off-by: Victor Moene <victor.moene@northern.tech>
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
It sets the seconds between two checks for the event, 1 by default.
The parser only checks it if it doesn't depend on variables or body
arguments, so it is checked again once expanded, and the events promise
fails if it is invalid.

Ticket: ENT-14692
Signed-off-by: Victor Moene <victor.moene@northern.tech>
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Moved from a hardcoded and single `file_deleted` event type, to
a table with all the event types and their necessary code, so
that cf-reactor can easily be extended with new event types.

Ticket: ENT-14692
Signed-off-by: Victor Moene <victor.moene@northern.tech>
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@victormlg
victormlg force-pushed the cf-reactor.AllFileEventTypes branch from 869e4b3 to 9c324e1 Compare October 16, 2026 12:37
@victormlg

Copy link
Copy Markdown
Contributor Author

@cf-bottom jenkins, please :)

@cf-bottom

Copy link
Copy Markdown

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

Labels

None yet

Development

Successfully merging this pull request may close these issues.

4 participants