Skip to content

Commit ef2e918

Browse files
committed
Final version of the external validation EP
Signed-off-by: jesus m. rodriguez <jesusr@redhat.com>
1 parent 57054b2 commit ef2e918

File tree

1 file changed

+19
-183
lines changed

1 file changed

+19
-183
lines changed

enhancements/sdk-external-and-pluggable-validations.md

Lines changed: 19 additions & 183 deletions
Original file line numberDiff line numberDiff line change
@@ -27,20 +27,21 @@ see-also:
2727

2828
## Open Questions [optional]
2929

30-
1. what validations do we have today?
3130
1. can we use scorecard to replace all of these validations?
3231
* scorecard uses the cluster to run the tests, these validations typically
3332
run locally or in a pipeline. They are also done before the expensive
3433
operator tests are run.
3534
1. what would it take to convert an existing validator to an executable format?
35+
Simply add a `main.go` to wrap existing validators.
36+
1. do we need to add `json` tags to [these structs][errors-go]?
3637

3738
## Summary
3839

39-
Today, validations used by CVP are compiled into the operator-sdk. Any changes
40+
Today, validations used by CVP are compiled into the `operator-sdk`. Any changes
4041
to the validation rules requires a release of operator-framework/api followed by
41-
a release of operator-sdk. This proposal attempts to design a way where the
42+
a release of `operator-sdk`. This proposal attempts to design a way where the
4243
validations can be hosted in their own repos as well as updated without
43-
requiring new releases of the operator-sdk.
44+
requiring new releases of the `operator-sdk`.
4445

4546
## Motivation
4647

@@ -66,8 +67,6 @@ validators to be created allowing for greater flexibility.
6667
* allow validations to be hosted in their own repos
6768
* allow validations to be external to operator-sdk
6869

69-
TODO: are there any other goals?
70-
7170
### Non-Goals
7271

7372
* existing validations do NOT have be migrated unless they want to
@@ -84,8 +83,6 @@ TODO: are there any other goals?
8483
* as a validation author, I can write a validation for a bundle and use it
8584
without having to get a new operator-sdk release
8685

87-
TODO: Stories from the epic; consolidate with the above stories
88-
8986
#### Story 3
9087
* Users want to edit/add/remove a set of validation rules for Operator bundle validation.
9188

@@ -122,9 +119,6 @@ shell script.
122119
From the operator-sdk's point of view, we don't care what you use
123120
to create your validator only that we can run it and pass it a bundle directory.
124121

125-
126-
TODO: how will validators be found?
127-
128122
#### Validators
129123

130124
##### Running validators
@@ -220,8 +214,6 @@ be found at [validator-poc][validator-poc1]
220214
Another example of a migration can be find at [ocp-olm-catalog-validator][camila-poc].
221215
This particular example does NOT yet output `ManifestResult` format.
222216

223-
TODO: do we need to add `json` tags to these structs?
224-
https://github.com/operator-framework/api/blob/master/pkg/validation/errors/error.go#L9-L16
225217

226218

227219
#### CLI
@@ -238,6 +230,7 @@ Usage:
238230
...
239231
240232
Flags:
233+
--alpha-select-external string Selector to select external validators to run. It should be set to a Unix path list ("/path/to/e1.sh:/path/to/e2")
241234
-h, --help help for validate
242235
-b, --image-builder string Tool to pull and unpack bundle images. Only used when validating a bundle image. One of: [docker, podman, none] (default "docker")
243236
--list-optional List all optional validators available. When set, no validators will be run
@@ -253,93 +246,12 @@ Global Flags:
253246
* *--help* works as is
254247
* *--image-builder* works as is
255248
* *--list-optional* would need to be updated to locate external validators.
256-
257-
TODO: How do we locate these validators? Do we use the XDG_CONFIG like Phase
258-
2? Or allow users to pass in the location of the validators?
259-
260249
* *--optional-values* would continue to be passed to the validators
261250
* *--output* indicates how we want to output the results.
251+
* *--select-optional* works as is
252+
* *-- alpha-select-external* added; takes in the location of the executable to run as
253+
the validator, i.e. `/path/to/validator/the-executable:/path/to/another`
262254

