Skip to content

Commit

Permalink
Fix Autoscaling for worker nodes with invalid ProviderID
Browse files Browse the repository at this point in the history
This change fixes a bug that arises when the user's cluster includes worker nodes not from Hetzner Cloud, such as a Hetzner Dedicated server or any server resource other than Hetzner. It also corrects the behavior when a server has been physically deleted from Hetzner Cloud.

Signed-off-by: Maksim Paskal <[email protected]>
  • Loading branch information
maksim-paskal committed Apr 16, 2024
1 parent 59882e0 commit 4aa2c83
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,6 @@ package hetzner

import (
"context"
"errors"
"strconv"
"sync"
"time"
Expand Down Expand Up @@ -136,7 +135,8 @@ func (m *serversCache) getServer(nodeIdOrName string) (*hcloud.Server, error) {
}
}

return nil, errors.New("server not found")
// return nil if server not found
return nil, nil
}

func (m *serversCache) getServersByNodeGroupName(nodeGroup string) ([]*hcloud.Server, error) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -70,6 +70,7 @@ func TestServersCache(t *testing.T) {
require.NoError(t, err)
assert.Equal(t, "test2", foundservers.Name)

_, err = c.getServer("test3")
require.Error(t, err)
server, err := c.getServer("test3")
require.Nil(t, server)
require.NoError(t, err)
}

0 comments on commit 4aa2c83

Please sign in to comment.