rgw: fix variable assignment
We need to explicitly assign the ceph version within each scope since one function returns a pointer and one is not. Previously, the `desiredCephVersion` was recreated in the scope of the `else` and thus a new variable `desiredCephVersion` was initialized (see the `:=`). Now, each scope creates and assign to clusterInfo a `desiredCephVersion` value. Signed-off-by: Sébastien Han <seb@redhat.com>
This commit is contained in:
1 parent
c3e02e7295
commit
7f32461b8f
2 files changed
+4
-6
No files matched your search
@@ -34,7 +34,6 @@ import (
|
||||
"github.com/rook/rook/pkg/operator/ceph/config"
|
||||
opcontroller "github.com/rook/rook/pkg/operator/ceph/controller"
|
||||
"github.com/rook/rook/pkg/operator/ceph/reporting"
|
||||
cephver "github.com/rook/rook/pkg/operator/ceph/version"
|
||||
"github.com/rook/rook/pkg/operator/k8sutil"
|
||||
"github.com/rook/rook/pkg/util/exec"
|
||||
appsv1 "k8s.io/api/apps/v1"
|
||||
@@ -291,14 +290,13 @@ func (r *ReconcileCephObjectStore) reconcile(request reconcile.Request) (reconci
|
||||
return reconcile.Result{}, cephObjectStore, nil
|
||||
}
|
||||
|
||||
var desiredCephVersion cephver.CephVersion
|
||||
if cephObjectStore.Spec.IsExternal() {
|
||||
// Check the ceph version of the running monitors
|
||||
desiredCephVersion, err = cephclient.LeastUptodateDaemonVersion(r.context, r.clusterInfo, config.MonType)
|
||||
desiredCephVersion, err := cephclient.LeastUptodateDaemonVersion(r.context, r.clusterInfo, config.MonType)
|
||||
if err != nil {
|
||||
return reconcile.Result{}, nil, errors.Wrapf(err, "failed to retrieve current ceph %q version", config.MonType)
|
||||
}
|
||||
|
||||
r.clusterInfo.CephVersion = desiredCephVersion
|
||||
} else {
|
||||
// Detect desired CephCluster version
|
||||
runningCephVersion, desiredCephVersion, err := currentAndDesiredCephVersion(
|
||||
@@ -328,10 +326,9 @@ func (r *ReconcileCephObjectStore) reconcile(request reconcile.Request) (reconci
|
||||
cephObjectStore,
|
||||
opcontroller.ErrorCephUpgradingRequeue(desiredCephVersion, runningCephVersion)
|
||||
}
|
||||
r.clusterInfo.CephVersion = *desiredCephVersion
|
||||
}
|
||||
|
||||
r.clusterInfo.CephVersion = desiredCephVersion
|
||||
|
||||
// validate the store settings
|
||||
if err := r.validateStore(cephObjectStore); err != nil {
|
||||
return reconcile.Result{}, cephObjectStore, errors.Wrapf(err, "invalid object store %q arguments", cephObjectStore.Name)
|
||||
|
||||
@@ -523,6 +523,7 @@ func TestCephObjectStoreController(t *testing.T) {
|
||||
assert.NotEmpty(t, objectStore.Status.Info["endpoint"], objectStore)
|
||||
assert.Equal(t, "http://rook-ceph-rgw-my-store.rook-ceph.svc:80", objectStore.Status.Info["endpoint"], objectStore)
|
||||
assert.True(t, calledCommitConfigChanges)
|
||||
assert.Equal(t, 16, r.clusterInfo.CephVersion.Major)
|
||||
})
|
||||
}
|
||||
|
||||
|
||||
Reference in new issue
Block a user