263-
TODO: what types do we want to support?
264-
265-
* *--select-optional* takes in a label selector to specify which optional test
266-
to run. We could allow a new label to indicate the location of the executable
267-
to run as the validator. i.e. `validator-path=/path/to/validator/the-executable`
268-
269-
TODO: need to define what the CLI for operator-sdk will look like. Are there
270-
any new flags? Do we use the environment variable?
271-
272-
NOTE: what would the CLI look like?
273-
274-
275-
##### Default validators run by operator-sdk
276-
277-
List of current validators:
278-
TODO: do we need these validators called out like this?
279-
280-
* BundleValidator
281-
* validates the bundle
282-
* looks for duplicate keys in bundle
283-
* verifies all owned keys match a CRD in the bundle
284-
* verifies that all CRDs present in the bundle are in the CSV
285-
* validates the service account
286-
287-
* ClusterServiceVersionValidator
288-
* operator-sdk checks to see if the CSV is nil on the bundle (that's the first
289-
check)
290-
* checks that the CSV name is a valid format
291-
* DNS1123
292-
* valid label
293-
* verifies replaces name is also a valid format
294-
* DNS1123
295-
* valid label
296-
* ensures that both `alm-examples` and `olm.examples` are not both present
297-
* decodes the example yaml, to validate its format
298-
* checks provided APIs
299-
* validates the `InstallModes`
300-
* verifies that conversion CRDs support `AllNamespaces`
301-
* checks for missing mandatory fields
302-
* validates the annotation names
303-
* validates the version and kind
304-
305-
* CustomResourceDefinitionValidator
306-
* operator-sdk puts the v1beta1 and v1 CRDs together for validation
307-
* validates v1beta1 CRDs
308-
* validates v1 CRDs
309-
* validates internal CRDs
310-
* https://github.com/kubernetes/apiextensions-apiserver/blob/master/pkg/apis/apiextensions/validation/validation.go#L49-L78
311-
312-
##### Optional validators
313-
314-
* PackageManifestValidator
315-
316-
* OperatorHubValidator
317-
318-
* ObjectValidator
319-
320-
* OperatorGroupValidator
321-
322-
* CommunityOperatorValidator
323-
324-
* AlphaDeprecatedAPIsValidator
325-
326-
* AllValidators
327-
* Uses ALL of the validators
328-
* BundleValidator
329-
* ClusterServiceVersionValidator
330-
* CustomResourceDefinitionValidator
331-
* PackageManifestValidator
332-
* OperatorHubValidator
333-
* ObjectValidator
334-
* OperatorGroupValidator
335-
* CommunityOperatorValidator
336-
* AlphaDeprecatedAPIsValidator
337-
338-
* DefaultBundleValidators
339-
* Uses the following 3 validators
340-
* BundleValidator
341-
* ClusterServiceVersionValidator
342-
* CustomResourceDefinitionValidator
343255
### Risks and Mitigations
344256

345257
There is little risk, if this does not pan out we keep going on the current path
@@ -349,73 +261,17 @@ of compiling them in.
349261

350262
### Test Plan
351263

352-
**Note:** *Section not required until targeted at a release.*
353-
354-
Consider the following in developing a test plan for this enhancement:
355-
- Will there be e2e and integration tests, in addition to unit tests?
356-
- How will it be tested in isolation vs with other components?
357-
358-
No need to outline all of the test cases, just the general strategy. Anything
359-
that would count as tricky in the implementation and anything particularly
360-
challenging to test should be called out.
361-
362-
All code is expected to have adequate tests (eventually with coverage
363-
expectations).
264+
- unit tests for the feature will be added in the implementation
265+
- QE would need to create custom validations to be called by the new `--alpha-select-external` flag.
364266

365267
### Graduation Criteria
366268

