Skip to content

Commit

Permalink
NO-ISSUE: Ensure that openshift_version isn't empty
Browse files Browse the repository at this point in the history
We found a situation where the `openshift_version` column of the
clusters table is empty. We haven't been able to understand why, but it
results in an error when running validations. For example, the
dual-stack VIP validation produces a false negative:

```
2024-09-11T05:39:04.055138029Z time="2024-09-11T05:39:04Z"
level=error
msg="Cluster 686c7849-8d68-4340-b81d-9add8c4261fe failed VIP validations"
func="github.com/openshift/assisted-service/internal/bminventory.(*bareMetalInventory).validateAndUpdateClusterParams"
file="/remote-source/assisted-service/app/internal/bminventory/inventory.go:1889"
error="dual-stack VIPs are not supported in OpenShift "
pkg=Inventory
```

Note how the error message doesn't contain the OpenShift version at the
end. It should, as the code is like this:

```go
return common.NewApiError(http.StatusBadRequest, errors.Errorf("%s %s", "dual-stack VIPs are not supported in OpenShift", cluster.OpenshiftVersion))
```

So we are assuming, at least in that code, that the `openshift_version`
column is not empty.

This patch changes adds a database constraint to ensure that that
`openshift_column` isn't null or empty. That doesn't address the root
cause (because we don't know it) but at least it should catch situations
where something tries to set that column empty.

Related: https://issues.redhat.com/browse/OCPBUGS-42059
Related: https://github.com/openshift/assisted-service/blob/e59df80246f418b62048d7252e4d79bf5723c81e/internal/cluster/validations/validations.go#L256
Signed-off-by: Juan Hernandez <juan.hernandez@redhat.com>
  • Loading branch information
jhernand committed Oct 3, 2024
1 parent 341f986 commit b5163e0
Show file tree
Hide file tree
Showing 6 changed files with 9 additions and 6 deletions.

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion models/cluster.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

6 changes: 4 additions & 2 deletions restapi/embedded_spec.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions swagger.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -5150,6 +5150,7 @@ definitions:
openshift_version:
type: string
description: Version of the OpenShift cluster.
x-go-custom-tag: gorm:"not null;check:openshift_version <> ''"
ocp_release_image:
type: string
description: OpenShift release image URI.
Expand Down

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

0 comments on commit b5163e0

Please sign in to comment.