You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: pkg/resourceinterpreter/default/thirdparty/resourcecustomizations/flink.apache.org/v1beta1/FlinkDeployment/customizations.yaml
+53-23Lines changed: 53 additions & 23 deletions
Original file line number
Diff line number
Diff line change
@@ -33,43 +33,71 @@ spec:
33
33
return observedObj.status.error ~= nil
34
34
end
35
35
componentResource:
36
-
luaScript: >
36
+
luaScript: |
37
37
local kube = require("kube")
38
38
39
39
local function isempty(s)
40
40
return s == nil or s == ''
41
41
end
42
42
43
-
local function qty(v)
44
-
if v == nil then return nil end
45
-
return kube.getResourceQuantity(v)
46
-
end
47
-
48
43
-- Safe fetch of deeply nested table fields.
49
44
local function get(obj, path)
50
45
local cur = obj
51
46
for i = 1, #path do
52
-
if cur == nil then return nil end
47
+
if cur == nil then
48
+
return nil
49
+
end
53
50
cur = cur[path[i]]
54
51
end
55
52
return cur
56
53
end
57
54
58
55
-- Normalize possibly-string numbers with a default.
59
56
local function to_num(v, default)
60
-
if v == nil or v == '' then return default end
57
+
if v == nil or v == '' then
58
+
return default
59
+
end
61
60
local n = tonumber(v)
62
-
return n ~= nil and n or default
61
+
if n ~= nil then
62
+
return n
63
+
end
64
+
return default
65
+
end
66
+
67
+
-- JSON-safe deep clone: strings/numbers/booleans/tables. Needed to prevent shared table references.
68
+
local function clone_plain(val, seen)
69
+
local tv = type(val)
70
+
if tv ~= "table" then
71
+
if tv == "string" or tv == "number" or tv == "boolean" or tv == "nil" then
72
+
return val
73
+
end
74
+
return nil
75
+
end
76
+
seen = seen or {}
77
+
if seen[val] then return nil end
78
+
seen[val] = true
79
+
local out = {}
80
+
for k, v in pairs(val) do
81
+
local tk = type(k)
82
+
if tk == "string" or tk == "number" then
83
+
local cv = clone_plain(v, seen)
84
+
if cv ~= nil then out[k] = cv end
85
+
end
86
+
end
87
+
seen[val] = nil
88
+
return out
63
89
end
64
90
65
91
local function apply_pod_template(pt_spec, requires)
66
-
if pt_spec == nil then return end
92
+
if pt_spec == nil then
93
+
return
94
+
end
67
95
68
-
local nodeSelector = pt_spec.nodeSelector
69
-
local tolerations = pt_spec.tolerations
96
+
local nodeSelector = clone_plain(pt_spec.nodeSelector)
97
+
local tolerations = clone_plain(pt_spec.tolerations)
70
98
local priority = pt_spec.priorityClassName
71
99
72
-
-- Only create nodeClaim if there’s content
100
+
-- Only create nodeClaim if there is content
73
101
if nodeSelector ~= nil or tolerations ~= nil then
74
102
requires.nodeClaim = requires.nodeClaim or {}
75
103
requires.nodeClaim.nodeSelector = nodeSelector
@@ -85,27 +113,29 @@ spec:
85
113
local components = {}
86
114
local pt_spec = get(observedObj, {"spec","podTemplate","spec"})
87
115
88
-
-- ===== JobManager =====
116
+
-- JobManager
117
+
89
118
local jm_replicas = to_num(get(observedObj, {"spec","jobManager","replicas"}), 1)
90
119
91
120
local jm_requires = {
92
-
resourceRequest = {},
121
+
resourceRequest = {}
93
122
}
94
123
95
124
local jm_cpu = get(observedObj, {"spec","jobManager","resource","cpu"})
96
125
local jm_memory = get(observedObj, {"spec","jobManager","resource","memory"})
0 commit comments