-
Notifications
You must be signed in to change notification settings - Fork 79
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
[WIP] fix: Require src namespace in apply-time-mutation #482
Conversation
[APPROVALNOTIFIER] This PR is NOT APPROVED This pull-request has been approved by: karlkfi The full list of commands accepted by this bot can be found here.
Needs approval from an approver in each of these files:
Approvers can indicate their approval by writing |
670d92b
to
9cebcd9
Compare
klog.V(3).Infof("adding vertex: %s", id) | ||
g.AddVertex(id) | ||
if mutation.HasAnnotation(obj) { | ||
subs, err := mutation.ReadAnnotation(obj) | ||
if err != nil { | ||
// TODO: fail task if parse errors? | ||
klog.V(3).Infof("failed to add edges from: %s: %s", id, err) | ||
klog.Warningf("warning: failed to sort explicit dependency: %v", |
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.
klog.Warning
prints directly to the user when using kapply or kpt, but for server-side usage it would just print to the service log.
Should we make a new WarningEvent instead, so the printer can handle it?
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.
The Warning
event would be a new top-level event type then? It seems like it would be only for the user to understand what is going on, as it seems difficult to use it for anything useful from code? Another option (perhaps in addition to a Warning
event) would be to allow users to specify if invalid references should lead to an error or not. Although that would require that we can fit the behavior into the continue-on-error strategy, but this happens before we apply any of the resources.
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 I think the question here is what should happen if either the annotation can't be read or it doesn't specify a namespace in a reference to a namespace-scoped resource. If we print an error or send an error event, then presumably we will go on with applying the resource right? I think considering the resource as failed/skipped in this situation might be more appropriate, and we can provide information back to the caller through the Error
property on the ApplyEvent
. It seems that applying the resource without doing the apply-time mutation almost certainly will result in a different outcome than the user expected. And by just considering that particular resource as failed/skipped, we will still continue applying other resources.
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've defined the problem and a couple proposals here: #484
9cebcd9
to
522b7b4
Compare
- This change dissables implicit namespace resolution for apply-time-mutation sourceRefs. This feature has been partially broken since it was implimented and fixing it is not currently possible. The sorting never worked properly because the namespace was being infered at apply time, while sorting was being done much earlier, before the tasks were scheduled. - Unfortunately, this makes testing and usage harder when the namespace is not known in advance, requiring yaml templating. - Avoid logging yaml at log lvl 5 (use lvl 7) - Improve error messages when annotation read/write fails - Warn if dependencies cannot be sorted - Warn if dependency not in resource set
522b7b4
to
51341e4
Compare
@@ -78,7 +78,7 @@ func (atm *ApplyTimeMutator) Mutate(ctx context.Context, obj *unstructured.Unstr | |||
|
|||
// Default source namespace to target namesapce, if namespace-scoped |
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.
We should probably fix the comment here.
klog.V(3).Infof("adding vertex: %s", id) | ||
g.AddVertex(id) | ||
if mutation.HasAnnotation(obj) { | ||
subs, err := mutation.ReadAnnotation(obj) | ||
if err != nil { | ||
// TODO: fail task if parse errors? | ||
klog.V(3).Infof("failed to add edges from: %s: %s", id, err) | ||
klog.Warningf("warning: failed to sort explicit dependency: %v", |
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.
The Warning
event would be a new top-level event type then? It seems like it would be only for the user to understand what is going on, as it seems difficult to use it for anything useful from code? Another option (perhaps in addition to a Warning
event) would be to allow users to specify if invalid references should lead to an error or not. Although that would require that we can fit the behavior into the continue-on-error strategy, but this happens before we apply any of the resources.
@karlkfi: PR needs rebase. 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. |
@karlkfi: The following test failed, say
Full PR test history. Your PR dashboard. Please help us cut down on flakes by linking to an open issue when you hit one in your PR. 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. |
The Kubernetes project currently lacks enough contributors to adequately respond to all issues and PRs. This bot triages issues and PRs according to the following rules:
You can:
Please send feedback to sig-contributor-experience at kubernetes/community. /lifecycle stale |
The Kubernetes project currently lacks enough active contributors to adequately respond to all issues and PRs. This bot triages issues and PRs according to the following rules:
You can:
Please send feedback to sig-contributor-experience at kubernetes/community. /lifecycle rotten |
/remove-lifecycle rotten |
The Kubernetes project currently lacks enough contributors to adequately respond to all issues and PRs. This bot triages issues and PRs according to the following rules:
You can:
Please send feedback to sig-contributor-experience at kubernetes/community. /lifecycle stale |
The Kubernetes project currently lacks enough active contributors to adequately respond to all issues and PRs. This bot triages issues and PRs according to the following rules:
You can:
Please send feedback to sig-contributor-experience at kubernetes/community. /lifecycle rotten |
The Kubernetes project currently lacks enough active contributors to adequately respond to all issues and PRs. This bot triages PRs according to the following rules:
You can:
Please send feedback to sig-contributor-experience at kubernetes/community. /close |
@k8s-triage-robot: Closed this PR. In response to this:
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. |
apply-time-mutation sourceRefs. This feature has been partially
broken since it was implimented and fixing it is not currently
possible. The sorting never worked properly because the namespace
was being infered at apply time, while sorting was being done
much earlier, before the tasks were scheduled.
namespace is not known in advance, requiring yaml templating.
Fixes: #481