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
if observedObj.status.state.phase == nil or observedObj.status.state.phase == '' or observedObj.status.state.phase == 'Failed' or observedObj.status.state.phase == 'Terminated' or observedObj.status.state.phase == 'Terminating' then
23
+
return false
24
+
end
25
+
return true
26
+
end
27
+
componentResource:
28
+
luaScript: |
29
+
local kube = require("kube")
30
+
local function isempty(s)
31
+
return s == nil or s == ''
32
+
end
33
+
34
+
local function get(obj, path)
35
+
local cur = obj
36
+
for i = 1, #path do
37
+
if cur == nil then return nil end
38
+
cur = cur[path[i]]
39
+
end
40
+
return cur
41
+
end
42
+
43
+
local function clone_plain(val, seen)
44
+
local tv = type(val)
45
+
if tv ~= "table" then return val end
46
+
seen = seen or {}
47
+
if seen[val] then return nil end
48
+
seen[val] = true
49
+
local out = {}
50
+
for k, v in pairs(val) do
51
+
local tk = type(k)
52
+
if tk == "string" or tk == "number" then
53
+
local cv = clone_plain(v, seen)
54
+
if cv ~= nil then out[k] = cv end
55
+
end
56
+
end
57
+
seen[val] = nil
58
+
return out
59
+
end
60
+
61
+
local function apply_pod_template(pt_spec, requires)
62
+
if pt_spec == nil then return end
63
+
local nodeSelector = clone_plain(pt_spec.nodeSelector)
64
+
local tolerations = clone_plain(pt_spec.tolerations)
65
+
local priority = pt_spec.priorityClassName
66
+
67
+
if nodeSelector ~= nil or tolerations ~= nil then
68
+
requires.nodeClaim = requires.nodeClaim or {}
69
+
requires.nodeClaim.nodeSelector = nodeSelector
70
+
requires.nodeClaim.tolerations = tolerations
71
+
end
72
+
73
+
if not isempty(priority) then
74
+
requires.priorityClassName = priority
75
+
end
76
+
end
77
+
78
+
local function to_num(v, default)
79
+
if v == nil or v == '' then
80
+
return default
81
+
end
82
+
local n = tonumber(v)
83
+
if n ~= nil then return n end
84
+
return default
85
+
end
86
+
87
+
function GetComponents(observedObj)
88
+
local components = {}
89
+
90
+
local tasks = get(observedObj, {"spec","tasks"})
91
+
if tasks == nil then
92
+
return components
93
+
end
94
+
95
+
for _, task in ipairs(tasks) do
96
+
local pt_spec = get(task, {"template","spec"}) or {}
97
+
98
+
local replicas = to_num(task.minAvailable, 1)
99
+
100
+
local requires = { resourceRequest = {} }
101
+
local containers = get(task, {"template", "spec", "containers"})
102
+
if containers ~= nil then
103
+
for _, container in ipairs(containers) do
104
+
if container.resources and container.resources.requests then
105
+
for name, value in pairs(container.resources.requests) do
Copy file name to clipboardExpand all lines: pkg/resourceinterpreter/default/thirdparty/resourcecustomizations/batch.volcano.sh/v1alpha1/Job/testdata/desired-job.yaml
Copy file name to clipboardExpand all lines: pkg/resourceinterpreter/default/thirdparty/resourcecustomizations/batch.volcano.sh/v1alpha1/Job/testdata/observed-job.yaml
0 commit comments