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

Propagate annotations from EL to svc and deployment #712

Merged
merged 1 commit into from
Aug 31, 2020

Conversation

piyush-garg
Copy link
Contributor

@piyush-garg piyush-garg commented Aug 14, 2020

This will add the feature of propagating annotations
of an eventlistener to the service, deployment and
further pods created by the eventlistener

Add docs and tests

Fix #700

Submitter Checklist

These are the criteria that every PR should meet, please check them off as you
review them:

See the contribution guide for more details.

Release Notes

Now annotations of the eventlistener will be propagated to deployment and services. If you have any custom annotation on your services/deployment, please add them to annotations otherwise they will be overwritten.

@tekton-robot tekton-robot added the size/L Denotes a PR that changes 100-499 lines, ignoring generated files. label Aug 14, 2020
@tekton-robot
Copy link

The following is the coverage report on the affected files.
Say /test pull-tekton-triggers-go-coverage to re-run this coverage report

File Old Coverage New Coverage Delta
pkg/reconciler/v1alpha1/eventlistener/eventlistener.go 70.8% 71.3% 0.5

@piyush-garg
Copy link
Contributor Author

/cc @dibyom @khrm @savitaashture

@savitaashture
Copy link
Contributor

@piyush-garg Thank you for the PR 👍

I have one suggestion related to annotation usage as @dibyom mentioned use case of adding annotation over the issue so i feel it would be great if we cover that usecase as part of examples also

Otherwise PR looks good to me 🙂

Copy link
Contributor

@khrm khrm left a comment

Choose a reason for hiding this comment

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

lgtm but add this information succinctly in https://github.com/tektoncd/triggers/blob/master/docs/eventlisteners.md
And an example like @savitaashture said.

@piyush-garg
Copy link
Contributor Author

@khrm @savitaashture Would want to add some annotation to all the examples there? The feature is all the annotations present in eventlistener will be copied to all services and deployments, not sure how we can show that in examples.

@savitaashture
Copy link
Contributor

savitaashture commented Aug 17, 2020

@khrm @savitaashture Would want to add some annotation to all the examples there? The feature is all the annotations present in eventlistener will be copied to all services and deployments, not sure how we can show that in examples.

IMO adding in one example(GH, GL etc...) would be enough to show the usage of annotation propagation.
I mean you can take the examples from here and show how we can use that as part of EL in README is also fine because adding it in examples will be difficult because of dependency.

And +1 for adding it to docs

@piyush-garg
Copy link
Contributor Author

@khrm @savitaashture I have updated the PR with doc and example. Thanks for review

@tekton-robot
Copy link

The following is the coverage report on the affected files.
Say /test pull-tekton-triggers-go-coverage to re-run this coverage report

File Old Coverage New Coverage Delta
pkg/reconciler/v1alpha1/eventlistener/eventlistener.go 70.8% 71.3% 0.5

@khrm
Copy link
Contributor

khrm commented Aug 18, 2020

/lgtm

@tekton-robot tekton-robot added the lgtm Indicates that a PR is ready to be merged. label Aug 18, 2020
@savitaashture
Copy link
Contributor

/lgtm

Thank you

@@ -447,6 +451,7 @@ func generateObjectMeta(el *v1alpha1.EventListener) metav1.ObjectMeta {
Name: el.Status.Configuration.GeneratedResourceName,
OwnerReferences: []metav1.OwnerReference{*el.GetOwnerReference()},
Labels: mergeLabels(el.Labels, GenerateResourceLabels(el.Name)),
Annotations: el.Annotations,
Copy link
Member

Choose a reason for hiding this comment

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

I think we should merge any extra annotations that might have been added by something besides the EL controller instead of overwriting it (just like we are doing it with the labels above).

Copy link
Contributor Author

Choose a reason for hiding this comment

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

@dibyom We are also overwriting in case of labels as per my understanding. We are merging labels to add the few labels which are generated by triggers controller, apart from that in case of labels also we are doing the same, copying the available in eventlistener, add the few generated by the controller and propagate to svc/deployment.

If we merge the extra annotation, don't do any anything which is already added, then how we can remove the one which a user did by mistake e.g. I have added an annotation with a typo in key. We will be in the same situation as before. So I think whatever the current set in EL should be copied further.

And as per my little understanding with the codebase, we are doing the same with labels. Please correct me here if wrong.

Copy link
Contributor

Choose a reason for hiding this comment

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

Yes we are just copying labels coming from eventlistener and merging with labels which are generated by triggers controller.
For annotation we don't have any annotation which are generated by triggers controller so we should just copy whatever is coming from eventlistener yaml and imo we don't require any merging functionality here

I think we should merge any extra annotations that might have been added by something besides the EL controller instead of overwriting it

@dibyom when you say something besides the EL controller do you mean annotation added by user ?

Copy link
Member

Choose a reason for hiding this comment

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

Hey, sorry for the delayed response.

@piyush-garg you are right -> we do overwrite the labels. The use case I was thinking of is the following -- say someone currently has a custom annotation set directly on the EL service/deployment. Now, when they upgrade to Triggers containing this change, the custom annotation will be unset. So, they'd have to manually add their annotations to the EL in order to make it work.

If we merge the extra annotation, don't do any anything which is already added, then how we can remove the one which a user did by mistake e.g. I have added an annotation with a typo in key.

Yeah, that's not ideal either :( The user would have to delete them from the EL deployment/service manually.

It gets a bit more complicated if we consider TEP-009. In that design, users can specify annotations/labels directly for the EL deployment. So, we'll have to see if it makes sense to keep propagating them.

So, the options I see are:

  1. Make the change in this PR and mark in the Release Notes that users have to manually update the EL's annotations if they added any custom annotations.

  2. Merge any existing annotations on the labels/annotations with any applied on the EL instead of overwriting them.

  3. Wait for TEP-009 design to be implemented where users can directly specify a podTemplate with exactly the annotations they want for the deployment. ( We might want to augment that design with something like a serviceTemplate for the EL service as well)

Does that make sense? Thoughts @savitaashture @piyush-garg @khrm ?

Copy link
Contributor

@savitaashture savitaashture Aug 21, 2020

Choose a reason for hiding this comment

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

@dibyom

Yes i agree with your point lets merge this PR with release note

  1. Wait for TEP-009 design to be implemented where users can directly specify a podTemplate with exactly the annotations they want for the deployment. ( We might want to augment that design with something like a serviceTemplate for the EL service as well)

Yes need to rethink about the support of annotation for Service while implementing TEP-0008 as that is bit tricky.
I will take care of this while implementation
Thank you for pointing it out here 👍

@tekton-robot tekton-robot added the needs-rebase Indicates a PR cannot be merged because it has merge conflicts with HEAD. label Aug 19, 2020
@savitaashture
Copy link
Contributor

savitaashture commented Aug 21, 2020

@piyush-garg could you please add points mentioned by @dibyom to release note and also resolve the conflict

@tekton-robot tekton-robot removed the lgtm Indicates that a PR is ready to be merged. label Aug 27, 2020
@tekton-robot
Copy link

The following is the coverage report on the affected files.
Say /test pull-tekton-triggers-go-coverage to re-run this coverage report

File Old Coverage New Coverage Delta
pkg/reconciler/v1alpha1/eventlistener/eventlistener.go 73.7% 74.1% 0.5

@piyush-garg
Copy link
Contributor Author

piyush-garg commented Aug 27, 2020

@khrm @savitaashture @dibyom I have updated the PR according to the discussion and also resolved the conflicts. Thanks for all reviews and suggestions.

@tekton-robot tekton-robot removed the needs-rebase Indicates a PR cannot be merged because it has merge conflicts with HEAD. label Aug 27, 2020
@savitaashture
Copy link
Contributor

/lgtm

@tekton-robot tekton-robot added the lgtm Indicates that a PR is ready to be merged. label Aug 28, 2020
@@ -220,6 +221,24 @@ must adhere to the
[Kubernetes syntax and character set requirements](https://kubernetes.io/docs/concepts/overview/working-with-objects/labels/#syntax-and-character-set)
for label values.

## Annotations
Copy link
Contributor

Choose a reason for hiding this comment

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

I think we should also document the behaviour for what happens when deployment or service has an annotation already present.

Copy link
Contributor

Choose a reason for hiding this comment

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

Or is mentioning that only in release note OK, @dibyom ?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

@khrm I have updated the doc also with the Note

This will add the feature of propagating annotations
of an eventlistener to the service, deployment and
further pods created by the eventlistener

Add docs and tests

Fix tektoncd#700
@tekton-robot tekton-robot removed the lgtm Indicates that a PR is ready to be merged. label Aug 31, 2020
@tekton-robot
Copy link

The following is the coverage report on the affected files.
Say /test pull-tekton-triggers-go-coverage to re-run this coverage report

File Old Coverage New Coverage Delta
pkg/reconciler/v1alpha1/eventlistener/eventlistener.go 73.7% 74.1% 0.5

Copy link
Contributor

@khrm khrm left a comment

Choose a reason for hiding this comment

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

/lgtm

@tekton-robot tekton-robot added the lgtm Indicates that a PR is ready to be merged. label Aug 31, 2020
@piyush-garg
Copy link
Contributor Author

@savitaashture @dibyom Probably the last round of review

@dibyom
Copy link
Member

dibyom commented Aug 31, 2020

/approve

@tekton-robot
Copy link

[APPROVALNOTIFIER] This PR is APPROVED

This pull-request has been approved by: dibyom

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 /approve in a comment
Approvers can cancel approval by writing /approve cancel in a comment

@tekton-robot tekton-robot added the approved Indicates a PR has been approved by an approver from all required OWNERS files. label Aug 31, 2020
@tekton-robot tekton-robot merged commit 0e93685 into tektoncd:master Aug 31, 2020
dibyom added a commit to dibyom/triggers that referenced this pull request Sep 10, 2020
In tektoncd#712, we added a feature to propagate annotations added to the EL to its
underlying resources. However, this resulted in infinite reconcile loops since
the deployment controller will add a standard revision annotation that the EL
controller will keep trying to overwrite. To fix this, this commit switches the
annotation propagation to merge any annotations set on the underlying resources
before adding any extra annotations from the EL.

Fixes tektoncd#751

Signed-off-by: Dibyo Mukherjee <dibyo@google.com>
dibyom added a commit to dibyom/triggers that referenced this pull request Sep 10, 2020
In tektoncd#712, we added a feature to propagate annotations added to the EL to its
underlying resources. However, this resulted in infinite reconcile loops since
the deployment controller will add a standard revision annotation that the EL
controller will keep trying to overwrite. To fix this, this commit switches the
annotation propagation to merge any annotations set on the underlying resources
before adding any extra annotations from the EL.

Fixes tektoncd#752

Signed-off-by: Dibyo Mukherjee <dibyo@google.com>
@dibyom dibyom mentioned this pull request Sep 10, 2020
3 tasks
dibyom added a commit to dibyom/triggers that referenced this pull request Sep 10, 2020
In tektoncd#712, we added a feature to propagate annotations added to the EL to its
underlying resources. However, this resulted in infinite reconcile loops since
the deployment controller will add a standard revision annotation that the EL
controller will keep trying to overwrite. To fix this, this commit switches the
annotation propagation to merge any annotations set on the underlying resources
before adding any extra annotations from the EL.

Fixes tektoncd#752

Signed-off-by: Dibyo Mukherjee <dibyo@google.com>
dibyom added a commit to dibyom/triggers that referenced this pull request Sep 11, 2020
In tektoncd#712, we added a feature to propagate annotations added to the EL to its
underlying resources. However, this resulted in infinite reconcile loops since
the deployment controller will add a standard revision annotation that the EL
controller will keep trying to overwrite. To fix this, this commit switches the
annotation propagation to merge any annotations set on the underlying resources
before adding any extra annotations from the EL.

Fixes tektoncd#752

Signed-off-by: Dibyo Mukherjee <dibyo@google.com>
tekton-robot pushed a commit that referenced this pull request Sep 11, 2020
In #712, we added a feature to propagate annotations added to the EL to its
underlying resources. However, this resulted in infinite reconcile loops since
the deployment controller will add a standard revision annotation that the EL
controller will keep trying to overwrite. To fix this, this commit switches the
annotation propagation to merge any annotations set on the underlying resources
before adding any extra annotations from the EL.

Fixes #752

Signed-off-by: Dibyo Mukherjee <dibyo@google.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
approved Indicates a PR has been approved by an approver from all required OWNERS files. lgtm Indicates that a PR is ready to be merged. size/L Denotes a PR that changes 100-499 lines, ignoring generated files.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Propagate annotations from EL to svc and pods
5 participants