Skip to content

ENT-13295: Added evaluation order option in body agent control#5914

Merged
olehermanse merged 1 commit into
cfengine:masterfrom
victormlg:agent_control_topdown
Nov 3, 2025
Merged

ENT-13295: Added evaluation order option in body agent control#5914
olehermanse merged 1 commit into
cfengine:masterfrom
victormlg:agent_control_topdown

Conversation

@victormlg

@victormlg victormlg commented Oct 27, 2025

Copy link
Copy Markdown
Contributor

You can now override the body common control's evaluation_order option for agents.

body common control
{
  evaluation_order => "classic";
}
body agent control
{
  evaluation_order => "top_down"; #override
}
bundle agent main
{
  reports:
    "Hello world!";
}

I removed this because it doesn't look like it does much.

if (CommonControlFromString(cp->lval) != COMMON_CONTROL_MAX)
{
    /* Already handled in generic_agent */
    continue;
}

@victormlg victormlg requested a review from larsewi October 27, 2025 14:24

@nickanderson nickanderson left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

s/body agent/body file/g

;)

I am trolling here in case it's not obvious.

@olehermanse

Copy link
Copy Markdown
Member

s/body agent/body file/g

No, that's a separate ticket. This is just about making it work in both body common control and body agent control.

Comment thread cf-agent/cf-agent.c Outdated
@nickanderson

Copy link
Copy Markdown
Member

s/body agent/body file/g

No, that's a separate ticket. This is just about making it work in both body common control and body agent control.

🧌

@victormlg victormlg force-pushed the agent_control_topdown branch 3 times, most recently from 214e082 to 56a38a8 Compare October 28, 2025 10:39
Comment thread cf-agent/cf-agent.c Outdated
Comment thread libpromises/eval_context.c Outdated
Comment thread libpromises/eval_context.c Outdated
Comment thread libpromises/eval_context.c Outdated
Comment thread libpromises/mod_common.c Outdated
@victormlg victormlg force-pushed the agent_control_topdown branch 2 times, most recently from 6a07fd5 to d91be73 Compare October 28, 2025 13:07
@nickanderson

Copy link
Copy Markdown
Member

You can now override the body common control's evaluation_order option for agents using agent_evaluation_order.

Great ...

I had to use a different name because by default in the C code, it skips the options that have the same name in common control: > > > if (CommonControlFromString(cp->lval) != COMMON_CONTROL_MAX) > { > _* Already handled in generic_agent *_ > continue; > } >

This is I think worth looking at more closely. I have not filed a ticket that I recall, but it has indeed annoyed me when we have identical config options that override that are not named the same. I don't recall specific attributes that re this way, but i think that this:

body common control
{
      # This applies to all components, unless the component has a more specific setting
      evaluation_order => "classic"; # I think this should also support "normal" but it's just a nitpick
}

body agent control
{
      # cf-agent only, will process policy top-down, other componetns (cf-serverd, cf-execd, cf-monitord, cf-hub) will follow common control or their own control setting.
      evaluation_order => "top_down";
 }

Looks nicer than:

body common control
{
      # This applies to all components, unless the component has a more specific setting
      evaluation_order => "classic"; # I think this should also support "normal" but it's just a nitpick
}

body agent control
{
      # cf-agent only, will process policy top-down, other componetns (cf-serverd, cf-execd, cf-monitord, cf-hub) will follow common control or their own control setting.
      agent_evaluation_order => "top_down";
 }

I'd almost rather prefer this if we must not use the same attribute names:

body common control
{
      # This applies to all components, unless the component has a more specific setting
      common_evaluation_order => "classic"; # I think this should also support "normal" but it's just a nitpick
}

body agent control
{
      # cf-agent only, will process policy top-down, other componetns (cf-serverd, cf-execd, cf-monitord, cf-hub) will follow common control or their own control setting.
      agent_evaluation_order => "top_down";
 }

@victormlg

Copy link
Copy Markdown
Contributor Author

I updated the PR description

@nickanderson nickanderson left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

I won't judge the C code, but 👍 on the CFEngine syntax.

Comment thread libpromises/eval_context.h Outdated
Comment thread libpromises/expand.c Outdated
Comment thread libpromises/mod_common.c Outdated
Comment thread libpromises/mod_common.c Outdated
Comment thread libpromises/eval_context.c Outdated
Comment thread libpromises/eval_context.c Outdated
Comment thread libpromises/eval_context.c Outdated
Comment thread libpromises/eval_context.c Outdated
Comment thread libpromises/eval_context.c Outdated
Comment thread cf-agent/cf-agent.c Outdated
@victormlg victormlg force-pushed the agent_control_topdown branch from cfb425e to 5c151ca Compare November 3, 2025 08:54
@victormlg victormlg requested a review from olehermanse November 3, 2025 10:04
Comment thread cf-agent/cf-agent.c
Comment thread cf-agent/cf-agent.c Outdated
Changelog: Title
Ticket: ENT-13295
Signed-off-by: Victor Moene <victor.moene@northern.tech>
@victormlg victormlg force-pushed the agent_control_topdown branch from 5c151ca to 4abbe20 Compare November 3, 2025 15:09
@victormlg victormlg requested a review from larsewi November 3, 2025 15:55
@olehermanse

olehermanse commented Nov 3, 2025

Copy link
Copy Markdown
Member

@cf-bottom jenkins, please :)

@cf-bottom

Copy link
Copy Markdown

@olehermanse olehermanse merged commit e97977d into cfengine:master Nov 3, 2025
47 of 49 checks passed
}

// The fallback is to use what is defined in body common control,
// or if not defined there either, default to true (normal order)

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.

Suggested change
// or if not defined there either, default to true (normal order)
// or if not defined there either, default to true (classic order)

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.

5 participants