Skip to content

Commit

Permalink
ARTESCA-10079 force bootstrap bundle roles on ext pillar
Browse files Browse the repository at this point in the history
  • Loading branch information
aprucolimartins committed Nov 10, 2023
1 parent c19a4e6 commit 8d43624
Showing 1 changed file with 23 additions and 2 deletions.
25 changes: 23 additions & 2 deletions salt/_pillar/metalk8s_nodes.py
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ def __virtual__():
return __virtualname__


def node_info(node, ca_minion):
def node_info(node, ca_minion, pillar):
result = {
"roles": [],
"version": None,
Expand All @@ -37,6 +37,27 @@ def node_info(node, ca_minion):
if role:
roles.add(role)

# Introduced as a workaround in cases which bootstrap setup fails after the
# kubernetes API server is up and running but node role labels are still
# not set.
#
# The issue is that when the API server is running the ext_pillar will
# overwrite the hardcoded roles with the ones from the API. It will cause
# bootstrap setup failure as described here:
# https://github.com/scality/metalk8s/issues/2137
#
# The `is_bootstrap` flag is set in pillar only when run the
# `metalk8s.orchestrate.bootstrap` state.
if not roles and pillar.get("is_bootstrap", False):
log.debug(
"Workaround: Adding bootstrap roles to pillar for node %s",
node["metadata"]["name"],
)
roles.add("bootstrap")
roles.add("master")
roles.add("etcd")
# End of workaround

if node["metadata"]["name"] == ca_minion:
roles.add("ca")

Expand Down Expand Up @@ -152,7 +173,7 @@ def ext_pillar(minion_id, pillar, kubeconfig):
else:
log.debug("Successfully retrieved nodes for ext_pillar")
pillar_nodes = dict(
(node["metadata"]["name"], node_info(node, ca_minion))
(node["metadata"]["name"], node_info(node, ca_minion, pillar))
for node in node_list
)

Expand Down

0 comments on commit 8d43624

Please sign in to comment.