Commit a16dacc
feat: add new notebook lint checks and harden code
New checks:
- ConnectionIntegrityCheck: verifies that Notebooks referencing
connections via the opendatahub.io/connections annotation have
backing Secrets that exist. Uses a two-pass approach — collect
referenced namespaces, then list Secrets only in those namespaces
— to avoid cluster-wide Secret queries.
- HardwareProfileIntegrityCheck: verifies that Notebooks referencing
infrastructure HardwareProfiles (infrastructure.opendatahub.io)
via annotations point to profiles that exist. Uses the same
namespace-scoped two-pass pattern as ConnectionIntegrityCheck.
- RunningWorkloadsCheck: detects Notebooks that are currently running
(missing the kubeflow-resource-stopped annotation) before a 2.x to
3.x upgrade.
All three new checks and AcceleratorMigrationCheck use
validate.WorkloadsMetadata().Run() with callbacks. WorkloadBuilder
handles result creation, target version annotation, CRD-not-found
(empty list), and workload count annotation. Each callback overrides
AnnotationImpactedWorkloadCount with the actual impacted count and
unconditionally calls SetImpactedObjects (which always allocates via
make, preventing WorkloadBuilder's auto-populate).
New shared infrastructure:
- validate.FilterWorkloadsWithAcceleratorRefs: extracted from
FindWorkloadsWithAcceleratorRefs to process pre-listed items
without re-listing. FindWorkloadsWithAcceleratorRefs is now a
thin wrapper (list + delegate) and is still used by kserve.
- constants.go: centralizes check metadata (condition types,
annotation keys, message templates) used across all notebook
checks. Inline constants from impacted.go, container_name.go,
container_name_support.go, and hardwareprofile_migration.go are
moved here.
- utils.go: adds isWorkbenchesManaged helper, replacing duplicated
DSC lookup logic in container_name.go, impacted.go, and
hardwareprofile_migration.go.
- helpers_test.go: shared newNotebook test helper to reduce inline
notebook construction across test files.
- resources.InfrastructureHardwareProfile: new ResourceType for the
infrastructure.opendatahub.io/v1 HardwareProfile API group.
- check.CheckTypeDataIntegrity and check.CheckTypeWorkloadState:
new check type constants.
Changes to existing checks:
- AcceleratorMigrationCheck: refactored to WorkloadBuilder with a
checkAcceleratorRefs callback that delegates to
FilterWorkloadsWithAcceleratorRefs. Uses ReasonMigrationPending
instead of ReasonConfigurationInvalid for the auto-migration
advisory condition.
- HardwareProfileMigrationCheck: CanApply now requires Workbenches
to be Managed (previously always returned true).
- ImpactedWorkloadsCheck:
- Pre-compute nginxFixMinRHOAIVersion parsing at package load
time via mustParseVersionParts, replacing per-call string
splitting in isCompliantBuildRef.
- Extract hardcoded check.opendatahub.io annotation keys into
named constants (AnnotationCheckImageStatus,
AnnotationCheckImageRef, AnnotationCheckReason).
- findImageStreamByDockerRepo returns (ootbImageStream, bool)
instead of *ootbImageStream, consistent with sibling lookup
functions.
- ContainerNameCheck: CanApply delegates to isWorkbenchesManaged
instead of inlining DSC lookup.
- buildSecretCache (connection_integrity.go): takes client.Reader
instead of check.Target, consistent with how
hardware_profile_integrity.go accesses the client directly.
Removed:
- export_test.go: replaced by helpers_test.go with a more flexible
newNotebook helper using a notebookMeta options struct.
Signed-off-by: Andy Stoneberg <astonebe@redhat.com>1 parent 41bca85 commit a16dacc
File tree
24 files changed
+1828
-418
lines changed- pkg
- lint
- checks/workloads/notebook
- check
- validate
- resources
24 files changed
+1828
-418
lines changed| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
9 | 9 | | |
10 | 10 | | |
11 | 11 | | |
| 12 | + | |
| 13 | + | |
12 | 14 | | |
13 | 15 | | |
14 | 16 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
4 | 4 | | |
5 | 5 | | |
6 | 6 | | |
| 7 | + | |
7 | 8 | | |
8 | 9 | | |
9 | 10 | | |
| |||
39 | 40 | | |
40 | 41 | | |
41 | 42 | | |
| 43 | + | |
| 44 | + | |
| 45 | + | |
| 46 | + | |
| 47 | + | |
| 48 | + | |
| 49 | + | |
| 50 | + | |
| 51 | + | |
| 52 | + | |
| 53 | + | |
42 | 54 | | |
43 | 55 | | |
44 | 56 | | |
45 | | - | |
| 57 | + | |
46 | 58 | | |
47 | 59 | | |
48 | 60 | | |
49 | 61 | | |
50 | | - | |
| 62 | + | |
51 | 63 | | |
52 | 64 | | |
53 | 65 | | |
| |||
56 | 68 | | |
57 | 69 | | |
58 | 70 | | |
59 | | - | |
| 71 | + | |
60 | 72 | | |
61 | 73 | | |
62 | 74 | | |
| |||
Lines changed: 18 additions & 27 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
2 | 2 | | |
3 | 3 | | |
4 | 4 | | |
5 | | - | |
6 | 5 | | |
7 | 6 | | |
8 | 7 | | |
9 | 8 | | |
10 | | - | |
11 | 9 | | |
12 | 10 | | |
13 | 11 | | |
14 | 12 | | |
15 | | - | |
16 | | - | |
17 | 13 | | |
18 | 14 | | |
19 | 15 | | |
20 | | - | |
21 | | - | |
22 | 16 | | |
23 | 17 | | |
24 | 18 | | |
| |||
46 | 40 | | |
47 | 41 | | |
48 | 42 | | |
49 | | - | |
50 | | - | |
51 | | - | |
52 | | - | |
53 | | - | |
54 | | - | |
| 43 | + | |
55 | 44 | | |
56 | 45 | | |
57 | 46 | | |
58 | 47 | | |
59 | 48 | | |
60 | 49 | | |
61 | 50 | | |
62 | | - | |
| 51 | + | |
| 52 | + | |
| 53 | + | |
63 | 54 | | |
64 | | - | |
65 | | - | |
66 | | - | |
| 55 | + | |
| 56 | + | |
| 57 | + | |
| 58 | + | |
| 59 | + | |
| 60 | + | |
67 | 61 | | |
68 | | - | |
| 62 | + | |
69 | 63 | | |
70 | | - | |
| 64 | + | |
71 | 65 | | |
72 | 66 | | |
73 | 67 | | |
| |||
77 | 71 | | |
78 | 72 | | |
79 | 73 | | |
| 74 | + | |
80 | 75 | | |
81 | | - | |
82 | | - | |
83 | | - | |
84 | | - | |
85 | | - | |
| 76 | + | |
86 | 77 | | |
87 | 78 | | |
88 | 79 | | |
| |||
94 | 85 | | |
95 | 86 | | |
96 | 87 | | |
97 | | - | |
| 88 | + | |
98 | 89 | | |
99 | 90 | | |
100 | 91 | | |
| |||
104 | 95 | | |
105 | 96 | | |
106 | 97 | | |
107 | | - | |
| 98 | + | |
108 | 99 | | |
109 | 100 | | |
110 | 101 | | |
| |||
114 | 105 | | |
115 | 106 | | |
116 | 107 | | |
117 | | - | |
118 | | - | |
| 108 | + | |
| 109 | + | |
119 | 110 | | |
120 | 111 | | |
121 | 112 | | |
| |||
Lines changed: 34 additions & 98 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
1 | 1 | | |
2 | 2 | | |
3 | 3 | | |
| 4 | + | |
4 | 5 | | |
5 | 6 | | |
6 | 7 | | |
| |||
45 | 46 | | |
46 | 47 | | |
47 | 48 | | |
48 | | - | |
| 49 | + | |
49 | 50 | | |
50 | 51 | | |
51 | 52 | | |
| |||
56 | 57 | | |
57 | 58 | | |
58 | 59 | | |
59 | | - | |
60 | | - | |
61 | | - | |
62 | | - | |
63 | | - | |
64 | | - | |
65 | | - | |
66 | | - | |
67 | | - | |
68 | | - | |
69 | | - | |
| 60 | + | |
70 | 61 | | |
71 | 62 | | |
72 | 63 | | |
| |||
106 | 97 | | |
107 | 98 | | |
108 | 99 | | |
109 | | - | |
110 | | - | |
111 | | - | |
112 | | - | |
113 | | - | |
114 | | - | |
115 | | - | |
116 | | - | |
117 | | - | |
118 | | - | |
119 | | - | |
120 | | - | |
121 | | - | |
| 100 | + | |
| 101 | + | |
| 102 | + | |
| 103 | + | |
122 | 104 | | |
123 | | - | |
| 105 | + | |
124 | 106 | | |
125 | 107 | | |
126 | 108 | | |
| |||
137 | 119 | | |
138 | 120 | | |
139 | 121 | | |
140 | | - | |
141 | | - | |
| 122 | + | |
| 123 | + | |
142 | 124 | | |
143 | 125 | | |
144 | 126 | | |
| |||
154 | 136 | | |
155 | 137 | | |
156 | 138 | | |
157 | | - | |
158 | | - | |
159 | | - | |
160 | | - | |
161 | | - | |
162 | | - | |
163 | | - | |
164 | | - | |
165 | | - | |
166 | | - | |
167 | | - | |
168 | | - | |
169 | | - | |
| 139 | + | |
| 140 | + | |
| 141 | + | |
| 142 | + | |
170 | 143 | | |
171 | | - | |
| 144 | + | |
172 | 145 | | |
173 | 146 | | |
174 | 147 | | |
| |||
186 | 159 | | |
187 | 160 | | |
188 | 161 | | |
189 | | - | |
| 162 | + | |
190 | 163 | | |
191 | 164 | | |
192 | 165 | | |
| |||
211 | 184 | | |
212 | 185 | | |
213 | 186 | | |
214 | | - | |
215 | | - | |
216 | | - | |
217 | | - | |
218 | | - | |
219 | | - | |
220 | | - | |
221 | | - | |
222 | | - | |
223 | | - | |
224 | | - | |
| 187 | + | |
225 | 188 | | |
226 | 189 | | |
227 | | - | |
228 | | - | |
229 | | - | |
230 | | - | |
231 | | - | |
232 | | - | |
233 | | - | |
234 | | - | |
235 | | - | |
236 | | - | |
237 | | - | |
238 | | - | |
239 | | - | |
| 190 | + | |
| 191 | + | |
| 192 | + | |
| 193 | + | |
240 | 194 | | |
241 | | - | |
| 195 | + | |
242 | 196 | | |
243 | 197 | | |
244 | | - | |
245 | | - | |
246 | | - | |
247 | | - | |
248 | | - | |
249 | | - | |
250 | | - | |
251 | | - | |
252 | | - | |
253 | | - | |
254 | | - | |
255 | | - | |
256 | | - | |
| 198 | + | |
| 199 | + | |
| 200 | + | |
| 201 | + | |
257 | 202 | | |
258 | | - | |
| 203 | + | |
259 | 204 | | |
260 | 205 | | |
261 | 206 | | |
| |||
273 | 218 | | |
274 | 219 | | |
275 | 220 | | |
276 | | - | |
| 221 | + | |
277 | 222 | | |
278 | 223 | | |
279 | 224 | | |
| |||
401 | 346 | | |
402 | 347 | | |
403 | 348 | | |
404 | | - | |
405 | | - | |
406 | | - | |
407 | | - | |
408 | | - | |
409 | | - | |
410 | | - | |
411 | | - | |
412 | | - | |
413 | | - | |
414 | | - | |
415 | | - | |
416 | | - | |
| 349 | + | |
| 350 | + | |
| 351 | + | |
| 352 | + | |
417 | 353 | | |
418 | | - | |
| 354 | + | |
419 | 355 | | |
420 | 356 | | |
421 | 357 | | |
| |||
433 | 369 | | |
434 | 370 | | |
435 | 371 | | |
436 | | - | |
| 372 | + | |
437 | 373 | | |
438 | 374 | | |
439 | 375 | | |
| |||
0 commit comments