-
Notifications
You must be signed in to change notification settings - Fork 222
update: support to wait to update function #4565
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
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change | ||||||
|---|---|---|---|---|---|---|---|---|
|
|
@@ -227,6 +227,11 @@ func (c *client) UpdateFunction(ctx context.Context, fm FunctionManifest) error | |||||||
| } | ||||||||
|
|
||||||||
| func (c *client) UpdateFunctionFromSource(ctx context.Context, fm FunctionManifest, zip io.Reader) error { | ||||||||
| // Update function configuration. | ||||||||
| if err := c.updateFunctionConfiguration(ctx, fm); err != nil { | ||||||||
| return err | ||||||||
| } | ||||||||
|
|
||||||||
| data, err := io.ReadAll(zip) | ||||||||
| if err != nil { | ||||||||
| return err | ||||||||
|
|
@@ -249,11 +254,6 @@ func (c *client) UpdateFunctionFromSource(ctx context.Context, fm FunctionManife | |||||||
| return fmt.Errorf("failed to update function code for Lambda function %s: %w", fm.Spec.Name, err) | ||||||||
| } | ||||||||
|
|
||||||||
| // Update function configuration. | ||||||||
| if err = c.updateFunctionConfiguration(ctx, fm); err != nil { | ||||||||
| return err | ||||||||
| } | ||||||||
|
|
||||||||
| // Tag/Untag function if necessary. | ||||||||
| return c.updateTagsConfig(ctx, fm) | ||||||||
| } | ||||||||
|
|
@@ -295,7 +295,24 @@ func (c *client) updateFunctionConfiguration(ctx context.Context, fm FunctionMan | |||||||
| if !updateFunctionConfigurationSucceed { | ||||||||
| return fmt.Errorf("failed to update configuration for Lambda function %s: %w", fm.Spec.Name, err) | ||||||||
| } | ||||||||
| return nil | ||||||||
|
|
||||||||
| // Wait until function updated successfully. | ||||||||
| retry = backoff.NewRetry(RequestRetryTime, backoff.NewConstant(RetryIntervalDuration)) | ||||||||
| input := &lambda.GetFunctionInput{ | ||||||||
| FunctionName: aws.String(fm.Spec.Name), | ||||||||
| } | ||||||||
| _, err = retry.Do(ctx, func() (any, error) { | ||||||||
|
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Sorry, I just noticed that we reused the previous retry object here. I think we should recreate a new one instead since the same object may contain previously updated backoff internal, thus the number of retry times is not as expected.
Suggested change
Member
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. @khanhtc1202 |
||||||||
| output, err := c.client.GetFunction(ctx, input) | ||||||||
| if err != nil { | ||||||||
| return nil, err | ||||||||
| } | ||||||||
| if output.Configuration.LastUpdateStatus != types.LastUpdateStatusSuccessful { | ||||||||
| return nil, fmt.Errorf("failed to update Lambda function %s, status code %v, error reason %s", | ||||||||
| fm.Spec.Name, output.Configuration.LastUpdateStatus, *output.Configuration.LastUpdateStatusReason) | ||||||||
| } | ||||||||
| return nil, nil | ||||||||
| }) | ||||||||
| return err | ||||||||
| } | ||||||||
|
|
||||||||
| func (c *client) PublishFunction(ctx context.Context, fm FunctionManifest) (string, error) { | ||||||||
|
|
||||||||
Uh oh!
There was an error while loading. Please reload this page.