Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 4 additions & 4 deletions config/v1/types_cluster_version.go
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,7 @@ type ClusterVersionSpec struct {
//
// Some of the fields are inter-related with restrictions and meanings described here.
// 1. image is specified, version is specified, architecture is specified. API validation error.
// 2. image is specified, version is specified, architecture is not specified. You should not do this. version is silently ignored and image is used.
// 2. image is specified, version is specified, architecture is not specified. The version extracted from the referenced image must match the specified version.
// 3. image is specified, version is not specified, architecture is specified. API validation error.
// 4. image is specified, version is not specified, architecture is not specified. image is used.
// 5. image is not specified, version is specified, architecture is specified. version and desired architecture are used to select an image.
Expand Down Expand Up @@ -702,16 +702,16 @@ type Update struct {
Architecture ClusterVersionArchitecture `json:"architecture"`

// version is a semantic version identifying the update version.
// version is ignored if image is specified and required if
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Poking a bit more deeply into where the nominal "ignored" came from, on 2022-11-08 I claimed it was ignored. I'm not sure what 2022-me was thinking there; possibly I was just focused on how the CVO looks up which image to use (and that logic doesn't run when image is explicitly set in spec), and I overlooked the sync-worker validation as it judges the requested desiredUpdate for ReleaseAccepted?

// architecture is specified.
// version is required if architecture is specified.
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You could add a CEL rule to validate this. We can test that it ratchets so that existing broken resources do not suddenly become broken

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

"version is ... required if architecture is specified" dates back to #1339, and seems orthogonal to the change I'm suggesting here. And actually, oc adm upgrade --to-multi-arch is setting both architecture and version, and I don't see a reason to block that; it's the same sanity-check of "yes, the image the cluster retrieved seems like the release the cluster admin was expecting" for folks where version numbers are more recognizable than image digests (everybody? Definitely me, anyway). Should I drop that unnecessary constraint from the docs in this pull request, or can I file a follow-up pull request dropping that constraint once this one merges? Or...?

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I agree it's orthogonal, but it's good to make compatible incremental change as we are touching areas of APIs.

What happens if version is missing when architecture is specified today? Ignoring CLI tooling that would set it, since folks can manipulate these resources themselves, would it cause CVO to return errors when it processes the object?

If so, adding a CEL rule as below would give more immediate feedback to a user, and is relatively free to us to implement. As of 4.18 this should ratchet itself, but we would need to test it.

// +kubebuilder:validation:XValidation:rule="!has(self.architecture) || has(self.version)",message="version if required when architecture is set"

A self ratcheting version

// +kubebuilder:validation:XValidation:rule="!has(self.architecture) || has(self.version) || has(oldSelf.architecture)",message="version if required when architecture is set"

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

What happens if version is missing when architecture is specified today?

Looks like that's already guarded here. With a launch 4.17.12 aws Cluster Bot cluster:

$ oc patch clusterversion version --type json -p '[{"op": "add", "path": "/spec/desiredUpdate", "value": {"architecture": "Multi"}}]'
The ClusterVersion "version" is invalid: spec.desiredUpdate: Invalid value: "object": no such key: version evaluating rule: Version must be set if Architecture is set

So I can leave the version is required if architecture is specified docs in place here, and don't need to add additional CEL.

// If both version and image are set, the version extracted from the referenced image must match the specified version.
//
// +optional
Version string `json:"version"`

// image is a container image location that contains the update.
// image should be used when the desired version does not exist in availableUpdates or history.
// When image is set, version is ignored. When image is set, version should be empty.
// When image is set, architecture cannot be specified.
// If both version and image are set, the version extracted from the referenced image must match the specified version.
//
// +optional
Image string `json:"image"`
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -141,7 +141,7 @@ spec:

Some of the fields are inter-related with restrictions and meanings described here.
1. image is specified, version is specified, architecture is specified. API validation error.
2. image is specified, version is specified, architecture is not specified. You should not do this. version is silently ignored and image is used.
2. image is specified, version is specified, architecture is not specified. The version extracted from the referenced image must match the specified version.
3. image is specified, version is not specified, architecture is specified. API validation error.
4. image is specified, version is not specified, architecture is not specified. image is used.
5. image is not specified, version is specified, architecture is specified. version and desired architecture are used to select an image.
Expand Down Expand Up @@ -181,14 +181,14 @@ spec:
description: |-
image is a container image location that contains the update.
image should be used when the desired version does not exist in availableUpdates or history.
When image is set, version is ignored. When image is set, version should be empty.
When image is set, architecture cannot be specified.
If both version and image are set, the version extracted from the referenced image must match the specified version.
type: string
version:
description: |-
version is a semantic version identifying the update version.
version is ignored if image is specified and required if
architecture is specified.
version is required if architecture is specified.
If both version and image are set, the version extracted from the referenced image must match the specified version.
type: string
type: object
x-kubernetes-validations:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -141,7 +141,7 @@ spec:

Some of the fields are inter-related with restrictions and meanings described here.
1. image is specified, version is specified, architecture is specified. API validation error.
2. image is specified, version is specified, architecture is not specified. You should not do this. version is silently ignored and image is used.
2. image is specified, version is specified, architecture is not specified. The version extracted from the referenced image must match the specified version.
3. image is specified, version is not specified, architecture is specified. API validation error.
4. image is specified, version is not specified, architecture is not specified. image is used.
5. image is not specified, version is specified, architecture is specified. version and desired architecture are used to select an image.
Expand Down Expand Up @@ -181,14 +181,14 @@ spec:
description: |-
image is a container image location that contains the update.
image should be used when the desired version does not exist in availableUpdates or history.
When image is set, version is ignored. When image is set, version should be empty.
When image is set, architecture cannot be specified.
If both version and image are set, the version extracted from the referenced image must match the specified version.
type: string
version:
description: |-
version is a semantic version identifying the update version.
version is ignored if image is specified and required if
architecture is specified.
version is required if architecture is specified.
If both version and image are set, the version extracted from the referenced image must match the specified version.
type: string
type: object
x-kubernetes-validations:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -141,7 +141,7 @@ spec:

Some of the fields are inter-related with restrictions and meanings described here.
1. image is specified, version is specified, architecture is specified. API validation error.
2. image is specified, version is specified, architecture is not specified. You should not do this. version is silently ignored and image is used.
2. image is specified, version is specified, architecture is not specified. The version extracted from the referenced image must match the specified version.
3. image is specified, version is not specified, architecture is specified. API validation error.
4. image is specified, version is not specified, architecture is not specified. image is used.
5. image is not specified, version is specified, architecture is specified. version and desired architecture are used to select an image.
Expand Down Expand Up @@ -181,14 +181,14 @@ spec:
description: |-
image is a container image location that contains the update.
image should be used when the desired version does not exist in availableUpdates or history.
When image is set, version is ignored. When image is set, version should be empty.
When image is set, architecture cannot be specified.
If both version and image are set, the version extracted from the referenced image must match the specified version.
type: string
version:
description: |-
version is a semantic version identifying the update version.
version is ignored if image is specified and required if
architecture is specified.
version is required if architecture is specified.
If both version and image are set, the version extracted from the referenced image must match the specified version.
type: string
type: object
x-kubernetes-validations:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -141,7 +141,7 @@ spec:

Some of the fields are inter-related with restrictions and meanings described here.
1. image is specified, version is specified, architecture is specified. API validation error.
2. image is specified, version is specified, architecture is not specified. You should not do this. version is silently ignored and image is used.
2. image is specified, version is specified, architecture is not specified. The version extracted from the referenced image must match the specified version.
3. image is specified, version is not specified, architecture is specified. API validation error.
4. image is specified, version is not specified, architecture is not specified. image is used.
5. image is not specified, version is specified, architecture is specified. version and desired architecture are used to select an image.
Expand Down Expand Up @@ -181,14 +181,14 @@ spec:
description: |-
image is a container image location that contains the update.
image should be used when the desired version does not exist in availableUpdates or history.
When image is set, version is ignored. When image is set, version should be empty.
When image is set, architecture cannot be specified.
If both version and image are set, the version extracted from the referenced image must match the specified version.
type: string
version:
description: |-
version is a semantic version identifying the update version.
version is ignored if image is specified and required if
architecture is specified.
version is required if architecture is specified.
If both version and image are set, the version extracted from the referenced image must match the specified version.
type: string
type: object
x-kubernetes-validations:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -143,7 +143,7 @@ spec:

Some of the fields are inter-related with restrictions and meanings described here.
1. image is specified, version is specified, architecture is specified. API validation error.
2. image is specified, version is specified, architecture is not specified. You should not do this. version is silently ignored and image is used.
2. image is specified, version is specified, architecture is not specified. The version extracted from the referenced image must match the specified version.
3. image is specified, version is not specified, architecture is specified. API validation error.
4. image is specified, version is not specified, architecture is not specified. image is used.
5. image is not specified, version is specified, architecture is specified. version and desired architecture are used to select an image.
Expand Down Expand Up @@ -183,14 +183,14 @@ spec:
description: |-
image is a container image location that contains the update.
image should be used when the desired version does not exist in availableUpdates or history.
When image is set, version is ignored. When image is set, version should be empty.
When image is set, architecture cannot be specified.
If both version and image are set, the version extracted from the referenced image must match the specified version.
type: string
version:
description: |-
version is a semantic version identifying the update version.
version is ignored if image is specified and required if
architecture is specified.
version is required if architecture is specified.
If both version and image are set, the version extracted from the referenced image must match the specified version.
type: string
type: object
x-kubernetes-validations:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -143,7 +143,7 @@ spec:

Some of the fields are inter-related with restrictions and meanings described here.
1. image is specified, version is specified, architecture is specified. API validation error.
2. image is specified, version is specified, architecture is not specified. You should not do this. version is silently ignored and image is used.
2. image is specified, version is specified, architecture is not specified. The version extracted from the referenced image must match the specified version.
3. image is specified, version is not specified, architecture is specified. API validation error.
4. image is specified, version is not specified, architecture is not specified. image is used.
5. image is not specified, version is specified, architecture is specified. version and desired architecture are used to select an image.
Expand Down Expand Up @@ -183,14 +183,14 @@ spec:
description: |-
image is a container image location that contains the update.
image should be used when the desired version does not exist in availableUpdates or history.
When image is set, version is ignored. When image is set, version should be empty.
When image is set, architecture cannot be specified.
If both version and image are set, the version extracted from the referenced image must match the specified version.
type: string
version:
description: |-
version is a semantic version identifying the update version.
version is ignored if image is specified and required if
architecture is specified.
version is required if architecture is specified.
If both version and image are set, the version extracted from the referenced image must match the specified version.
type: string
type: object
x-kubernetes-validations:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -143,7 +143,7 @@ spec:

Some of the fields are inter-related with restrictions and meanings described here.
1. image is specified, version is specified, architecture is specified. API validation error.
2. image is specified, version is specified, architecture is not specified. You should not do this. version is silently ignored and image is used.
2. image is specified, version is specified, architecture is not specified. The version extracted from the referenced image must match the specified version.
3. image is specified, version is not specified, architecture is specified. API validation error.
4. image is specified, version is not specified, architecture is not specified. image is used.
5. image is not specified, version is specified, architecture is specified. version and desired architecture are used to select an image.
Expand Down Expand Up @@ -183,14 +183,14 @@ spec:
description: |-
image is a container image location that contains the update.
image should be used when the desired version does not exist in availableUpdates or history.
When image is set, version is ignored. When image is set, version should be empty.
When image is set, architecture cannot be specified.
If both version and image are set, the version extracted from the referenced image must match the specified version.
type: string
version:
description: |-
version is a semantic version identifying the update version.
version is ignored if image is specified and required if
architecture is specified.
version is required if architecture is specified.
If both version and image are set, the version extracted from the referenced image must match the specified version.
type: string
type: object
x-kubernetes-validations:
Expand Down
Loading