Commit cc49907
committed
Refactor GPU allocatable detection into reusable function
Extract the GPU allocatable detection loop into a new NodeHasGpuAllocatable
helper function in utils/gpu/gpu.go. This eliminates code duplication across
gpu_processor.go and makes the logic more maintainable.
The new function returns both the GPU allocatable value and whether it exists,
allowing callers to get both pieces of information in a single call.
Changes:
- Add NodeHasGpuAllocatable() helper in utils/gpu/gpu.go
- Update NodeHasGpu() to use the new helper
- Simplify FilterOutNodesWithUnreadyResources() in gpu_processor.go
- Simplify GetNodeGpuTarget() in gpu_processor.go1 parent 5873c7f commit cc49907
File tree
2 files changed
+14
-16
lines changed- cluster-autoscaler
- processors/customresources
- utils/gpu
2 files changed
+14
-16
lines changedLines changed: 3 additions & 12 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
48 | 48 | | |
49 | 49 | | |
50 | 50 | | |
51 | | - | |
52 | | - | |
53 | | - | |
54 | | - | |
55 | | - | |
56 | | - | |
57 | | - | |
58 | | - | |
| 51 | + | |
59 | 52 | | |
60 | 53 | | |
61 | 54 | | |
| |||
94 | 87 | | |
95 | 88 | | |
96 | 89 | | |
97 | | - | |
98 | | - | |
99 | | - | |
100 | | - | |
| 90 | + | |
| 91 | + | |
101 | 92 | | |
102 | 93 | | |
103 | 94 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
126 | 126 | | |
127 | 127 | | |
128 | 128 | | |
| 129 | + | |
| 130 | + | |
| 131 | + | |
| 132 | + | |
| 133 | + | |
| 134 | + | |
| 135 | + | |
129 | 136 | | |
130 | | - | |
131 | | - | |
132 | | - | |
| 137 | + | |
| 138 | + | |
| 139 | + | |
133 | 140 | | |
134 | 141 | | |
135 | | - | |
| 142 | + | |
136 | 143 | | |
137 | 144 | | |
138 | 145 | | |
| |||
0 commit comments