-
Notifications
You must be signed in to change notification settings - Fork 582
provide suggestion if xpc 'Connection invalid' error encountered #179
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
provide suggestion if xpc 'Connection invalid' error encountered #179
Conversation
c555a01 to
2ed799b
Compare
adityaramani
left a comment
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.
Thanks for the PR! Im trying to think about this a little bit.
I think I'd like it better if this check happens somewhere in the CLI - im not sure where the right place to put it in is (in a way that we dont need to update every command). Maybe ArgumentParser - the library we use to write the CLI has an exit hook?
The reason for this is that XPCClient in theory is a (mostly) generic XPC client type and could be used for other services that may uses a different bootstrap pattern.
What are your thoughts on this?
|
My thought was to emulate a similar UX to the Docker client since it's the dominant container platform as highlighted here: #80 (comment) Honestly, I'm not super concerned about where it's at. I think it makes sense to have on every command where the XPC client fails to connect -- as that's a fatal error. Regardless, I'm happy to rework it however is most desired -- let me know what you'd prefer and I'll do it. 😄 |
|
Yes totally agree about having the check there - just that I think its better if its somewhere in the CLI. Let me look a bit more to see if there is an easy way to add it. This will also allow others to share their thoughts |
|
I'll spend some time reworking it into the CLI as you suggested and see what I can come up with. Likely will get around to it tomorrow! 😄 |
|
Went through the code a bit - I think we can perform that check here? https://github.com/apple/container/blob/main/Sources/CLI/Application.swift#L179 And it should account for all the commands we have? |
2ed799b to
f6ce132
Compare
|
Latest iteration of my PR, the error-handling looks like this: Please let me know if you have any further feedback on wording, etc. 😄 Sorry for taking a while to get around to this! |
adityaramani
left a comment
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.
Thanks! I like this better!
Its unfortunate that we need to use String(describing: error) and check the string - but I dont think there is a better way.
We cant solely use the error codes / cause of the error in ContainerizationError cause they may not give a match all the time
Sources/CLI/Application.swift
Outdated
| let modifiedErrorDescription = "\(error)\nEnsure container system has been started with `container system start`." | ||
| let modifiedError = NSError(domain: "", code: 1, userInfo: [NSLocalizedDescriptionKey: modifiedErrorDescription]) | ||
| Application.exit(withError: modifiedError) |
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 switch this to be ContainerizationError over NSError? Or Did you see that using NSError was causing the exit() to print the message better?
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.
Done in latest rev!
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.
However, is there a way with a ContainerizationError to remove the quotes at the beginning and end of the error output?
❯ ./bin/container list
Warning! Running debug build. Performance may be degraded.
Error: internalError: "internalError: "failed to list containers" (cause: "interrupted: "XPC connection error: Connection invalid"")
Ensure container system service has been started with `container system start`."
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.
Also, noticed in my output that internalError is repeated twice. Is there a more generic ContainerizationError type that is not .internalError that I could use?
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 do have .interrupted which may make sense? or .invalidState ?
I need to check if we can do something about the quotes
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.
Interrupted looks good to me!
❯ ./bin/container list
Warning! Running debug build. Performance may be degraded.
Error: interrupted: "internalError: "failed to list containers" (cause: "interrupted: "XPC connection error: Connection invalid"")
Ensure container system service has been started with `container system start`."
ff5108e to
f81f3af
Compare
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.
Thanks! LGTM! Will wait for the others to look if we want to change the wordings.
You just need to run make fmt and re-push
f81f3af to
b53f0ad
Compare
|
@katiewasnothere I forgot to run |
Closes #80
Adds the following help message if you try to run
containeragainst a host that hasn't started the container system: