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

revert "fix wrong output when using jsonpath" #104172

Merged
merged 2 commits into from
Aug 31, 2021

Conversation

atiratree
Copy link
Member

@atiratree atiratree commented Aug 5, 2021

What type of PR is this?

/kind bug
/kind regression

What this PR does / why we need it:

This partially reverts commit #98057

the original problem was caused by not using {end} at the end of the range. Please see attached jsonpath documentation on using range.

The reverted commit causes a new bug of not parsing missing keys incorrectly (added a unit test for this use case)

Which issue(s) this PR fixes:

Fixes #104276

Special notes for your reviewer:

Does this PR introduce a user-facing change?

Fix a 1.22 regression with wrong output using jsonpath

Additional documentation e.g., KEPs (Kubernetes Enhancement Proposals), usage docs, etc.:

[Other doc]: https://kubernetes.io/docs/reference/kubectl/jsonpath/

@k8s-ci-robot k8s-ci-robot added release-note-none Denotes a PR that doesn't merit a release note. kind/bug Categorizes issue or PR as related to a bug. kind/regression Categorizes issue or PR as related to a regression from a prior release. size/XS Denotes a PR that changes 0-9 lines, ignoring generated files. cncf-cla: yes Indicates the PR's author has signed the CNCF CLA. do-not-merge/needs-sig Indicates an issue or PR lacks a `sig/foo` label and requires one. needs-triage Indicates an issue or PR lacks a `triage/foo` label and requires one. labels Aug 5, 2021
@k8s-ci-robot
Copy link
Contributor

Hi @atiratree. Thanks for your PR.

I'm waiting for a kubernetes member to verify that this patch is reasonable to test. If it is, they should reply with /ok-to-test on its own line. Until that is done, I will not automatically test new commits in this PR, but the usual testing commands by org members will still work. Regular contributors should join the org to skip this step.

Once the patch is verified, the new status will be reflected by the ok-to-test label.

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.

@k8s-ci-robot k8s-ci-robot added sig/api-machinery Categorizes an issue or PR as relevant to SIG API Machinery. needs-ok-to-test Indicates a PR that requires an org member to verify it is safe to test. needs-priority Indicates a PR lacks a `priority/foo` label and requires one. and removed do-not-merge/needs-sig Indicates an issue or PR lacks a `sig/foo` label and requires one. labels Aug 5, 2021
@atiratree
Copy link
Member Author

@zerodayz @soltysh

@caesarxuchao
Copy link
Member

/assign @caesarxuchao @soltysh

Copy link
Member

@knight42 knight42 left a comment

Choose a reason for hiding this comment

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

/ok-to-test
/lgtm

Thanks for the fix!

@k8s-ci-robot k8s-ci-robot added ok-to-test Indicates a non-member PR verified by an org member that is safe to test. and removed needs-ok-to-test Indicates a PR that requires an org member to verify it is safe to test. labels Aug 6, 2021
@k8s-ci-robot k8s-ci-robot added the lgtm "Looks good to me", indicates that a PR is ready to be merged. label Aug 6, 2021
@knight42
Copy link
Member

knight42 commented Aug 6, 2021

Copy link
Contributor

@soltysh soltysh left a comment

Choose a reason for hiding this comment

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

/lgtm
/approve
@atiratree can you open a cherry-pick against 1.22 to fix this problem since that's where the regression was introduced.

@soltysh
Copy link
Contributor

soltysh commented Aug 9, 2021

/triage accepted
/priority important-longterm

@k8s-ci-robot k8s-ci-robot added triage/accepted Indicates an issue or PR is ready to be actively worked on. priority/important-longterm Important over the long term, but may not be staffed and/or may need multiple releases to complete. and removed needs-triage Indicates an issue or PR lacks a `triage/foo` label and requires one. labels Aug 9, 2021
@k8s-ci-robot k8s-ci-robot removed the needs-priority Indicates a PR lacks a `priority/foo` label and requires one. label Aug 9, 2021
@soltysh
Copy link
Contributor

soltysh commented Aug 11, 2021

ping @caesarxuchao for approval

"when range is used in a certain way in script, additional line is printed",
`{range .items[?(.status.phase=="Running")]}{.metadata.name}{" is Running\n"}`,
"range over pods without selecting the last one",
`{range .items[?(.status.phase=="Running")]}{.metadata.name}{" is Running\n"}{end}`,
Copy link
Contributor

