Skip to content
This repository has been archived by the owner on Jun 6, 2024. It is now read-only.

Commit

Permalink
fix
Browse files Browse the repository at this point in the history
  • Loading branch information
suiguoxin committed Dec 21, 2020
1 parent c713c48 commit 1e6fbef
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 3 deletions.
1 change: 0 additions & 1 deletion contrib/kubespray/script/pre-check-generator.py
Original file line number Diff line number Diff line change
Expand Up @@ -76,7 +76,6 @@ def main():

# fill in cpu, memory, computing_device information in both masters and workers
# we assume the layout file the user gives is correct
# TO DO: check layout file before this step
all_machines = masters + workers
for machine in all_machines:
sku_info = layout['machine-sku'][machine['machine-type']]
Expand Down
9 changes: 7 additions & 2 deletions contrib/kubespray/script/validate_layout_schema.py
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,8 @@ def validate_layout_schema(layout):
},
'machine-list': [
{
'hostname': str,
# https://github.com/kubernetes-sigs/kubespray/blob/release-2.11/roles/kubernetes/preinstall/tasks/0020-verify-settings.yml#L124
'hostname': Regex(r"^[a-z0-9]([-a-z0-9]*[a-z0-9])?(\.[a-z0-9]([-a-z0-9]*[a-z0-9])?)*$"),
'hostip': Regex(r"^\d{1,3}\.\d{1,3}\.\d{1,3}\.\d{1,3}$"),
'machine-type': str,
Optional('pai-master'): Or('true', 'false'),
Expand Down Expand Up @@ -78,14 +79,18 @@ def check_layout(layout):
return False

masters = list(filter(lambda elem: 'pai-master' in elem and elem["pai-master"] == 'true', layout['machine-list']))
workers = list(filter(lambda elem: 'pai-worker' in elem and elem["pai-worker"] == 'true', layout['machine-list']))
# only one pai-master
if len(masters) == 0:
logger.error('No master machine specified.')
return False
if len(masters) > 1:
logger.error('More than one master machine specified.')
return False

# at least one pai-worker
if len(workers) == 0:
logger.error('No worker machine specified.')
return False
# pai-master / pai-worker cannot be true at the same time
if 'pai-worker' in masters[0] and masters[0]['pai-worker'] == 'true':
logger.error("One machine can not be pai-master and pai-worker at the same time.")
Expand Down

0 comments on commit 1e6fbef

Please sign in to comment.