Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Report versioning errors in StorageCluster's status #1447

Closed
wants to merge 1 commit into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
2 changes: 1 addition & 1 deletion Makefile
Expand Up @@ -161,7 +161,7 @@ golangci-lint:
# use 'make functest' to run just the functional tests
unit-test:
@echo "Executing unit tests"
go test -v -cover `go list ./... | grep -v "functest"`
hack/unit-test.sh

ocs-operator-ci: shellcheck-test golangci-lint unit-test verify-deps verify-generated verify-latest-deploy-yaml

Expand Down
6 changes: 6 additions & 0 deletions controllers/storagecluster/reconcile.go
Expand Up @@ -200,6 +200,12 @@ func (r *StorageClusterReconciler) validateStorageClusterSpec(instance *ocsv1.St
r.Log.Error(err, "Failed to validate StorageCluster version.", "StorageCluster", klog.KRef(instance.Namespace, instance.Name))
r.recorder.ReportIfNotPresent(instance, corev1.EventTypeWarning, statusutil.EventReasonValidationFailed, err.Error())
instance.Status.Phase = statusutil.PhaseError
instance.Status.Conditions = append(instance.Status.Conditions, conditionsv1.Condition{
Type: conditionsv1.ConditionDegraded,
Status: corev1.ConditionTrue,
Reason: statusutil.EventReasonValidationFailed,
Message: err.Error(),
})
if updateErr := r.Client.Status().Update(context.TODO(), instance); updateErr != nil {
r.Log.Error(updateErr, "Failed to update StorageCluster.", "StorageCluster", klog.KRef(instance.Namespace, instance.Name))
return updateErr
Expand Down
3 changes: 2 additions & 1 deletion hack/build-functest.sh
Expand Up @@ -21,8 +21,9 @@ else
echo "GINKO binary found at $GINKGO"
fi

LDFLAGS="-X github.com/red-hat-storage/ocs-operator/version.Version=${VERSION}"

"$GOBIN"/ginkgo build "functests/${suite}/"
"$GOBIN"/ginkgo build --ldflags "${LDFLAGS}" "functests/${suite}/"

mkdir -p $OUTDIR_BIN
mv "functests/${suite}/${suite}.test" "${OUTDIR_BIN}/${suite}_tests"
5 changes: 4 additions & 1 deletion hack/generate-unified-csv.sh
Expand Up @@ -5,7 +5,10 @@ set -e
source hack/common.sh

CSV_MERGER="tools/csv-merger/csv-merger"
(cd tools/csv-merger/ && go build)

LDFLAGS="-X github.com/red-hat-storage/ocs-operator/version.Version=${VERSION}"

(cd tools/csv-merger/ && go build -ldflags="${LDFLAGS}")

function help_txt() {
echo "Environment Variables"
Expand Down
9 changes: 9 additions & 0 deletions hack/unit-test.sh
@@ -0,0 +1,9 @@
#!/bin/bash

set -e

source hack/common.sh

LDFLAGS="-X github.com/red-hat-storage/ocs-operator/version.Version=${VERSION}"

go test -ldflags="${LDFLAGS}" -v -cover `go list ./... | grep -v "functest"`
2 changes: 1 addition & 1 deletion tools/csv-merger/csv-merger.go
Expand Up @@ -781,7 +781,7 @@ The OpenShift Container Storage operator is the primary operator for OpenShift C

func injectCSVRelatedImages(r *unstructured.Unstructured) error {

relatedImages := []interface{}{}
var relatedImages []interface{}

if *rookContainerImage != "" {
relatedImages = append(relatedImages, map[string]interface{}{
Expand Down
2 changes: 1 addition & 1 deletion version/version.go
Expand Up @@ -2,5 +2,5 @@ package version

var (
// Version of the operator
Version = "4.11.0"
Version = ""
)