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 606eb97
Showing 1 changed file with 24 additions and 2 deletions.
26 changes: 24 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 @@ -40,6 +40,28 @@ def node_info(node, ca_minion):
if node["metadata"]["name"] == ca_minion:
roles.add("ca")

# Introduced by https://scality.atlassian.net/browse/ARTESCA-10079
# 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 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

result["roles"] = list(roles)

return result
Expand Down Expand Up @@ -152,7 +174,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 606eb97

Please sign in to comment.