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

Improve error output of kubectl update #9803

Merged
merged 1 commit into from Jun 18, 2015

Conversation

satnam6502
Copy link
Contributor

This PR addresses issue #9721 to improve theerror output of kubectl update.
NewCmdUpdate is changed to used a modified version of CheckErr called CheckCustomErr which can accept a custom error prefix message. Unfortunately, the text segment we want to report ("may not update fields other than container.image") which is originally stored in a separate field is unfortunately conflated with a larger text message that includes details of the spec being updated. To avoid making significant changes to the error types used in the code base I decided to do the horrible but expedient thing: extract out the required string by looking for text after "}': ". Now the error message is:

$ kubectl update -f counter-pod.yaml 
Update failed: may not update fields other than container.image

which is exactly what @erictune requested.

@satnam6502 satnam6502 force-pushed the execessive branch 2 times, most recently from 0638563 to e0e4d03 Compare June 15, 2015 17:27
@k8s-bot
Copy link

k8s-bot commented Jun 15, 2015

GCE e2e build/test failed for commit e0e4d035f97a105d7e9bfe71b2dc2e027e3412d1.

@k8s-bot
Copy link

k8s-bot commented Jun 15, 2015

GCE e2e build/test passed for commit 14052c06f63a0e8a09edfad724a2e958311c220c.

// a sperate field ends up being concatentated into one string which contains
// the spec and the detail string. To avoid significant refactoring of the error
// data structures we just extract the required detail string by looking for it
// after "}': " which is horrible but expedient.
Copy link
Member

Choose a reason for hiding this comment

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

TODO: We should create an error struct with information embedded in fields, not in a string.
(or touch on how this should be fixed up after v1)

@mikedanese
Copy link
Member

I'm okay with this if it's important to get a quick fix in for v1 (but please add a TODO to cleanup). What I don't like:

  • I think this hides the path to the object file, so if I kubectl update -f a directory, I'll get a list of Update failed errors without any indicator of where they came from.
  • We should try to refactor kubectl errors to meaningful structs rather than doing string parsing to extract fields.

@satnam6502
Copy link
Contributor Author

Indeed, the objective is to do a quick fix because right now because I think improving the user experience is fairly important and I think many users are likely to encounter this error message. I will add a TODO here but I am not sure if this is really where the TODO belongs since it's not this code that we mostly need to return later to fix up -- it's the error types that need to be worked and and that is a pretty big change (which we could do now -- but the effort/reward does not seem worth it right now).

@mikedanese
Copy link
Member

Sure. Don't worry about the TODO. Maybe track what we want in an issue?

@mikedanese
Copy link
Member

LGTM

@mikedanese mikedanese added the lgtm "Looks good to me", indicates that a PR is ready to be merged. label Jun 17, 2015
@saad-ali
Copy link
Member

@k8s-bot ok to test

@saad-ali
Copy link
Member

@satnam6502 can you rebase and push again, and see if that kicks k8s-bot

@k8s-bot
Copy link

k8s-bot commented Jun 17, 2015

GCE e2e build/test passed for commit e0e4d035f97a105d7e9bfe71b2dc2e027e3412d1.

@satnam6502
Copy link
Contributor Author

Rebased, pushed.

@k8s-bot
Copy link

k8s-bot commented Jun 17, 2015

GCE e2e build/test passed for commit 445f1113f37d048828f3adcb00999b4f9220a480.

@k8s-bot
Copy link

k8s-bot commented Jun 17, 2015

GCE e2e build/test failed for commit d69e0b5.

@saad-ali
Copy link
Member

@k8s-bot retest this please

@k8s-bot
Copy link

k8s-bot commented Jun 18, 2015

GCE e2e build/test passed for commit d69e0b5.

satnam6502 added a commit that referenced this pull request Jun 18, 2015
Improve error output of kubectl update
@satnam6502 satnam6502 merged commit 3505fb4 into kubernetes:master Jun 18, 2015
@caesarxuchao
Copy link
Member

cc @nikhiljindal

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
lgtm "Looks good to me", indicates that a PR is ready to be merged.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

6 participants