-
Notifications
You must be signed in to change notification settings - Fork 221
feat: return error on missing required fields during adoption #613
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
base: main
Are you sure you want to change the base?
feat: return error on missing required fields during adoption #613
Conversation
/retest |
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.
noice! thanks @michaelhtm
pkg/generate/code/set_resource.go
Outdated
// The variable used for primary key | ||
requiredFieldVarName string, |
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 variable needed a this level? doc updates?
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.
yes, we construct it inside the PopulateResourceFromAnnotation, where we find out if a field is a primary key or it's just a required field.
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.
doc updates?
831f5ac
to
5e72da5
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.
Q: Is a field being required always a field we need to adopt a resource? It seems like a field could be considered required to create/update a resource, but not necessarily to identify it.
5e72da5
to
6f0d5cd
Compare
// if !ok { | ||
// return ackerrors.MissingNameIdentifier |
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 about return ackerrors.MissingNameIdentifier(fieldNames...)
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.
So for a longtime this wasn't considered a terminal error?
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.
MissingNameIdentifier is an error introduced by SetIdentifiers (Adopted CRD). It was mainly used when NameOrID was nil.
This error message fix was introduced here
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.
@michaelhtm thanks for resolving my. Holding of on lgtm so that @a-hilaly can verify that their comments have been resolved.
[APPROVALNOTIFIER] This PR is APPROVED This pull-request has been approved by: knottnt, michaelhtm 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 |
/retest |
/test eks-controller-test |
During resource Adoption, the ACK controllers only returned an error when there was a missing PrimaryKey. If a Resource requires more than 1 field to describe a Resource (eg. Lambda alias requires Name and FunctionName), the controller only verifies the Primary identifier (ARN, ID, Name) and nothing else. With this change, we look into the SDK model to retrieve the required fields and return an error if all are not defined during `PopulateResourceFromAnnotation`
6f0d5cd
to
9c0d0ba
Compare
/retest |
@michaelhtm: The following tests failed, say
Full PR test history. Your PR dashboard. Instructions for interacting with me using PR comments are available here. If you have questions or suggestions related to my behavior, please file an issue against the kubernetes/test-infra repository. I understand the commands that are listed here. |
default: | ||
break |
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.
why? maybe a commment explaining
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.
all break does is exit the switch case. since we're already at the end i thought it was unnecessary.
here's an example: https://go.dev/play/p/aFKpTVGC6BT
Issue #2557
Description of changes:
During resource Adoption, the ACK controllers only returned an error
when there was a missing PrimaryKey. If a Resource requires more than 1
field to describe a Resource (eg. Lambda alias requires Name and
FunctionName), the controller only verifies the Primary identifier (ARN,
ID, Name) and nothing else.
With this change, we look into the SDK model to retrieve the required
fields and return an error if all are not defined during
PopulateResourceFromAnnotation
By submitting this pull request, I confirm that my contribution is made under the terms of the Apache 2.0 license.