-
Notifications
You must be signed in to change notification settings - Fork 23
Adding support for Function version
#113
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
Adding support for Function version
#113
Conversation
Skipping CI for Draft Pull Request. |
06873ce
to
e6c9b38
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Since we already have a LayerVersion
resource, and to avoid UX confusions, should we name this resource FunctionVersion
instead?
It's a good call, but the resource is called just I don't know what would create more confusion really |
e6c9b38
to
bde333e
Compare
generator.yaml
Outdated
@@ -7,11 +7,28 @@ ignore: | |||
# FunctionUrlConfig | |||
# LayerVersion | |||
operations: | |||
PublishLayerVersion: | |||
PublishLayerVersion: #opID |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Is this comment needed or relevant? (can we remove it?)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
My mistake, have removed it now. Thanks!
if err != nil { | ||
return nil, err | ||
} | ||
bigList := list.Versions |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Maybe bigList
should be called something more specific, like versionsList
or previousVersions
(Or something that makes more sense, for when it's used in the sdk_create_pre_set_output.go.tpl
file)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Makes sense, I went with versionList
. We're getting list of Versions for LayerVersion
resource and assigned it to variable named versionList
only, made sense to use the same naming for this case too. Let me know if we should keep the naming different.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Ty @Vandita2020 - left two comments inline.
pkg/resource/version/sdk.go
Outdated
res := &svcsdk.ListVersionsByFunctionInput{} | ||
res.FunctionName = desired.ko.Spec.FunctionName | ||
var list *svcsdk.ListVersionsByFunctionOutput | ||
list, err = rm.sdkapi.ListVersionsByFunctionWithContext(ctx, res) | ||
if err != nil { | ||
return nil, err | ||
} | ||
versionList := list.Versions | ||
|
||
for ok := list.NextMarker != nil; ok; ok = (list.NextMarker != nil) { | ||
res.Marker = list.NextMarker | ||
list, err = rm.sdkapi.ListVersionsByFunctionWithContext(ctx, res) | ||
if err != nil { | ||
return nil, err | ||
} | ||
versionList = append(versionList, list.Versions...) | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
res := &svcsdk.ListVersionsByFunctionInput{} | |
res.FunctionName = desired.ko.Spec.FunctionName | |
var list *svcsdk.ListVersionsByFunctionOutput | |
list, err = rm.sdkapi.ListVersionsByFunctionWithContext(ctx, res) | |
if err != nil { | |
return nil, err | |
} | |
versionList := list.Versions | |
for ok := list.NextMarker != nil; ok; ok = (list.NextMarker != nil) { | |
res.Marker = list.NextMarker | |
list, err = rm.sdkapi.ListVersionsByFunctionWithContext(ctx, res) | |
if err != nil { | |
return nil, err | |
} | |
versionList = append(versionList, list.Versions...) | |
} | |
marker := nil | |
versionsList := []svcsdk.Version | |
for { | |
listVersionsInput := &svcsdk.ListVersionsByFunctionInput{ | |
FunctionName: desired.ko.Spec.FunctionName, | |
Marker: marker | |
} | |
listVersionResponse, err := rm.sdkapi.ListVersionsByFunctionWithContext(ctx, listVersionsInput) | |
if err != nil { | |
return nil, err | |
} | |
versionsList = append(versionLists, listVersionResponse.Versions...) | |
if listVersionResponse.NextMarker == nil { | |
break | |
} | |
marker = listVersionResponse.NextMarker | |
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Made the suggested changes. Thanks!
services.k8s.aws/region: $AWS_REGION | ||
spec: | ||
functionName: $FUNCTION_NAME | ||
codeSHA256: $HASH |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
How is the $HASH
set
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
codeSHA256
and RevisionId
fields are optional and are used to check whether the Version is published only when there is some change in the code or its configuration. I have added new E2E test to verify the code by setting $HASH to publish the Version.
/test all |
1c8f77d
to
0be1990
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can we name this file function_version.yaml
, to keep the same style used for the files in the same directory?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This file is similar to version_with_check.yaml
file, so I deleted it. Don't remember how it got here.
# Check function version doesn't exist | ||
assert not lambda_validator.version_exists(lambda_function_name, version_number) | ||
|
||
def test_version_with_check(self, lambda_client, lambda_function): |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
What does check here means?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
To check that the version we created above got deleted. We call getFunction
API and pass the Version number along with Function name as we are only deleting a version and not the whole function.
Architectures []*string `json:"architectures,omitempty"` | ||
// The size of the function's deployment package, in bytes. | ||
// +kubebuilder:validation:Optional | ||
CodeSize *int64 `json:"codeSize,omitempty"` | ||
// The function's dead letter queue. | ||
// +kubebuilder:validation:Optional | ||
DeadLetterConfig *DeadLetterConfig `json:"deadLetterConfig,omitempty"` |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Most of the fields in here are not really relevant to a function, should we get rid of them?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We're using PublishVersion
API to set the status and its response has all these fields. So we cannot do anything with the extra fields.
/test all |
0be1990
to
c5682d9
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thank you very much for your contribution @Vandita2020 ! rock on!
/lgtm
[APPROVALNOTIFIER] This PR is APPROVED This pull-request has been approved by: a-hilaly, Vandita2020 The full list of commands accepted by this bot can be found here. The pull request process is described here
Needs approval from an approver in each of these files:
Approvers can indicate their approval by writing |
Summary:
Adding support to publish
Version
for aFunction
.Description:
This PR adds implementation of AWS Lambda’s
Function Version
feature in the ACK. Function versions allow developers to publish new versions of their Lambda functions while maintaining older versions for backward compatibility or testing purposes. This will allow developers to publish new versions of their lambda functions and manage function updates seamlessly using ACK.Version
resource for a Function can be created using following manifest:The PR supports creation and deletion of
Version
resource. It also includes E2E tests to verify the functionality.Acknowledgment:
By submitting this pull request, I confirm that my contribution is made under the terms of the Apache 2.0 license.