Skip to content

Commit f38cd84

Browse files
authored
Enabled to configure the interval of livestate store for Lambda (#5269)
* add liveStateInterval for Lambda Signed-off-by: t-kikuc <[email protected]> * add docs of liveStateInterval Signed-off-by: t-kikuc <[email protected]> * fix a test Signed-off-by: t-kikuc <[email protected]> * Rename to 'awsAPIPollingInterval' Signed-off-by: t-kikuc <[email protected]> --------- Signed-off-by: t-kikuc <[email protected]>
1 parent 4b2499e commit f38cd84

File tree

4 files changed

+10
-2
lines changed

4 files changed

+10
-2
lines changed

docs/content/en/docs-dev/user-guide/managing-piped/configuration-reference.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -130,6 +130,7 @@ Must be one of the following structs:
130130
| roleARN | string | The IAM role arn to use when assuming an role. Required if you want to use the AWS SecurityTokenService. | No |
131131
| tokenFile | string | The path to the WebIdentity token the SDK should use to assume a role with. Required if you want to use the AWS SecurityTokenService. | No |
132132
| profile | string | The profile to use for logging into AWS cluster. The default value is `default`. | No |
133+
| awsAPIPollingInterval | duration | The interval of periodical calls of AWS APIs. Currently, this is an interval of refreshing the live state of Lambda functions. Default is 15s. | No |
133134

134135
### PlatformProviderECSConfig
135136

pkg/app/piped/livestatestore/lambda/lambda.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -58,7 +58,7 @@ func NewStore(cfg *config.PlatformProviderLambdaConfig, platformProvider string,
5858
client: client,
5959
logger: logger.Named("store"),
6060
},
61-
interval: 15 * time.Second,
61+
interval: time.Duration(cfg.AwsAPIPollingInterval),
6262
logger: logger,
6363
firstSyncedCh: make(chan error, 1),
6464
}

pkg/config/piped.go

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -712,6 +712,12 @@ type PlatformProviderLambdaConfig struct {
712712
// If empty, the environment variable "AWS_PROFILE" is used.
713713
// "default" is populated if the environment variable is also not set.
714714
Profile string `json:"profile,omitempty"`
715+
// The interval of periodical calls of AWS APIs.
716+
// Currently this is used for live state of Lambda functions,
717+
// but in the future, this might also be used for other polling features.
718+
// Default is 15s.
719+
// To reduce AWS API calls, this interval should be larger.
720+
AwsAPIPollingInterval Duration `json:"awsAPIPollingInterval,omitempty" default:"15s"`
715721
}
716722

717723
func (c *PlatformProviderLambdaConfig) Mask() {

pkg/config/piped_test.go

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -146,7 +146,8 @@ func TestPipedConfig(t *testing.T) {
146146
Name: "lambda",
147147
Type: model.PlatformProviderLambda,
148148
LambdaConfig: &PlatformProviderLambdaConfig{
149-
Region: "us-east-1",
149+
Region: "us-east-1",
150+
AwsAPIPollingInterval: Duration(15 * time.Second),
150151
},
151152
},
152153
},

0 commit comments

Comments
 (0)