-
Notifications
You must be signed in to change notification settings - Fork 38.6k
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
Kubectl convert - warn users with NotRegisteredError and Fail on all other errors #117002
Kubectl convert - warn users with NotRegisteredError and Fail on all other errors #117002
Conversation
Please note that we're already in Test Freeze for the Fast forwards are scheduled to happen every 6 hours, whereas the most recent run was: Wed Mar 29 22:31:15 UTC 2023. |
This issue is currently awaiting triage. If a SIG or subproject determines this is a relevant issue, they will accept it by applying the The 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. |
Hi @gxwilkerson33. 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 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. |
/cc @eddiezane |
/ok-to-test |
pkg/kubectl/cmd/convert/convert.go
Outdated
return nil, err | ||
//Dont fail on error converting objects. | ||
//Simply warn the user with the error returned from api-machinery and continue with the rest of the file | ||
fmt.Fprintln(os.Stderr, err.Error()) |
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 think, type of error matters. Perhaps we can only continue if the error is notfound error?
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.
@ardaguclu yep. i think you are right. i will update this PR with that. Thanks
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.
Instead of using os.Stderr
directly we should plumb through the IOStreams.
…user instead of stdError
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 looking good but I'm not sure what the expected behavior should be.
Right now the output for multiple resources is wrapped in a v1 List.
apiVersion: v1
kind: List
metadata: {}
items:
- apiVersion: v1
kind: Service
...
This is valid but IMO unexpected. I think users would want to pipe the output to a file with only the conversions done with a clean diff. i.e. kubectl convert -f my-old-network.yaml > my-new-network.yaml
.
@ardaguclu @soltysh what do you think?
apiVersion: v1 | ||
kind: Service | ||
metadata: | ||
name: TestClusterIP |
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.
nit: this should be a vaild DNS-1035 value.
test-cluster-ip
apiVersion: extensions/v1beta1 | ||
kind: Ingress | ||
metadata: | ||
name: testIngress |
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.
nit: same as above. No capitals.
pkg/kubectl/cmd/convert/convert.go
Outdated
@@ -263,6 +263,14 @@ func asVersionedObjects(infos []*resource.Info, specifiedOutputVersion schema.Gr | |||
|
|||
converted, err := tryConvert(scheme.Scheme, info.Object, targetVersions...) | |||
if err != nil { | |||
//Dont fail on not registered error converting objects. |
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.
nit: these comments should have a space.
//Dont fail on not registered error converting objects. | |
// Dont fail on not registered error converting objects. |
To clarify are you meaning not returning a list but instead returning the resources indiviually in the file?
Ill wait for clarification on this to push again. Thanks |
I think we can discard the ones not supported(we will already show a warning to user about they will be skipped), List will only contain the ones supported. |
/retest |
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 think we can discard the ones not supported(we will already show a warning to user about they will be skipped), List will only contain the ones supported.
It looks like the current behavior is for multiple entries to be wrapped in a v1 List regardless. That's not what I would expect when using this tool but I am ok with it.
@gxwilkerson33 thanks for this PR! It will merge in a week or so after thaw.
/approve
/lgtm
LGTM label has been added. Git tree hash: cb2f6df06e748464d433913ba801680110d08d2c
|
[APPROVALNOTIFIER] This PR is APPROVED This pull-request has been approved by: eddiezane, gxwilkerson33 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 |
/retest |
1 similar comment
/retest |
…other errors (kubernetes#117002) * Convert file but warn user with impossible conversions * Only continuing for NotRegisteredErrors. Using iostreams for warning user instead of stdError * Formatting, correct tests to use valid DNS-1035.
…other errors (kubernetes#117002) * Convert file but warn user with impossible conversions * Only continuing for NotRegisteredErrors. Using iostreams for warning user instead of stdError * Formatting, correct tests to use valid DNS-1035.
What type of PR is this?
/kind bug
What this PR does / why we need it:
This PR solves issue of kubectl-convert failing when resources cannot be converted to desired output version. The solution is to warn the user and continue converting the rest of the file.
Which issue(s) this PR fixes:
Fixes kubernetes/kubectl#1383
Special notes for your reviewer:
Does this PR introduce a user-facing change? No
Additional documentation e.g., KEPs (Kubernetes Enhancement Proposals), usage docs, etc.: