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

Hetzner: search for not_found code explicitly before returning ErrInstanceNotFound #121

Open
wants to merge 2 commits into
base: master
Choose a base branch
from

Conversation

davidhiendl
Copy link

@davidhiendl davidhiendl commented Sep 22, 2022

When a hetzner cloud instance is deleted externally (not by the autoscaler, for example via GUI/API) the autoscaler fails to correctly remove the instance. This is due to the fact that it does not return ErrInstanceNotFound but a generic one.

Example log:

{"image":"ubuntu-20.04","level":"debug","msg":"deleting instance","name":"agent-QpBgrGhL","region":"unknown","size":"cpx11","time":"2022-09-22T13:57:36Z"}
{"error":"server with ID '24078837' not found (not_found)","image":"ubuntu-20.04","level":"error","msg":"deleting instance failed","name":"agent-QpBgrGhL","region":"unknown","size":"cpx11","time":"2022-09-22T13:57:37Z"}
{"error":"server with ID '24078837' not found (not_found)","level":"error","msg":"cannot destroy server","server":"agent-QpBgrGhL","state":"error","time":"2022-09-22T13:57:37Z"}

As you can see the hetzner responsed with code=not_found but the implementation returns a generic error as indicated by the log message "cannot destroy server" (reaper.go#107)

Instead of relying on the generic error response here which seems to have changed it will now check for the string not_found in the hetzner api response and if found return ErrInstanceNotFound allowing the instance to be deleted from the autoscaler.

@davidhiendl davidhiendl changed the title search for not_found code explicitly before returning ErrInstanceNotFound Hetzner: search for not_found code explicitly before returning ErrInstanceNotFound Sep 22, 2022
@ShruthiHubb
Copy link

Hi @davidhiendl Thanks for sending the proposal we appreciate it 🚀

We usually review PRs every Tuesday but I will keep you up to date if anything changes.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants