-
Notifications
You must be signed in to change notification settings - Fork 24
Add support to configure EventInvokeConfig
for Version
#115
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
Add support to configure EventInvokeConfig
for Version
#115
Conversation
Skipping CI for Draft Pull Request. |
3c7e8b4
to
3b15fe8
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.
Looks good! I have two questions below
@@ -32,7 +32,8 @@ type VersionSpec struct { | |||
CodeSHA256 *string `json:"codeSHA256,omitempty"` | |||
// A description for the version to override the description in the function | |||
// configuration. | |||
Description *string `json:"description,omitempty"` | |||
Description *string `json:"description,omitempty"` | |||
FunctionEventInvokeConfig *PutFunctionEventInvokeConfigInput `json:"functionEventInvokeConfig,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.
Thoughts: how about naming this field EventInvokeConfig
- how does CF support this?
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.
Good suggestion, the CF uses the same naming too EventInvokeConfig
. Here's the link
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.
Looks like it's named FunctionEventInvokeConfig
in https://github.com/aws-controllers-k8s/lambda-controller/blob/main/apis/v1alpha1/function.go#L66
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 keep the things similar across all resources, I am keeping the naming to be FunctionEventInvokeConfig
. Will open a PR in future to correct the naming for all resources.
func (rm *resourceManager) customUpdateVersion( | ||
ctx context.Context, | ||
desired *resource, | ||
latest *resource, | ||
delta *ackcompare.Delta, | ||
) (*resource, error) { | ||
var err error | ||
rlog := ackrtlog.FromContext(ctx) | ||
exit := rlog.Trace("rm.customUpdateFunction") | ||
defer exit(err) | ||
|
||
if isVersionPending(desired) { | ||
return nil, requeueWaitWhilePending | ||
} | ||
|
||
if delta.DifferentAt("Spec.FunctionEventInvokeConfig") { | ||
err = rm.syncEventInvokeConfig(ctx, desired) | ||
if err != nil { | ||
return nil, err | ||
} | ||
} | ||
|
||
readOneLatest, err := rm.ReadOne(ctx, desired) | ||
if err != nil { | ||
return nil, err | ||
} | ||
return rm.concreteResource(readOneLatest), nil | ||
} |
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 if it's the SHA256 or revisionID that changed?
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.
SHA256 and revisionID needs to be matched with the code, if they are different than the expected ones, the controller will not publish version and will throw an error. So those fields cannot be changed and even if one change them and they do not match with the expected, the API will return an error
lambda_validator = LambdaValidator(lambda_client) | ||
|
||
version_number = cr['status']['version'] |
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 assert that the version is 1 ? or 2?
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 more in the test_smoke
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.
I am not sure if that would work or fail, giving it a try by hard coding version to be 1
for test_smoke
function. My guess is while running tests if the controller calls the same API twice for publishing version, the second time the Version won't be published as the same version_number (which is 1) will be passed.
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.
I tried keeping the version to be 1, but the tests failed. My guess is this is because controller might be using same function and publishing Version for it and then deleting it. The concept is even after deleting the function and its associated Version, when it creates the Function with same name and tries to publish Version for it, the Version number gets incremented from the last published version. Thus we cannot hard bound the Version number, instead we're getting the Version number after the Version is published and then using it to check if the Version exists.
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.
Thanks for the clarification. QQ: Why not use different tests functions with brand new names so that we make sure that the published version is 1. Asserting that the versions are 1 is a mandatory thing for us to do, before making a release.
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.
Added a new test function named test_smoke_version_specified
keeping Version to be 1
and testing.
65170b8
to
9808122
Compare
/test all |
/hold |
7b48238
to
10bc8a0
Compare
b3bf2c1
to
44403ae
Compare
44403ae
to
97dad94
Compare
97dad94
to
6a71d99
Compare
6a71d99
to
79df778
Compare
79df778
to
74af390
Compare
74af390
to
81f8f2f
Compare
81f8f2f
to
020045d
Compare
/test all |
Create Version resource Delete functionality mend Check code changes before creating new version resource Adding E2E tests Review changes Add support to configure EventInvokeConfig for Version E2E tests for EventInvokeConfig
020045d
to
3441bf0
Compare
/test all |
/retest |
/test all |
/retest |
1 similar comment
/retest |
test/e2e/tests/test_version.py
Outdated
@@ -81,7 +81,9 @@ def lambda_function(): | |||
@pytest.mark.canary | |||
class TestVersion: | |||
def test_smoke(self, lambda_client, lambda_function): | |||
(_, function_resource) = lambda_function | |||
(function_reference, function_resource) = lambda_function | |||
fn_resource = k8s.get_resource(function_reference) |
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 fn_resource
actually different than function_resource
? Any reason to not just use the same variable?
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.
Thanks for bringing this up. Have kept fn_resource
and used it. Need to use fn_resource
as k8s.get_resource
is passing the whole function resource which can then be modified, which is required in our case.
c0661ca
to
a7e13c6
Compare
a7e13c6
to
c30edd1
Compare
c30edd1
to
13dfbef
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 @Vandita2020 !
/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 |
/unhold |
Issue #, if available:
Description of changes:
By submitting this pull request, I confirm that my contribution is made under the terms of the Apache 2.0 license.