Skip to content

CFE-3866: Allowed select_region to converge across passes (3.27)#6076

Merged
nickanderson merged 6 commits intocfengine:3.27.xfrom
nickanderson:CFE-3866/3.27.x
Apr 17, 2026
Merged

CFE-3866: Allowed select_region to converge across passes (3.27)#6076
nickanderson merged 6 commits intocfengine:3.27.xfrom
nickanderson:CFE-3866/3.27.x

Conversation

@nickanderson
Copy link
Copy Markdown
Member

Enable select_region to find regions created by earlier promises during
multi-pass convergence. Previously, if a promise inserted a section header
in pass 1, promises using select_region for that section would fail with
INTERRUPTED, preventing convergence.

This allows policies like set_variable_values_ini() to work without the
workarounds currently required in masterfiles.

Ticket: CFE-3866

olehermanse and others added 6 commits April 17, 2026 10:36
Signed-off-by: Ole Herman Schumacher Elgesem <ole@northern.tech>
(cherry picked from commit 369df1a)
Signed-off-by: Ole Herman Schumacher Elgesem <ole@northern.tech>
(cherry picked from commit 9434229)
Signed-off-by: Ole Herman Schumacher Elgesem <ole@northern.tech>
(cherry picked from commit e6afbba)
Signed-off-by: Ole Herman Schumacher Elgesem <ole@northern.tech>
(cherry picked from commit 4c0a170)
This test validates that select_region can converge across multiple
edit_line passes when the region is created in an earlier pass.

The test creates a file with a [section] header in the first promise,
then uses select_region to insert content within that section in the
second promise. This demonstrates that select_region failures are
retried across multiple passes until they succeed.

Ticket: CFE-3866
Changelog: None
(cherry picked from commit 0565051)
Modified edit_line operations to allow select_region to succeed across
multiple convergence passes. Previously, if a promise inserted a section
header in pass 1, promises using select_region for that section would
fail with INTERRUPTED in the same run, preventing convergence.

Changes:
- Added EDIT_CONTEXT_IS_FINAL_PASS macro to files_edit.h for checking
  if we're on the final convergence pass
- Extracted HandleSelectRegionFailure() to centralize error handling
  for SelectRegion failures across VerifyLineDeletions, VerifyColumnEdits,
  VerifyPatterns, and VerifyLineInsertions
- On non-final passes: log verbose message and return NOOP to allow retry
- On final pass: report error with detailed context
- Log messages now show remaining passes (e.g., "pass 1/3, 2 more passes to try")

This eliminates the need for workarounds in set_variable_values_ini()
and similar functions that create sections and immediately edit them.

Ticket: CFE-3866
Changelog: Title
(cherry picked from commit 1a411a0)
@nickanderson nickanderson merged commit a4cce52 into cfengine:3.27.x Apr 17, 2026
8 checks passed
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.

2 participants