Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[CAPPL-399] Syncer limits #16234

Merged
merged 18 commits into from
Feb 27, 2025
Merged

[CAPPL-399] Syncer limits #16234

merged 18 commits into from
Feb 27, 2025

Conversation

agparadiso
Copy link
Contributor

@agparadiso agparadiso commented Feb 5, 2025

Description

This pr adds the following limits:

  • number of engines the syncer can host (global count limit)
  • number of workflows an owner can create (per owner limit)

CAPPL-399

Requires

Supports

Copy link
Contributor

github-actions bot commented Feb 5, 2025

AER Report: CI Core ran successfully ✅

aer_workflow , commit

AER Report: Operator UI CI ran successfully ✅

aer_workflow , commit

@agparadiso agparadiso force-pushed the CAPPL-399_syncer_limits branch 3 times, most recently from c22722f to 10ba0d2 Compare February 7, 2025 17:57
NetworkID *string
ChainID *string
GlobalEngineCountLimit *int32
WorkflowsPerOwnerLimit *int32
Copy link
Contributor

Choose a reason for hiding this comment

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

Can we put these two fields in a new top-level field called Workflows? I think putting it in ExternalRegistry isn't quite right (that refers to the CapabilitiesRegistry btw, not the WorklfowRegistry)

@@ -291,6 +292,14 @@ func NewApplication(opts ApplicationOpts) (Application, error) {
return nil, fmt.Errorf("could not instantiate workflow rate limiter: %w", err)
}

workflowSyncerLimiter, err := syncerlimiter.NewWorkflowSyncerLimiter(syncerlimiter.Config{
Copy link
Contributor

Choose a reason for hiding this comment

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

Just workflowLimiter, rather than workflowSyncerLimiter, it should apply to all workflows, not just those belonging to the workflowSyncer

@@ -1339,6 +1353,15 @@ func NewEngine(ctx context.Context, cfg Config) (engine *Engine, err error) {
// - that the resulting graph is strongly connected (i.e. no disjointed subgraphs exist)
// - etc.

// validate if adding another engine would exceed either the global or per owner count limit
ownerAllow, globalAllow := cfg.WorkflowSyncerLimiter.Allow(cfg.WorkflowOwner)
Copy link
Contributor

Choose a reason for hiding this comment

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

Can we put this in Start() instead so it's symmetric with Close :) ?

@agparadiso agparadiso force-pushed the CAPPL-399_syncer_limits branch from 10ba0d2 to 88e3844 Compare February 10, 2025 11:02
@agparadiso agparadiso force-pushed the CAPPL-399_syncer_limits branch 4 times, most recently from 7da41ca to 3544aea Compare February 10, 2025 17:11
@agparadiso agparadiso force-pushed the CAPPL-399_syncer_limits branch from 3544aea to 2b8f98c Compare February 10, 2025 20:40
@agparadiso agparadiso marked this pull request as ready for review February 11, 2025 09:57
@agparadiso agparadiso requested review from a team as code owners February 11, 2025 09:57
Comment on lines 473 to 475
[Capabilities.WorkflowRegistry.Limits]
# WorkflowsGlobalLimit is the maximum number of workflows that can be registered globally.
WorkflowsGlobalLimit = 50 # Default
Copy link
Contributor

Choose a reason for hiding this comment

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

Do we need to say Limit twice? Or could we drop either the extra wrapper or the suffix?

@agparadiso agparadiso requested a review from jmank88 February 12, 2025 16:32
@@ -27,6 +27,8 @@ type CapabilitiesWorkflowRegistry interface {
MaxBinarySize() utils.FileSize
MaxConfigSize() utils.FileSize
RelayID() types.RelayID
WorkflowsGlobal() int32
WorkflowsPerOwner() int32
Copy link
Contributor

Choose a reason for hiding this comment

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

@agparadiso Is this correct? Looking at the docs there should be a struct beneath it called limits I think?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

true, this was working because underneath I was calling Limits:

func (c *capabilitiesWorkflowRegistry) WorkflowsGlobal() int32 {
	return *c.c.Limits.WorkflowsGlobal
}

func (c *capabilitiesWorkflowRegistry) WorkflowsPerOwner() int32 {
	return *c.c.Limits.WorkflowsPerOwner
}

will modify it, thanks!

@@ -470,6 +470,12 @@ MaxEncryptedSecretsSize = '26.40kb' # Default
# MaxConfigSize is the maximum size of a config that can be fetched from the given config url.
MaxConfigSize = '50.00kb' # Default

[Capabilities.WorkflowRegistry.Limits]
Copy link
Contributor

Choose a reason for hiding this comment

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

I still think we should move this to something that doesn't imply it's a limit that only applies to the WorkflowRegistry

eg. [Workflows.Limits]

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Addressed 👍🏼

@agparadiso agparadiso force-pushed the CAPPL-399_syncer_limits branch from 3353bab to c5e8a20 Compare February 17, 2025 12:34
# Global is the maximum number of workflows that can be registered globally.
Global = 50 # Default
# PerOwner is the maximum number of workflows that can be registered per owner.
PerOwner = 5 # Default
Copy link
Contributor

Choose a reason for hiding this comment

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

@agparadiso Can we set this to 200 Global and 200 PerOwner by default? This will be what we need for ST3

// validate if adding another workflow would exceed either the global or per owner engine count limit
ownerAllow, globalAllow := e.workflowLimits.Allow(e.workflow.owner)
if !globalAllow {
e.metrics.with(platform.KeyWorkflowID, e.workflow.id, platform.KeyWorkflowOwner, e.workflow.owner).incrementWorkflowLimitGlobalCounter(ctx)
Copy link
Contributor

Choose a reason for hiding this comment

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

We also should log a message via Beholder here and below on line 166

@agparadiso agparadiso force-pushed the CAPPL-399_syncer_limits branch from 4e954bb to 2cdcf9c Compare February 26, 2025 17:32
Copy link
Contributor

Flakeguard Summary

Ran new or updated tests between develop and 4e954bb (CAPPL-399_syncer_limits).

View Flaky Detector Details | Compare Changes

Found Flaky Tests ❌

1 Results
Name Pass Ratio Panicked? Timed Out? Race? Runs Successes Failures Skips Package Package Panicked? Avg Duration Code Owners
TestWorkflowsConfig 0% false false false 3 0 3 0 github.com/smartcontractkit/chainlink/v2/core/services/chainlink false 10ms Unknown

Artifacts

For detailed logs of the failed tests, please refer to the artifact failed-test-results-with-logs.json.

@cedric-cordenier cedric-cordenier added this pull request to the merge queue Feb 27, 2025
Merged via the queue into develop with commit f50d567 Feb 27, 2025
182 of 184 checks passed
@cedric-cordenier cedric-cordenier deleted the CAPPL-399_syncer_limits branch February 27, 2025 15:43
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