headscale icon indicating copy to clipboard operation
headscale copied to clipboard

Make server errors exported

Open GrigoriyMikhalkin opened this issue 1 year ago • 4 comments

There's a bunch of errors that headscale server can return. For example "Namespace already exists". Would it be desirable to export them?

Specifically i would find it useful as i use headscale as a lib to create a built-in client in a service. And there i want to check returned errors.

GrigoriyMikhalkin avatar Jul 25 '22 21:07 GrigoriyMikhalkin

@GrigoriyMikhalkin happy to merge a PR doing this :)

Btw, out of pure curiosity, what is the use case?

juanfont avatar Jul 28 '22 21:07 juanfont

@juanfont I'm trying to implement VPN connection for machines provided by metal-stack(which is MaaS platform basically). Headscale is deployed to serve as a control-plane. And then we have metal-api service, which is basically middleware that organizes deployment of bare metal machines. metal-api also should be able to manage VPNs and connect these machines to it. For that metal-api uses headscale as a lib to connect remotely to Headscale installation and manage namespaces/auth keys.

Regarding exporting errors. Here i'm trying to catch the Namespace already exists error.

It actually could be solved in another way(additional request to get all namespaces and try to find the one that's expected), but it just doesn't feel as an elegant solution.

I was thinking about using GetNamespace method, but it also returns an error which is not exported.

GrigoriyMikhalkin avatar Jul 28 '22 21:07 GrigoriyMikhalkin

Happy to get all the errors exported. Can you prepare a PR?

On Thu, 28 Jul 2022 at 23:46, GrigoriyMikhalkin @.***> wrote:

@juanfont https://github.com/juanfont Here https://github.com/metal-stack/metal-api/pull/308/files#diff-e3be14987652bb48dcefbab95f677cfd5db025653af59c036ffdad1bb5d1f898R252 i'm trying to catch the Namespace already exists error.

It actually could be solved in another way(additional request to get all namespaces and try to find the one that's expected), but it just doesn't feel as an elegant solution.

I was thinking about using GetNamespace method, but it also returns an error which is not exported.

— Reply to this email directly, view it on GitHub https://github.com/juanfont/headscale/issues/690#issuecomment-1198664382, or unsubscribe https://github.com/notifications/unsubscribe-auth/AABMGQZYEGONYLFD7BEVZUTVWL5UFANCNFSM54TYVXYQ . You are receiving this because you were mentioned.Message ID: @.***>

juanfont avatar Jul 28 '22 22:07 juanfont

@juanfont Yep, sure!

GrigoriyMikhalkin avatar Jul 28 '22 22:07 GrigoriyMikhalkin

Fixed :)

juanfont avatar Aug 11 '22 08:08 juanfont