Skip to content

Commit

Permalink
Enabled to configure the interval of livestate store for Lambda (#5269)
Browse files Browse the repository at this point in the history
* add liveStateInterval for Lambda

Signed-off-by: t-kikuc <tkikuchi07f@gmail.com>

* add docs of liveStateInterval

Signed-off-by: t-kikuc <tkikuchi07f@gmail.com>

* fix a test

Signed-off-by: t-kikuc <tkikuchi07f@gmail.com>

* Rename to 'awsAPIPollingInterval'

Signed-off-by: t-kikuc <tkikuchi07f@gmail.com>

---------

Signed-off-by: t-kikuc <tkikuchi07f@gmail.com>
Signed-off-by: pipecd-bot <pipecd.dev@gmail.com>
  • Loading branch information
t-kikuc authored and pipecd-bot committed Oct 9, 2024
1 parent c3361ab commit 086f001
Show file tree
Hide file tree
Showing 4 changed files with 10 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -130,6 +130,7 @@ Must be one of the following structs:
| roleARN | string | The IAM role arn to use when assuming an role. Required if you want to use the AWS SecurityTokenService. | No |
| 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 |
| profile | string | The profile to use for logging into AWS cluster. The default value is `default`. | No |
| 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 |

### PlatformProviderECSConfig

Expand Down
2 changes: 1 addition & 1 deletion pkg/app/piped/livestatestore/lambda/lambda.go
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,7 @@ func NewStore(cfg *config.PlatformProviderLambdaConfig, platformProvider string,
client: client,
logger: logger.Named("store"),
},
interval: 15 * time.Second,
interval: time.Duration(cfg.AwsAPIPollingInterval),
logger: logger,
firstSyncedCh: make(chan error, 1),
}
Expand Down
6 changes: 6 additions & 0 deletions pkg/config/piped.go
Original file line number Diff line number Diff line change
Expand Up @@ -712,6 +712,12 @@ type PlatformProviderLambdaConfig struct {
// If empty, the environment variable "AWS_PROFILE" is used.
// "default" is populated if the environment variable is also not set.
Profile string `json:"profile,omitempty"`
// The interval of periodical calls of AWS APIs.
// Currently this is used for live state of Lambda functions,
// but in the future, this might also be used for other polling features.
// Default is 15s.
// To reduce AWS API calls, this interval should be larger.
AwsAPIPollingInterval Duration `json:"awsAPIPollingInterval,omitempty" default:"15s"`
}

func (c *PlatformProviderLambdaConfig) Mask() {
Expand Down
3 changes: 2 additions & 1 deletion pkg/config/piped_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -146,7 +146,8 @@ func TestPipedConfig(t *testing.T) {
Name: "lambda",
Type: model.PlatformProviderLambda,
LambdaConfig: &PlatformProviderLambdaConfig{
Region: "us-east-1",
Region: "us-east-1",
AwsAPIPollingInterval: Duration(15 * time.Second),
},
},
},
Expand Down

0 comments on commit 086f001

Please sign in to comment.