Skip to content

fix: check lambda Function latest status in sdkupdate #174

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

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
24 changes: 13 additions & 11 deletions pkg/resource/function/hooks.go
Original file line number Diff line number Diff line change
Expand Up @@ -69,36 +69,38 @@ func (rm *resourceManager) customUpdateFunction(
exit := rlog.Trace("rm.customUpdateFunction")
defer exit(err)

if isFunctionPending(desired) {
return nil, requeueWaitWhilePending
updatedStatusResource := rm.concreteResource(desired.DeepCopy())
updatedStatusResource.SetStatus(latest)
Comment on lines +72 to +73
Copy link

Choose a reason for hiding this comment

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

Q: Am I correct in assuming that the reason for this is to set the ensure that the new Function status is applied the resource? Doesn't the controller normally handle updating the status field until the synced:when condition is met?

Copy link
Member Author

Choose a reason for hiding this comment

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

Yes, it usually does if there is no error. But since below here we were returning a requeue error, the Synced one is ignored.

We should probably have a patch in runtime handling this..

if isFunctionPending(latest) {
return updatedStatusResource, requeueWaitWhilePending
}

if delta.DifferentAt("Spec.Tags") {
err = rm.updateFunctionTags(ctx, latest, desired)
if err != nil {
return nil, err
return updatedStatusResource, err
}
}
if delta.DifferentAt("Spec.ReservedConcurrentExecutions") {
err = rm.updateFunctionConcurrency(ctx, desired)
if err != nil {
return nil, err
return updatedStatusResource, err
}
}
if delta.DifferentAt("Spec.FunctionEventInvokeConfig") {
err = rm.syncFunctionEventInvokeConfig(ctx, desired)
if err != nil {
return nil, err
return updatedStatusResource, err
}
}
if delta.DifferentAt("Spec.CodeSigningConfigARN") {
if desired.ko.Spec.PackageType != nil && *desired.ko.Spec.PackageType == "Image" &&
desired.ko.Spec.CodeSigningConfigARN != nil && *desired.ko.Spec.CodeSigningConfigARN != "" {
return nil, ackerr.NewTerminalError(ErrCannotSetFunctionCSC)
return updatedStatusResource, ackerr.NewTerminalError(ErrCannotSetFunctionCSC)
} else {
err = rm.updateFunctionCodeSigningConfig(ctx, desired)
if err != nil {
return nil, err
return updatedStatusResource, err
}
}
}
Expand All @@ -112,9 +114,9 @@ func (rm *resourceManager) customUpdateFunction(
err = rm.updateFunctionCode(ctx, desired, delta, latest)
if err != nil {
if strings.Contains(err.Error(), "Provide a valid source image.") {
return nil, requeueWaitWhileSourceImageDoesNotExist
return updatedStatusResource, requeueWaitWhileSourceImageDoesNotExist
} else {
return nil, err
return updatedStatusResource, err
}
}
case delta.DifferentExcept(
Expand All @@ -125,13 +127,13 @@ func (rm *resourceManager) customUpdateFunction(
"Spec.CodeSigningConfigARN"):
err = rm.updateFunctionConfiguration(ctx, desired, delta)
if err != nil {
return nil, err
return updatedStatusResource, err
}
}

readOneLatest, err := rm.ReadOne(ctx, desired)
if err != nil {
return nil, err
return updatedStatusResource, err
}
return rm.concreteResource(readOneLatest), nil
}
Expand Down
3 changes: 2 additions & 1 deletion pkg/resource/function/sdk.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 2 additions & 2 deletions templates/hooks/function/sdk_read_one_post_set_output.go.tpl
Original file line number Diff line number Diff line change
Expand Up @@ -51,5 +51,5 @@
ko.Spec.Tags = expectedOutput
}
if err := rm.setResourceAdditionalFields(ctx, ko); err != nil {
return nil, err
}
return &resource{ko}, err
}