gambol99 / go-marathon

A GO API library for working with Marathon
Apache License 2.0
199 stars 128 forks source link

DeleteApplication fails with "Marathon API Error: " #268

Closed iderdik closed 6 years ago

iderdik commented 7 years ago

I seem to have this intermittent issue where calling DeleteApplication fails with the error "Marathon API error: " and no additional info. Nothing appears in the Marathon logs.

I'm using Marathon 1.3.0 and Mesos 1.0.1.

Have you encountered this issue at all?

timoreimann commented 7 years ago

Thanks for the report @iderdik.

The problem is that the error message cannot be parsed anymore. I suppose that Mesosphere has changed the structure of the error JSON response (once again).

Do you have a chance to initialize your go-marathon client with the LogOutput parameter set to os.Stdout? That way, we should see the response body.

iderdik commented 7 years ago

@timoreimann I can't get that level of detail turned on in the system I'm seing this with. However, combing through Marathon logs, I do see the DELETE calling returning a 405 error if that helps.

iderdik commented 7 years ago

And I've actually figured the error out (I think). When we inadvertently send a blank Marathon app name to DeleteApplication (due to a logic error on my side), this error occurs (with the blank message). Better error handling/condition checking would definitely help here - I'll try to open a PR if I have some time.

If anyone else needs it, the offending line is: https://github.com/gambol99/go-marathon/blob/7d0d658a97e71947a2e10b136c17c26d688d337e/application.go#L759

Restart seems to have a similar issue but I haven't encountered it in practice.

timoreimann commented 7 years ago

Thanks for investigating.

The problem is that we currently do not decode 405s. The fix is to unmarshal such errors into a dedicated type.

Additionally, we should fall back to showing just the pure JSON content if we can't map the error any better.