Skip to content

fix: Announce agent migrations after the settings commit - #4759

Open
maciaszczykm wants to merge 2 commits into
masterfrom
marcin/agent-migration-after-commit
Open

maciaszczykm wants to merge 2 commits into
masterfrom
marcin/agent-migration-after-commit

Conversation

@maciaszczykm

Copy link
Copy Markdown
Member

Settings.update/2 creates the agent migration inside its transaction, and create_agent_migration/2 broadcasts AgentMigrationCreated straight away. The recursive handler then runs apply_migration/1 in another process, which reads the settings with fetch_consistent/0 before the transaction commits. When the values and agent_helm_values_templateable change together, as they do the first time agentHelmValuesTemplate is set, it sees the old flag, skips templating, and writes the raw Liquid template to every agent service. The operator then fails with "yaml: found character that cannot start any token" and stops syncing.

Migrations are now inserted inside the transaction and announced after it commits, in both update/2 and migrate_agents/2. create_agent_migration/2 keeps its behaviour for the GraphQL mutation.

Test Plan

Tests in settings_test.exs check that the migration is announced outside the transaction, with the new settings visible, for both settings updates and agent version bumps, and that a failed update announces nothing.

Found on a fresh plural up on Azure.

@maciaszczykm maciaszczykm added the bug-fix This pull request fixes a bug label Nov 30, 2026
@greptile-apps

greptile-apps Bot commented Nov 30, 2026 •

Copy link
Copy Markdown
Contributor

Confidence Score: 5/5 · The PR appears safe to merge.RetriggerView in GreptileConfidence Score: 5/5

[Medium impact] The PR appears safe to merge.

Summary

The PR inserts agent migrations inside the settings transaction and announces them after it finishes.

  • Agent migrations start after settings and version changes commit.

No actionable issues found. Tests were reviewed but not run.

Reviews (1) · Last reviewed commit: "announce agent migrations after the sett..." · Reviewed by Greptile

Comment thread lib/console/deployments/settings.ex Outdated
end

# announces a migration only after its transaction commits, so applying it sees the committed settings
defp notify_migration({:ok, %{migration: %AgentMigration{} = migration} = result}, key, user) do

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.

this priv function is kind of overcall, just do the same logic in a case at the end of the calling function instead. Also don't know if we really need the notify_agent_migration function, can just do the bare notify inline too.

This branch has not been deployed

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

Labels

bug-fix This pull request fixes a bug

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants