Skip to content

Commit

Permalink
Fix: ensure that only servers that belong to the cluster are deleted …
Browse files Browse the repository at this point in the history
…from the project
  • Loading branch information
vitobotta committed Aug 20, 2021
1 parent 3300651 commit 36056e8
Show file tree
Hide file tree
Showing 4 changed files with 10 additions and 3 deletions.
2 changes: 1 addition & 1 deletion Gemfile.lock
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
PATH
remote: .
specs:
hetzner-k3s (0.3.7)
hetzner-k3s (0.3.8)
bcrypt_pbkdf
ed25519
http
Expand Down
3 changes: 3 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -227,6 +227,9 @@ Once the cluster is ready you can create persistent volumes out of the box with

## changelog

- 0.3.8
- Fix: added a check on a label to ensure that only servers that belong to the cluster are deleted from the project.

- 0.3.7
- Ensure that the cluster name only contains lowercase letters, digits and dashes for compatibility with the cloud controller manager

Expand Down
6 changes: 5 additions & 1 deletion lib/hetzner/k3s/cluster.rb
Original file line number Diff line number Diff line change
Expand Up @@ -501,7 +501,7 @@ def find_flannel_interface(server)
end

def all_servers
@all_servers ||= hetzner_client.get("/servers")["servers"]
@all_servers ||= hetzner_client.get("/servers")["servers"].select{ |server| belongs_to_cluster?(server) == true }
end

def masters
Expand Down Expand Up @@ -624,4 +624,8 @@ def ugrade_plan_manifest_path
temp_file_path
end

def belongs_to_cluster?(server)
server.dig("labels", "cluster") == cluster_name
end

end
2 changes: 1 addition & 1 deletion lib/hetzner/k3s/version.rb
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
module Hetzner
module K3s
VERSION = "0.3.7"
VERSION = "0.3.8"
end
end

0 comments on commit 36056e8

Please sign in to comment.