@@ -18,7 +18,9 @@ require "yaml"
1818
1919template = File .read(" .controlplane/templates/node-renderer.yml" )
2020rendered = template.gsub (/\{\{ [A-Z_] +\}\} / , " template-placeholder" )
21- container = YAML .safe_load(rendered).fetch(" spec" ).fetch(" containers" ).fetch(0 )
21+ workload = YAML .safe_load(rendered)
22+ spec = workload.fetch(" spec" )
23+ container = spec.fetch(" containers" ).fetch(0 )
2224
2325expected_args = [
2426 " bash" ,
@@ -32,6 +34,10 @@ expected_args = [
3234 SHELL
3335]
3436expected_ports = [{ " number" => 3800 , " protocol" => " http2" }]
37+ expected_env = [
38+ { " name" => " LOG_LEVEL" , " value" => " info" },
39+ { " name" => " NODE_OPTIONS" , " value" => " --max-old-space-size=256" },
40+ ]
3541expected_readiness_probe = {
3642 " tcpSocket" => { " port" => 3800 },
3743 " failureThreshold" => 3 ,
@@ -43,18 +49,52 @@ expected_liveness_probe = {
4349 " periodSeconds" => 10 ,
4450 " initialDelaySeconds" => 120 ,
4551}
52+ expected_default_options = {
53+ " autoscaling" => { " maxScale" => 1 },
54+ " capacityAI" => true ,
55+ }
56+ expected_firewall_config = {
57+ " external" => {
58+ " inboundAllowCIDR" => [],
59+ " outboundAllowCIDR" => [" 0.0.0.0/0" ],
60+ },
61+ " internal" => { " inboundAllowType" => " same-gvc" },
62+ }
4663
4764failures = []
65+ failures << " workload keys changed" unless workload.keys.sort == %w[kind name spec]
66+ failures << " workload identity changed" unless workload.values_at(" kind" , " name" ) == %w[workload node-renderer]
67+ failures << " spec keys changed" unless spec.keys.sort == %w[containers defaultOptions firewallConfig identityLink type]
68+ failures << " workload type changed" unless spec.fetch(" type" ) == " standard"
69+ failures << " container keys changed" unless container.keys.sort ==
70+ %w[args cpu env image inheritEnv livenessProbe memory name ports readinessProbe]
4871failures << " unsupported startupProbe is present" if container.key?(" startupProbe" )
4972failures << " command changed" if container.key?(" command" )
73+ failures << " renderer name changed" unless container.fetch(" name" ) == " node-renderer"
74+ failures << " renderer CPU changed" unless container.fetch(" cpu" ) == " 100m"
75+ failures << " renderer memory changed" unless container.fetch(" memory" ) == " 512Mi"
76+ failures << " renderer environment changed" unless container.fetch(" env" ) == expected_env
77+ failures << " environment inheritance changed" unless container.fetch(" inheritEnv" ) == true
5078failures << " args changed" unless container.fetch(" args" ) == expected_args
5179failures << " image changed" unless container.fetch(" image" ) == " template-placeholder"
5280failures << " ports changed" unless container.fetch(" ports" ) == expected_ports
5381failures << " readinessProbe changed" unless container.fetch(" readinessProbe" ) == expected_readiness_probe
5482failures << " livenessProbe grace or thresholds changed" unless container.fetch(" livenessProbe" ) == expected_liveness_probe
83+ failures << " default autoscaling or capacityAI changed" unless spec.fetch(" defaultOptions" ) == expected_default_options
84+ failures << " firewall configuration changed" unless spec.fetch(" firewallConfig" ) == expected_firewall_config
85+ failures << " identity link changed" unless spec.fetch(" identityLink" ) == " template-placeholder"
86+
87+ cpu_match = /\A (?<millicores>\d +) m\z / .match(container.fetch(" cpu" ).to_s)
88+ memory_match = /\A (?<mebibytes>\d +) Mi\z / .match(container.fetch(" memory" ).to_s)
89+ if cpu_match && memory_match && cpu_match[:millicores ].to_i.positive?
90+ resource_ratio = memory_match[:mebibytes ].to_f / cpu_match[:millicores ].to_i
91+ failures << format (" provider resource ratio must be strictly below 8 (got %.2f)" , resource_ratio) unless resource_ratio < 8
92+ else
93+ failures << " renderer resources must use positive millicore CPU and MiB memory units"
94+ end
5595
5696abort failures.join(" \n " ) unless failures.empty?
57- puts " node renderer template preserves supported probe grace and stable runtime settings"
97+ puts " node renderer template preserves provider resource ratio, supported probe grace, and stable runtime settings"
5898RUBY
5999
60100echo " ==> parse generated GitHub Actions YAML"
0 commit comments