367-
**Note:** *Section not required until targeted at a release.*
368-
369-
Define graduation milestones.
370-
371-
These may be defined in terms of API maturity, or as something else. Initial proposal
372-
should keep this high-level with a focus on what signals will be looked at to
373-
determine graduation.
374-
375-
Consider the following in developing the graduation criteria for this
376-
enhancement:
377-
- Maturity levels - `Dev Preview`, `Tech Preview`, `GA`
378-
- Deprecation
379-
380-
Clearly define what graduation means.
381-
382-
#### Examples
383-
384-
These are generalized examples to consider, in addition to the aforementioned
385-
[maturity levels][maturity-levels].
269+
This feature will come out as alpha accessible via the `--alpha-select-external`
270+
flag to the `bundle validate` command. We will accept feedback on possible
271+
changes to the feature.
386272

387-
##### Dev Preview -> Tech Preview
388-
389-
- Ability to utilize the enhancement end to end
390-
- End user documentation, relative API stability
391-
- Sufficient test coverage
392-
- Gather feedback from users rather than just developers
393-
394-
##### Tech Preview -> GA
395-
396-
- More testing (upgrade, downgrade, scale)
397-
- Sufficient time for feedback
398-
- Available by default
399-
400-
**For non-optional features moving to GA, the graduation criteria must include
401-
end to end tests.**
402-
403-
##### Removing a deprecated feature
404-
405-
- Announce deprecation and support policy of the existing feature
406-
- Deprecate the feature
407-
408-
### Upgrade / Downgrade Strategy
409-
410-
If applicable, how will the component be upgraded and downgraded? Make sure this
411-
is in the test plan.
412-
413-
Consider the following in developing an upgrade/downgrade strategy for this
414-
enhancement:
415-
- What changes (in invocations, configurations, API use, etc.) is an existing
416-
cluster required to make on upgrade in order to keep previous behavior?
417-
- What changes (in invocations, configurations, API use, etc.) is an existing
418-
cluster required to make on upgrade in order to make use of the enhancement?
273+
After a period of time, we can graduate to a GA with a more permanent flag, i.e.
274+
`--select-external`.
419275

420276
### Version Skew Strategy
421277

@@ -426,8 +282,7 @@ enhancement:
426282

427283
## Implementation History
428284

429-
Major milestones in the life cycle of a proposal should be tracked in `Implementation
430-
History`.
285+
N/A
431286

432287
## Drawbacks
433288

@@ -446,20 +301,6 @@ compilation step being needed depending on the language used to implement them.
446301
* would need a cluster to run these validations
447302
* authors would have to create binaries of their validations anyway
448303

449-
TODO: ---------- vvvvvv CUT vvvvvv ----------
450-
* wrap validations in their own executables
451-
* validations would be wrapped in an executable that would be called from
452-
operator-sdk
453-
* pro:
454-
* could reuse the existing go validations and put a main.go in front to make
455-
them executable
456-
* follows a similar phase 2 plugin path
457-
* could reuse some of the phase 2 tech to run this
458-
* would not need a cluster necessarily to run the validation
459-
* con:
460-
* authors would have to create binaries of their validations
461-
TODO: ---------- ^^^^^^ CUT ^^^^^^ ----------
462-
463304
* use a language like JavaScript or CUE to define all validations
464305
* validations could be run from a git repo, i.e. operator-sdk could pull it
465306
and then evaluate it
@@ -480,15 +321,10 @@ TODO: ---------- ^^^^^^ CUT ^^^^^^ ----------
480321

481322
## Infrastructure Needed [optional]
482323

483-
Use this section if you need things from the project. Examples include a new
484-
subproject, repos requested, github details, and/or testing infrastructure.
485-
486-
Listing these here allows the community to get the process for these resources
487-
started right away.
488-
489-
https://github.com/operator-framework/api/tree/master/pkg/validation
324+
N/A
490325

491326
[phase-2]: https://github.com/kubernetes-sigs/kubebuilder/blob/master/designs/extensible-cli-and-scaffolding-plugins-phase-2.md
492327
[manifest-result]: https://github.com/operator-framework/api/blob/master/pkg/validation/errors/error.go#L9-L16
493328
[validator-poc1]: https://github.com/jmrodri/validator-poc/tree/poc1-manifestresults
494329
[camila-poc]: https://github.com/camilamacedo86/ocp-olm-catalog-validator
330+
[errors-go]: https://github.com/operator-framework/api/blob/master/pkg/validation/errors/error.go#L9-L16

0 commit comments

Comments
 (0)