mirror of
https://github.com/moghtech/komodo.git
synced 2026-07-16 01:59:56 -05:00
[PR #1492] feat: Allow resource syncs to self update #28684
Reference in New Issue
Block a user
Delete Branch "%!s()"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
📋 Pull Request Information
Original PR: https://github.com/moghtech/komodo/pull/1492
Author: @scolastico
Created: 6/23/2026
Status: 🔄 Open
Base:
main← Head:feat/allow-self-updating-syncs📝 Commits (1)
2123fc6feat: allow resource syncs to self update📊 Changes
8 files changed (+615 additions, -327 deletions)
View changed files
📝
bin/core/src/api/execute/sync.rs(+427 -323)📝
bin/core/src/resource/mod.rs(+26 -1)📝
bin/core/src/sync/execute.rs(+109 -3)📝
client/core/rs/src/entities/sync.rs(+11 -0)📝
client/core/ts/src/types.ts(+9 -0)📝
docsite/docs/automate/sync-resources.md(+19 -0)📝
ui/public/client/types.d.ts(+9 -0)📝
ui/src/resources/sync/config.tsx(+5 -0)📄 Description
Let resource syncs sync themselves
Fixes #676
What this does
A resource sync can declare itself among the resources it manages. Before
this change, running such a sync - when its own config had changed - always
failed with
ResourceSync busyand left the sync stuck inPendingwithno clear recovery path. The only workarounds were removing the sync's own
declaration from the TOML, or hand-editing the UI config to match git exactly.
This PR makes a sync able to apply changes to itself during its own run, adds
an opt-in to immediately re-run when a sync changes its own scope, and turns
the "a sync would delete itself" case into an explicit hard error instead of a
confusing busy failure.
Why it happened
When a sync runs, it takes its own action-state lock (
syncing = true) for theentire run. Applying the sync's own changes goes through
resource::update::<ResourceSync>, which starts with a busy check:Because the sync is the thing holding the lock, this check always trips for the
sync's own entry - so it could never converge.
How it works
1. Apply self-updates, bypassing the busy check
resource::updatewas split intoupdate(unchanged, busy-checked) and a newupdate_ignore_busy, sharing a privateupdate_inner(..., check_busy: bool).No other call sites change.
execute_self_sync_updatespulls the sync's own entry out of theResourceSyncdeltas and applies the config update directly viaupdate_ignore_busy. This is safe: it runs sequentially as part of thein-progress sync, not concurrently. (Tag/description/template meta updates
already worked, since
update_metahas no busy check.)2. Optional re-run when a sync changes its own scope (
rerun_on_self_change)A run reconciles against the config that was active when the run started. If a
sync changes its own config mid-run (e.g. a new
resource_path), that new scopeonly takes effect on the next run - the end-of-run
RefreshResourceSyncPendingcorrectly recomputes pending against the new config, so the sync simply shows
Pendingagain (it does not get falsely marked "in sync").New opt-in config field
rerun_on_self_change(defaultfalse): when the syncsuccessfully changed its own config during a pass, run one more pass immediately
to apply the new scope, instead of waiting for an external trigger.
To support this,
RunSync::resolvewas refactored so the per-pass reconciliationlives in
execute_sync_pass(...), driven by a small loop hard-capped atMAX_SYNC_PASSES = 2. The cap guarantees termination even if a sync's TOML neverquite diff-matches itself; if it's still
Pendingafter the second pass it staysPending.3. A sync can never delete itself (hard fail)
If
delete/managedmode is enabled and the running sync is not declared inits own resource files, it would otherwise be marked for deletion. This now
hard-fails the run up front - before any resource is mutated - with a clear
message, rather than silently skipping the deletion or failing as "busy":
Failing early (right after deltas are computed) avoids a half-applied sync.
Behavior summary
ResourceSync busy, stuckPendingrerun_on_self_changeoff (default)Pendingrerun_on_self_changeonResourceSync busyChanges
bin/core/src/resource/mod.rs- splitupdateintoupdate/update_ignore_busy/update_inner(check_busy).bin/core/src/sync/execute.rs-execute_self_sync_updates(applies thesync's own update, bypassing busy; returns whether config changed).
bin/core/src/api/execute/sync.rs- extractedexecute_sync_pass, added thecapped re-run loop and the early self-delete hard fail.
client/core/rs/src/entities/sync.rs- newrerun_on_self_changeconfigfield (default
false).client/core/ts/src/types.ts,ui/public/client/types.d.ts- generated TStype for the new field.
ui/src/resources/sync/config.tsx- "Re-run On Self Change" toggle.docsite/docs/automate/sync-resources.md- documents self-managing syncs, thenew option, and the self-delete hard fail.
Testing
cargo check -p komodo_coreand-p komodo_clientpass with no warnings.Screenshots
🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.