From 5dd51d6fb01d2cd5c880b9594bf0dd44f7753258 Mon Sep 17 00:00:00 2001 From: Gabriel Paradiso Date: Mon, 10 Feb 2025 15:52:31 +0100 Subject: [PATCH] feat: group workflow limits on a top-level field --- core/config/docs/core.toml | 2 ++ core/config/toml/types.go | 26 ++++++++++++------- .../services/chainlink/config_capabilities.go | 4 +-- core/services/chainlink/config_test.go | 6 +++-- .../testdata/config-empty-effective.toml | 2 ++ .../chainlink/testdata/config-full.toml | 2 ++ .../config-multi-chain-effective.toml | 2 ++ docs/CONFIG.md | 10 +++++-- 8 files changed, 39 insertions(+), 15 deletions(-) diff --git a/core/config/docs/core.toml b/core/config/docs/core.toml index cac36a3bfb1..f2b46d784c8 100644 --- a/core/config/docs/core.toml +++ b/core/config/docs/core.toml @@ -469,6 +469,8 @@ MaxBinarySize = '20.00mb' # Default 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] # WorkflowsGlobalLimit is the maximum number of workflows that can be registered globally. WorkflowsGlobalLimit = 50 # Default # WorkflowsPerOwnerLimit is the maximum number of workflows that can be registered per owner. diff --git a/core/config/toml/types.go b/core/config/toml/types.go index 206a2c5b9d0..d879e34e296 100644 --- a/core/config/toml/types.go +++ b/core/config/toml/types.go @@ -1487,6 +1487,21 @@ func (r *ExternalRegistry) setFrom(f *ExternalRegistry) { } } +type WorkflowLimits struct { + WorkflowsGlobalLimit *int32 + WorkflowsPerOwnerLimit *int32 +} + +func (r *WorkflowLimits) setFrom(f *WorkflowLimits) { + if f.WorkflowsGlobalLimit != nil { + r.WorkflowsGlobalLimit = f.WorkflowsGlobalLimit + } + + if f.WorkflowsPerOwnerLimit != nil { + r.WorkflowsPerOwnerLimit = f.WorkflowsPerOwnerLimit + } +} + type WorkflowRegistry struct { Address *string NetworkID *string @@ -1494,8 +1509,7 @@ type WorkflowRegistry struct { MaxBinarySize *utils.FileSize MaxEncryptedSecretsSize *utils.FileSize MaxConfigSize *utils.FileSize - WorkflowsGlobalLimit *int32 - WorkflowsPerOwnerLimit *int32 + Limits WorkflowLimits } func (r *WorkflowRegistry) setFrom(f *WorkflowRegistry) { @@ -1523,13 +1537,7 @@ func (r *WorkflowRegistry) setFrom(f *WorkflowRegistry) { r.MaxConfigSize = f.MaxConfigSize } - if f.WorkflowsGlobalLimit != nil { - r.WorkflowsGlobalLimit = f.WorkflowsGlobalLimit - } - - if f.WorkflowsPerOwnerLimit != nil { - r.WorkflowsPerOwnerLimit = f.WorkflowsPerOwnerLimit - } + r.Limits.setFrom(&f.Limits) } type Dispatcher struct { diff --git a/core/services/chainlink/config_capabilities.go b/core/services/chainlink/config_capabilities.go index d857172d1cc..99ee8e4246e 100644 --- a/core/services/chainlink/config_capabilities.go +++ b/core/services/chainlink/config_capabilities.go @@ -154,11 +154,11 @@ func (c *capabilitiesWorkflowRegistry) MaxConfigSize() utils.FileSize { } func (c *capabilitiesWorkflowRegistry) WorkflowsGlobalLimit() int32 { - return *c.c.WorkflowsGlobalLimit + return *c.c.Limits.WorkflowsGlobalLimit } func (c *capabilitiesWorkflowRegistry) WorkflowsPerOwnerLimit() int32 { - return *c.c.WorkflowsPerOwnerLimit + return *c.c.Limits.WorkflowsPerOwnerLimit } type gatewayConnector struct { diff --git a/core/services/chainlink/config_test.go b/core/services/chainlink/config_test.go index 457b67ce444..dea71dcbf8d 100644 --- a/core/services/chainlink/config_test.go +++ b/core/services/chainlink/config_test.go @@ -478,8 +478,10 @@ func TestConfig_Marshal(t *testing.T) { MaxBinarySize: ptr(utils.FileSize(20 * utils.MB)), MaxEncryptedSecretsSize: ptr(utils.FileSize(26.4 * utils.KB)), MaxConfigSize: ptr(utils.FileSize(50 * utils.KB)), - WorkflowsGlobalLimit: ptr(int32(50)), - WorkflowsPerOwnerLimit: ptr(int32(5)), + Limits: toml.WorkflowLimits{ + WorkflowsGlobalLimit: ptr(int32(50)), + WorkflowsPerOwnerLimit: ptr(int32(5)), + }, }, Dispatcher: toml.Dispatcher{ SupportedVersion: ptr(1), diff --git a/core/services/chainlink/testdata/config-empty-effective.toml b/core/services/chainlink/testdata/config-empty-effective.toml index 4cb5e068c2c..f9fb54a7548 100644 --- a/core/services/chainlink/testdata/config-empty-effective.toml +++ b/core/services/chainlink/testdata/config-empty-effective.toml @@ -286,6 +286,8 @@ ChainID = '1' MaxBinarySize = '20.00mb' MaxEncryptedSecretsSize = '26.40kb' MaxConfigSize = '50.00kb' + +[Capabilities.WorkflowRegistry.Limits] WorkflowsGlobalLimit = 50 WorkflowsPerOwnerLimit = 5 diff --git a/core/services/chainlink/testdata/config-full.toml b/core/services/chainlink/testdata/config-full.toml index b724caa3941..28d551b725c 100644 --- a/core/services/chainlink/testdata/config-full.toml +++ b/core/services/chainlink/testdata/config-full.toml @@ -296,6 +296,8 @@ ChainID = '1' MaxBinarySize = '20.00mb' MaxEncryptedSecretsSize = '26.40kb' MaxConfigSize = '50.00kb' + +[Capabilities.WorkflowRegistry.Limits] WorkflowsGlobalLimit = 50 WorkflowsPerOwnerLimit = 5 diff --git a/core/services/chainlink/testdata/config-multi-chain-effective.toml b/core/services/chainlink/testdata/config-multi-chain-effective.toml index a8ee74b6e0c..8afc6d12446 100644 --- a/core/services/chainlink/testdata/config-multi-chain-effective.toml +++ b/core/services/chainlink/testdata/config-multi-chain-effective.toml @@ -286,6 +286,8 @@ ChainID = '1' MaxBinarySize = '20.00mb' MaxEncryptedSecretsSize = '26.40kb' MaxConfigSize = '50.00kb' + +[Capabilities.WorkflowRegistry.Limits] WorkflowsGlobalLimit = 50 WorkflowsPerOwnerLimit = 5 diff --git a/docs/CONFIG.md b/docs/CONFIG.md index 15d3f1efe8d..a7dbc35cd18 100644 --- a/docs/CONFIG.md +++ b/docs/CONFIG.md @@ -1263,8 +1263,6 @@ ChainID = '1' # Default MaxBinarySize = '20.00mb' # Default MaxEncryptedSecretsSize = '26.40kb' # Default MaxConfigSize = '50.00kb' # Default -WorkflowsGlobalLimit = 50 # Default -WorkflowsPerOwnerLimit = 5 # Default ``` @@ -1304,6 +1302,14 @@ MaxConfigSize = '50.00kb' # Default ``` MaxConfigSize is the maximum size of a config that can be fetched from the given config url. +## Capabilities.WorkflowRegistry.Limits +```toml +[Capabilities.WorkflowRegistry.Limits] +WorkflowsGlobalLimit = 50 # Default +WorkflowsPerOwnerLimit = 5 # Default +``` + + ### WorkflowsGlobalLimit ```toml WorkflowsGlobalLimit = 50 # Default