Skip to content

Commit

Permalink
salt: fix unsafe approach for etcd `initial-cluster-state
Browse files Browse the repository at this point in the history
Initially, we set etcd cluster state to new when the member
list from the pillars is empty.

This approach is not optimal since if for what ever reason we are
not able to retrieve the list.

Now, we raise an error when setting the cluster state to `existing`
if we are unable to obtain a list of members.
Also, we only set to `new` state only during a bootstrap.
  • Loading branch information
Ebaneck committed Jan 21, 2020
1 parent 33eafc2 commit ef8d1a1
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 2 deletions.
8 changes: 6 additions & 2 deletions salt/metalk8s/kubernetes/etcd/installed.sls
Original file line number Diff line number Diff line change
Expand Up @@ -12,8 +12,12 @@ include:
{#- Get the list of existing etcd member. #}
{%- set etcd_members = pillar.metalk8s.etcd.members %}
{#- Compute the initial state according to the existing list of node. #}
{%- set state = "existing" if etcd_members else "new" %}
{%- if pillar.is_bootstrap %}
{%- set state = 'new' %}
{%- else %}
{%- set state = 'existing' if etcd_members else
raise ('etcd member list cannot be empty for existing state') %}
{%- endif %}
{%- set etcd_endpoints = {} %}
{#- NOTE: Filter out members with empty name as they are not started yet. #}
Expand Down
1 change: 1 addition & 0 deletions salt/metalk8s/orchestrate/bootstrap/init.sls
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@

{%- set pillar_data = {
'bootstrap_id': pillar.bootstrap_id,
'is_bootstrap': True,
'metalk8s': {
'nodes': {
pillar.bootstrap_id: {
Expand Down

0 comments on commit ef8d1a1

Please sign in to comment.