-
Notifications
You must be signed in to change notification settings - Fork 2.3k
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
Modified code for patches and patchJson6902 which will throw error if target is not found #4715
Modified code for patches and patchJson6902 which will throw error if target is not found #4715
Conversation
Welcome @laxmikantbpandhare! |
Hi @laxmikantbpandhare. Thanks for your PR. I'm waiting for a kubernetes-sigs member to verify that this patch is reasonable to test. If it is, they should reply with Once the patch is verified, the new status will be reflected by the I understand the commands that are listed here. 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. |
@laxmikantbpandhare: This PR has multiple commits, and the default merge method is: merge. 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. |
/label tide/merge-method-squash |
/label WIP |
@laxmikantbpandhare: The label(s) 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. |
19c4c7a
to
941a44b
Compare
/ok-to-test |
@yuwenma: The
Use 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. |
/approve |
/assign @natasha41575 |
@KnVerey @natasha41575 - Could you please take a look at this. |
/remove-lifecycle stale |
@annasong20 - thank you for your comment. I will start looking into it. |
As of now, Added as a log warning. I would like to know more about the stderr requirement for patchJsonTransformer. patchjson6902Transformer I kept it as it is as it ll be deprecated soon. |
@laxmikantbpandhare: 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. |
Test Jobs are failing as test cases have not been updated yet. |
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.
Thank you for all of your work on this, @laxmikantbpandhare!
I gave a high-level review of the current code behavior. Lmk if anything is unclear. Once we've fulfilled the behavior agreed upon in #4379 and added tests, I'll do another pass for details.
@@ -100,6 +100,11 @@ func (p *plugin) transformStrategicMerge(m resmap.ResMap, patch *resource.Resour | |||
if err != nil { | |||
return err | |||
} | |||
|
|||
if p.Options["allowNoTargetMatch"] { | |||
log.Println("Warning: patches target not found for Target") |
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.
Can we print to os.Stderr
instead? You can use fmt.Fprintf
.
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.
Updated as below:
fmt.Fprintf(os.Stderr, "%v\n", "Warning: patches target not found for Target")
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 don't see this change in the code.
@@ -100,6 +100,11 @@ func (p *plugin) transformStrategicMerge(m resmap.ResMap, patch *resource.Resour | |||
if err != nil { | |||
return err | |||
} | |||
|
|||
if p.Options["allowNoTargetMatch"] { |
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.
This is close. Instead, we want to emit this warning if allowNoTargetMatch
is true
AND there is no matching target (selected
is empty).
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.
totally agree.
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.
Updated as below:
if p.Options["allowNoTargetMatch"] && len(selected) == 0 {
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 see your comment, but this doesn't seem to be reflected in the code? Can you commit your changes?
if p.Options["allowNoTargetMatch"] { | ||
log.Println("Warning: patches target not found for Target") | ||
} |
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.
Same as above.
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.
Updated same as above.
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.
Don't see the change in code.
@@ -100,6 +100,11 @@ func (p *plugin) transformStrategicMerge(m resmap.ResMap, patch *resource.Resour | |||
if err != nil { | |||
return err | |||
} | |||
|
|||
if p.Options["allowNoTargetMatch"] { |
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.
Now that options
is growing, can we define a struct under api/types
to replace the map[string]bool
? The field will be better documented that way and we'll be less likely to suffer from typo bugs.
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.
@annasong20 - We can create a PatchTransformer struct under api/types
. So, do you mean only the options
field can be moved out of it and add it in api/types
? Please let me know if I am wrong.
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.
Good question! I only need options
to be a struct under api/types
, but if you'd like you can move the PatchTransformer arguments into a PatchArgs
. The latter is more work, but I think easier to read in the long run.
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. |
/remove-approve |
/unhold |
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.
@laxmikantbpandhare Sorry for taking so long to re-review. I took a closer look this time. Can you address my new comments?
Also, could you rebase?
@@ -100,6 +100,11 @@ func (p *plugin) transformStrategicMerge(m resmap.ResMap, patch *resource.Resour | |||
if err != nil { | |||
return err | |||
} | |||
|
|||
if p.Options["allowNoTargetMatch"] { |
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.
Good question! I only need options
to be a struct under api/types
, but if you'd like you can move the PatchTransformer arguments into a PatchArgs
. The latter is more work, but I think easier to read in the long run.
@@ -100,6 +100,11 @@ func (p *plugin) transformStrategicMerge(m resmap.ResMap, patch *resource.Resour | |||
if err != nil { | |||
return err | |||
} | |||
|
|||
if p.Options["allowNoTargetMatch"] { |
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 see your comment, but this doesn't seem to be reflected in the code? Can you commit your changes?
@@ -100,6 +100,11 @@ func (p *plugin) transformStrategicMerge(m resmap.ResMap, patch *resource.Resour | |||
if err != nil { | |||
return err | |||
} | |||
|
|||
if p.Options["allowNoTargetMatch"] { | |||
log.Println("Warning: patches target not found for Target") |
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 don't see this change in the code.
@@ -100,6 +100,11 @@ func (p *plugin) transformStrategicMerge(m resmap.ResMap, patch *resource.Resour | |||
if err != nil { | |||
return err | |||
} | |||
|
|||
if p.Options["allowNoTargetMatch"] { | |||
log.Println("Warning: patches target not found for Target") |
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.
Can we print for users the "Target" that we're looking for?
As a user with a complex Kustomization, I'd be confused and need to debug which patch target is missing.
if p.Options["allowNoTargetMatch"] { | ||
log.Println("Warning: patches target not found for Target") | ||
} |
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.
Don't see the change in code.
|
||
if p.Options["allowNoTargetMatch"] { | ||
log.Println("Warning: patches target not found for Target") | ||
} |
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 still need to return an error if allowNoTargetMatch
is not set?
version: v2 | ||
path: patch.0.yaml | ||
`) | ||
th.WriteF("base/servicemonitor.yaml", ` |
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.
Can we use the existing files in makeCommonFileForExtendedPatchTest
for this test?
@@ -1213,3 +1066,44 @@ spec: | |||
app: busybox | |||
`) | |||
} | |||
|
|||
func TestTargetMissingPatchJson6902Error(t *testing.T) { |
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 don't seem to have tests for
allowNoTargetMatch
- json patches under the
patches
field
/approve cancel |
[APPROVALNOTIFIER] This PR is NOT APPROVED This pull-request has been approved by: laxmikantbpandhare, yuwenma 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 |
selfish bump, looking forward to it |
The Kubernetes project currently lacks enough contributors to adequately respond to all PRs. This bot triages PRs according to the following rules:
You can:
Please send feedback to sig-contributor-experience at kubernetes/community. /lifecycle stale |
/unassign |
/uncc |
The Kubernetes project currently lacks enough active contributors to adequately respond to all PRs. This bot triages 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. |
Fix for
patchesJson6902
,patches
is completed. This fix verifies whether isresources
filed has any data or not. If it is empty then there is definitely a missing target.patchStrategicMerge
is already throwing an error if thetarget
is missing.This will fix #4379