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

Clean Up Objects in App Mesh #12

Merged
merged 1 commit into from
Mar 22, 2019
Merged

Clean Up Objects in App Mesh #12

merged 1 commit into from
Mar 22, 2019

Conversation

nckturner
Copy link
Contributor

@nckturner nckturner commented Mar 19, 2019

  • Uses a finalizer to implement a delete hook.
  • When custom resource is deleted, clean up corresponding objects in App Mesh.
    • Virtual Node -> Virtual Node.
    • Virtual Service -> Virtual Service, Virtual Router, Routes.
    • Mesh -> Mesh, and all resources in the mesh.
    • Do not process virtual nodes, virtual services when the mesh doesn't exist or is deleting.
  • Status should reflect the current state of the object in App Mesh.
    • Condition for Mesh Deleting on Virtual Nodes, Virtual Services.
    • ARN of resources in status.
    • Resources shouldn't be active when they have been deleted.
    • Update conditions based on describe.
      • Virtual Service
      • Virtual Node
      • Mesh
  • Unit tests
  • Godocs

Issue #, if available:
#10, #11

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

@nckturner
Copy link
Contributor Author

WIP, will push the rest tomorrow morning.

@nckturner nckturner changed the title Clean up App Mesh resource Clean Up Objects in App Mesh Mar 20, 2019
pkg/aws/appmesh.go Show resolved Hide resolved
return
} else {
for _, obj := range objects {
vnode, ok := obj.(*appmeshv1alpha1.VirtualNode)
Copy link

Choose a reason for hiding this comment

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

Ah, this just filters out the VirtualNodes from the list of objects. What can be returned by c.virtualNodeIndex.ByIndex("meshName", name) besides VirtualNodes?

Copy link
Contributor Author

@nckturner nckturner Mar 21, 2019

Choose a reason for hiding this comment

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

Probably nothing for now, but its a pattern I saw in upstream k8s. As you pointed out in offline discussion today, potentially if we bump the version we would need to filter out objects with previous versions.


// This is not a delete, add the deletion finalizer if it doesn't exist
if yes, _ := containsFinalizer(mesh, meshDeletionFinalizerName); !yes {
_ = addFinalizer(mesh, meshDeletionFinalizerName)
Copy link

Choose a reason for hiding this comment

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

Is it safe to ignore these errors?

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 didn't think there would ever be a case that the object would have no meta, but I guess we should at least log since it shouldn't ever happen.

return c.updateVServiceCondition(vservice, appmeshv1alpha1.VirtualServiceInactive, status)
}

func (c *Controller) updateVServiceDeleted(vservice *appmeshv1alpha1.VirtualService, status api.ConditionStatus) error {
Copy link

Choose a reason for hiding this comment

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

Worth making a helper for updateVServiceMarkForDeletion() as well?

func (c *Controller) updateVServiceMarkForDeletion(vservice *appmeshv1alpha1.VirtualService) error {
    return c.updateVServiceCondition(vservice, appmeshv1alpha1.VirtualServiceMeshMarkedForDeletion, api.ConditionTrue);
}

Copy link

@christopherhein christopherhein left a comment

Choose a reason for hiding this comment

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

Only two questions, see below for the first and the second why are the Spec and Status for each type pointers to the accompanying structs in

// +optional
Spec *MeshSpec `json:"spec,omitempty"`
// +optional
Status *MeshStatus `json:"status,omitempty"`

@@ -51,11 +51,13 @@ spec:
type: string
enum:
- Active
- Inactive
- Deleted
status:
type: string

Choose a reason for hiding this comment

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

Should we be using a boolean, and converting for our backend?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

We could definitely start with just Active

Choose a reason for hiding this comment

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

for status? I was confused by status being a string with "True" and "False" I can see people thinking it's an actual bool and trying true or false w/o quotes.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

@christopherhein I intended to use pointers only for optional values, as the API guidelines recommend. status is optional because a custom resource can be created without it by a user. spec could probably not be a pointer.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

My above comment ^ doesn't make sense in the context. I was trying to respond to your overall review comment.

for status? I was confused by status being a string with "True" and "False" I can see people thinking it's an actual bool and trying true or false w/o quotes.

You're talking about the allowed values of api.ConditionStatus? Its not something people should set, rather its to be used by the controller to convey information to the user. Also its an upstream dependency so I can't change it without re-defining it.

Copy link
Contributor Author

@nckturner nckturner Mar 21, 2019

Choose a reason for hiding this comment

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

I've removed Inactive and Deleted as conditions for now, and we just have Active, which can be True, False or Unknown. This is a Kubernetes convention, currently we are only setting the values to Active=True once the resources are created. We can make it smarter in the future.

serviceDiscoveryType:
type: string
enum:
- cloudmap-http
- dns
Copy link
Contributor Author

Choose a reason for hiding this comment

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

We are starting with just DNS support. At this point this field doesn't do anything, but we will need it later in order to enable Cloud Map http service discovery by creating a Cloud Map namespace.

* When custom resource is deleted, clean up corresponding objects
  in App Mesh.
* Uses a finalizer to implement a delete hook.
* When a mesh is deleted, all objects in App Mesh in the mesh that
  have corresponding custom resources are deleted.
* Remove pointers from spec and status fields of all custom resources
* Convert App Mesh statuses to a single Active status that is true,
  false, or Unknown.
@nckturner
Copy link
Contributor Author

Updated and addressed most of Claes's and Chris's comments, going to merge and create issues for the important stuff thats left on the checklist.

@nckturner nckturner merged commit 1a11b5f into aws:master Mar 22, 2019
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