Choose a reason for hiding this comment

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

shouldn't we have both cases tested, ie with and without end?

Copy link
Member Author

Choose a reason for hiding this comment

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

Should we test invalid syntaxes here? What should be the behaviour?

  • the output is broken and outputs additional line (current behaviour)
  • or should we fast fail with invalid syntax error? (would require changes)

Copy link
Contributor

Choose a reason for hiding this comment

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

it was kind of graceful before to leave out the {end}, just a little wrong. Could be get it working easily too?

Copy link
Contributor

Choose a reason for hiding this comment

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

In any case, I would rather try to avoid breaking behaviour that ran without error before. Fixing it is ok, but not suddenly fail.

Copy link
Member Author

Choose a reason for hiding this comment

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

I am not sure how easy that would be.
But do we want to support an invalid syntax? I think it is a bit problematic of supporting this especially when you consider nested ranges. I would prefer an error here , but that would also break some scripts (more than keeping it failing slightly).

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 that the support for missing {end} was rather accidental than intentional. I'd prefer we stick with having code simple and complying to jsonpath standard, than over-complicated to support something not entirely correct.

Copy link
Contributor

Choose a reason for hiding this comment

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

I would prefer keeping graceful behaviour and not fix it and break users. But I am not blocking this. Both paths are acceptable.

This partially reverts commit 39cfe232325d66bcdbc935af7aaf7022562e7010and PR kubernetes#98057

the original problem was caused by not using {end} at the end of the range
@k8s-ci-robot k8s-ci-robot removed the lgtm "Looks good to me", indicates that a PR is ready to be merged. label Aug 26, 2021
@atiratree
Copy link
Member Author

just split this into two commits - one for revert and one for the extra test

@atiratree
Copy link
Member Author

ping @soltysh @caesarxuchao

Copy link
Contributor

@soltysh soltysh left a comment

Choose a reason for hiding this comment

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

/lgtm

@k8s-ci-robot k8s-ci-robot added the lgtm "Looks good to me", indicates that a PR is ready to be merged. label Aug 31, 2021
@sttts
Copy link
Contributor

sttts commented Aug 31, 2021

/approve

with #104172 (comment) in mind.

@k8s-ci-robot
Copy link
Contributor

[APPROVALNOTIFIER] This PR is APPROVED

This pull-request has been approved by: atiratree, knight42, soltysh, sttts

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

@k8s-ci-robot k8s-ci-robot added the approved Indicates a PR has been approved by an approver from all required OWNERS files. label Aug 31, 2021
@atiratree
Copy link
Member Author

the failures don't seem connected to this PR
/retest

@rtheis
Copy link

rtheis commented Aug 31, 2021

If not too much trouble, can we link this PR as the fix for #104276? Thank you.

@soltysh
Copy link
Contributor

soltysh commented Aug 31, 2021

If not too much trouble, can we link this PR as the fix for #104276? Thank you.

done

@k8s-ci-robot k8s-ci-robot merged commit db4f201 into kubernetes:master Aug 31, 2021
@k8s-ci-robot k8s-ci-robot added this to the v1.23 milestone Aug 31, 2021
k8s-ci-robot added a commit that referenced this pull request Sep 1, 2021
…04172-upstream-release-1.22

Automated cherry pick of #104172: revert "fix wrong output when using jsonpath"
@k8s-ci-robot k8s-ci-robot added release-note Denotes a PR that will be considered when it comes time to generate release notes. and removed release-note-none Denotes a PR that doesn't merit a release note. labels Sep 9, 2023
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. cncf-cla: yes Indicates the PR's author has signed the CNCF CLA. kind/bug Categorizes issue or PR as related to a bug. kind/regression Categorizes issue or PR as related to a regression from a prior release. lgtm "Looks good to me", indicates that a PR is ready to be merged. ok-to-test Indicates a non-member PR verified by an org member that is safe to test. priority/important-longterm Important over the long term, but may not be staffed and/or may need multiple releases to complete. release-note Denotes a PR that will be considered when it comes time to generate release notes. sig/api-machinery Categorizes an issue or PR as relevant to SIG API Machinery. size/XS Denotes a PR that changes 0-9 lines, ignoring generated files. triage/accepted Indicates an issue or PR is ready to be actively worked on.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

kubectl get -o jsonpath no longer continues parsing an item when a key is encountered that has no value
7 participants