Installer: Handle VM uninstall before it has had a time to boot
Change-Id: I615bc949b5054b301899b1e0b7eae94a98126e61
diff --git a/core/headscale/client.go b/core/headscale/client.go
index 159fffb..f4d0f51 100644
--- a/core/headscale/client.go
+++ b/core/headscale/client.go
@@ -111,7 +111,7 @@
return strconv.Itoa(n.Id), nil
}
}
- return "", fmt.Errorf("not found")
+ return "", ErrorNotFound
}
func (c *client) getNodeAddresses(user, node string) ([]net.IP, error) {
diff --git a/core/headscale/main.go b/core/headscale/main.go
index 194da06..c2cfcf5 100644
--- a/core/headscale/main.go
+++ b/core/headscale/main.go
@@ -167,7 +167,11 @@
return
}
if err := s.client.expirePreAuthKey(user, req.AuthKey); err != nil {
- http.Error(w, err.Error(), http.StatusInternalServerError)
+ if errors.Is(err, ErrorNotFound) {
+ http.Error(w, err.Error(), http.StatusNotFound)
+ } else {
+ http.Error(w, err.Error(), http.StatusInternalServerError)
+ }
return
}
}
@@ -185,8 +189,11 @@
return
}
if err := s.client.expireUserNode(user, node); err != nil {
- fmt.Println(err)
- http.Error(w, err.Error(), http.StatusInternalServerError)
+ if errors.Is(err, ErrorNotFound) {
+ http.Error(w, err.Error(), http.StatusNotFound)
+ } else {
+ http.Error(w, err.Error(), http.StatusInternalServerError)
+ }
return
}
}
@@ -203,7 +210,11 @@
return
}
if err := s.client.removeUserNode(user, node); err != nil {
- http.Error(w, err.Error(), http.StatusInternalServerError)
+ if errors.Is(err, ErrorNotFound) {
+ http.Error(w, err.Error(), http.StatusNotFound)
+ } else {
+ http.Error(w, err.Error(), http.StatusInternalServerError)
+ }
return
}
}