Skip to content
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

Update Routes for VirtualService/VirtualRouter changes #8

Merged
merged 1 commit into from
Mar 16, 2019
Merged

Update Routes for VirtualService/VirtualRouter changes #8

merged 1 commit into from
Mar 16, 2019

Conversation

nckturner
Copy link
Contributor

@nckturner nckturner commented Mar 14, 2019

This change creates, updates and deletes routes in AppMesh based on the VirtualService custom resource.

Similar to #7 except that it also cleans up routes for a virtual router that is referenced by a VirtualService custom resource.

By submitting this pull request, I confirm that my contribution is made under the terms of the Apache 2.0 license.

}, nil
}

func notFound(err error) bool {
Copy link

Choose a reason for hiding this comment

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

Nit: I like the cleanup, but maybe a too general name? What about isErrCodeNotFound()?

@@ -85,6 +85,8 @@ spec:
weight: 1
- virtualNodeName: colorteller-blue-vn
weight: 1
- virtualNodeName: colorteller-black-vn
weight: 1
Copy link

Choose a reason for hiding this comment

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

Is there a way to check that weight is between 1 and 100, and throw a useful error message if it is outside the boundary?

Copy link
Collaborator

@stefanprodan stefanprodan Mar 14, 2019

Choose a reason for hiding this comment

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

I think the range validation (0-100) can be made in the CRD API spec with a regex.

}

return &Route{
Data: *output.Route,
Copy link
Collaborator

Choose a reason for hiding this comment

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

This will panic see 2fa2058

}
extraTarget = []appmeshv1alpha1.WeightedTarget{
{Weight: int64(1), VirtualNodeName: defaultNodeName},
{Weight: int64(1), VirtualNodeName: "extra-node"},
Copy link
Collaborator

Choose a reason for hiding this comment

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

Weight should be different for each target, due to a the pointer ref in here https://github.com/aws/aws-app-mesh-controller-for-k8s/pull/7/files#diff-a9ebef8a191b968924fc4bb6a3d2f788L511 you'll end up with the same weight for all targets. Also there should be a test that checks the weights are created and changed accordingly.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Good catch, thanks.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I'll add this in another PR.

return nil, nil
}
if notFound(err) {
return nil, nil
Copy link
Collaborator

Choose a reason for hiding this comment

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

Why does this returns nil instead of a not found error?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I wanted an obvious way to distinguish from other errors, that allowed a simpler check than the aws error type switch statement in calling code, but perhaps I should either just return the aws error or wrap it and return it. I think probably just returning the aws error is fine and moving notFound() to the calling package.

@@ -85,6 +85,8 @@ spec:
weight: 1
- virtualNodeName: colorteller-blue-vn
weight: 1
- virtualNodeName: colorteller-black-vn
weight: 1
Copy link
Collaborator

@stefanprodan stefanprodan Mar 14, 2019

Choose a reason for hiding this comment

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

I think the range validation (0-100) can be made in the CRD API spec with a regex.

}

return &VirtualService{
Data: *output.VirtualService,
Copy link
Collaborator

Choose a reason for hiding this comment

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

This will panic see 2fa2058

@nckturner nckturner merged commit e9ef614 into aws:master Mar 16, 2019
jeremymill added a commit to jeremymill/aws-app-mesh-controller-for-k8s that referenced this pull request Apr 13, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants