@@ -16,7 +16,19 @@ def get_limits() -> Dict[str, Dict[str, str]]:
1616 Until OCI has an API to fetch service limits, we have to hard-code
1717 them in a file.
1818 """
19- return load_yaml ("/home/opc/limits.yaml" )
19+ limits = load_yaml ("/home/opc/limits.yaml" )
20+ for mappings in limits .values ():
21+ if not isinstance (mappings , dict ):
22+ raise SyntaxError
23+ for ad , count in mappings .items ():
24+ if not isinstance (ad , int ):
25+ raise SyntaxError
26+ if not isinstance (count , int ):
27+ raise SyntaxError
28+ for shape in limits :
29+ if not re .match (r"" , shape ):
30+ raise ValueError
31+ return limits
2032
2133
2234def get_shapes () -> Dict [str , Dict [str , str ]]:
@@ -64,7 +76,12 @@ def get_node_configs(limits, shapes, mgmt_info):
6476
6577 slurm_conf_filename = "/mnt/shared/etc/slurm/slurm.conf"
6678
67- node_config = "\n " .join (get_node_configs (get_limits (), get_shapes (), get_mgmt_info ()))
79+ try :
80+ limits = get_limits ()
81+ except SyntaxError :
82+ print ("ERROR: Syntax error in `limits.yaml`." )
83+ exit (1 )
84+ node_config = "\n " .join (get_node_configs (limits , get_shapes (), get_mgmt_info ()))
6885
6986 chop = re .compile ('(?<=# STARTNODES\n )(.*?)(?=\n ?# ENDNODES)' , re .DOTALL )
7087
0 commit comments