Skip to content

cre-4958: manual shard assignments - #23348

Open
mchain0 wants to merge 18 commits into
developfrom
cre-4958
Open

cre-4958: manual shard assignments#23348
mchain0 wants to merge 18 commits into
developfrom
cre-4958

Conversation

@mchain0

@mchain0 mchain0 commented Aug 6, 2026

Copy link
Copy Markdown
Contributor

Enables manual shard assignments owner->shard.

Scope:

  • Config layer — ShardAssignmentMode field added to [Sharding] TOML config with 3 mode constants (ringocr-only, manual-only, ringocr-with-overrides). Validation updated to skip ShardOrchestratorAddress requirement for manual-only.
  • CRESettings job spec — config_type key inside the existing settings TOML column branches between regular settings and shard assignment. No DB migration needed. validate.go parses and validates accordingly. delegate.go routes to a dedicated AtomicSettings instance for shard assignment, reusing the existing Store() pattern.
  • ShardResolver (shardownership/resolver.go) — New interface with 3 implementations:
    • ringOCRShardResolver — wraps ShardOrchestrator client (existing behavior)
    • manualShardResolver — loads shard assignment TOML from AtomicSettings, parses it, O(1) owner→shard map lookup, no external deps
    • overrideShardResolver — manual wins for static owners, delegates to RingOCR for hashed owners
  • Wiring — cre.go creates the resolver based on mode. workflow_registry.go's filterWorkflowsByShard uses the resolver with owner hex from WorkflowMetadataView.Owner. Engine execution guard uses the resolver with EngineConfig.WorkflowOwner. application.go skips ShardOrchestrator infrastructure in manual-only mode.
  • Deployment — ShardAssignmentJob type prepends config_type = "shard_assignment" to the settings TOML, reuses the existing cre-settings.tmpl template. ProposeShardAssignmentJob operation added.

Tests:

  • Unit tests for config parsing, owner normalization, all 3 resolvers
  • E2E test files for manual-only and ringocr-with-overrides modes
  • Test config TOMLs for both new modes

cre-4958

@github-actions

github-actions Bot commented Aug 6, 2026

Copy link
Copy Markdown
Contributor

✅ No conflicts with other open PRs targeting develop

@github-actions

github-actions Bot commented Aug 6, 2026

Copy link
Copy Markdown
Contributor

I see you updated files related to core. Please run make gocs in the root directory to add a changeset as well as in the text include at least one of the following tags:

  • #added For any new functionality added.
  • #breaking_change For any functionality that requires manual action for the node to boot.
  • #bugfix For bug fixes.
  • #changed For any change to the existing functionality.
  • #db_update For any feature that introduces updates to database schema.
  • #deprecation_notice For any upcoming deprecation functionality.
  • #internal For changesets that need to be excluded from the final changelog.
  • #nops For any feature that is NOP facing and needs to be in the official Release Notes for the release.
  • #removed For any functionality/config that is removed.
  • #updated For any functionality that is updated.
  • #wip For any change that is not ready yet and external communication about it should be held off till it is feature complete.

@trunk-io

trunk-io Bot commented Aug 6, 2026

Copy link
Copy Markdown

Static BadgeStatic BadgeStatic Badge

View Full Report ↗︎Docs

@mchain0
mchain0 requested a review from bolekk August 6, 2026 16:16

@bolekk bolekk 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.

LGTM overall!

Comment thread core/services/workflows/syncer/v2/file_workflow_source_test.go Outdated
Comment thread core/services/chainlink/application.go Outdated
Comment thread core/services/cresettings/delegate.go
Comment thread core/services/cresettings/delegate.go Outdated
Comment thread core/services/cresettings/delegate.go Outdated
}); err != nil {
return nil, fmt.Errorf("failed to update settings: %w", err)
spec := j.CRESettingsSpec
configType := spec.ConfigType

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.

cc @jmank88 are you OK with this extension? Soon we can also add the third type for offchain Capabilities Registry (FYI @vyzaldysanchez )

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

I've refactored this a bit after @pavel-raykov 's suggestion. pls have a look

Comment thread core/services/cresettings/delegate.go Outdated
Comment thread core/services/cresettings/shard_assignment_config.go
Comment thread core/services/workflows/shardownership/resolver.go
Comment thread core/store/migrate/migrations/0302_add_shard_assignment_to_cre_settings.sql Outdated

switch {
case e.cfg.ShardResolver != nil:
shardID, found, resolveErr := e.cfg.ShardResolver.ResolveShard(ctx, e.cfg.WorkflowID, e.cfg.WorkflowOwner)

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.

We need to include info on whether current shard is primary or backup for this workflow. Backup will still subscribe to triggers and collect trigger events but not execute by default (until a fallback condition is met).

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

sorry, just to clarify - if there were 10 shards, would it mean that all of them receive the trigger and only 1 executes?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

yes

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.

@mchain0 so where is the information on whether this shard is primary or backup? How does the engine know if it should subscribe to triggers but not execute?

Comment thread core/services/cresettings/delegate.go Outdated
@github-actions

github-actions Bot commented Aug 11, 2026

Copy link
Copy Markdown
Contributor

CORA - Pending Reviewers

All codeowners have approved! ✅

Legend: ✅ Approved | ❌ Changes Requested | 💬 Commented | 🚫 Dismissed | ⏳ Pending | ❓ Unknown

For more details, see the full review summary.

@cl-sonarqube-production

Copy link
Copy Markdown

@mchain0
mchain0 marked this pull request as ready for review August 11, 2026 12:53
@mchain0
mchain0 requested review from a team as code owners August 11, 2026 12:53
ShardOrchestratorAddress = '' # Default
# ShardAssignmentMode controls how workflows are assigned to shards.
# One of: "ringocr-only" (default), "manual-only", "ringocr-with-overrides".
ShardAssignmentMode = 'ringocr-only' # Default

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.

This shouldn't be the default.

Comment thread core/services/cresettings/shard_assignment_config.go

switch {
case e.cfg.ShardResolver != nil:
shardID, found, resolveErr := e.cfg.ShardResolver.ResolveShard(ctx, e.cfg.WorkflowID, e.cfg.WorkflowOwner)

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.

@mchain0 so where is the information on whether this shard is primary or backup? How does the engine know if it should subscribe to triggers but not execute?

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

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants