Skip to content

Commit

Permalink
fix: use operator image for vgmanager
Browse files Browse the repository at this point in the history
- get the operator image name from reconciler struct

Signed-off-by: Leela Venkaiah G <lgangava@redhat.com>
  • Loading branch information
leelavg authored and openshift-cherrypick-robot committed Jan 28, 2022
1 parent f8e6dae commit 63ff71b
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 17 deletions.
7 changes: 2 additions & 5 deletions controllers/vgmanager.go
Original file line number Diff line number Diff line change
Expand Up @@ -43,13 +43,10 @@ func (v vgManager) ensureCreated(r *LVMClusterReconciler, ctx context.Context, l
unitLogger := r.Log.WithValues("resourceManager", v.getName())

// get desired daemonset spec
dsTemplate, err := newVGManagerDaemonset(r, ctx, lvmCluster)
if err != nil {
return fmt.Errorf("failed to get new VGManager Daemonset due to %v", err)
}
dsTemplate := newVGManagerDaemonset(lvmCluster, r.Namespace, r.ImageName)

// controller reference
err = ctrl.SetControllerReference(lvmCluster, &dsTemplate, r.Scheme)
err := ctrl.SetControllerReference(lvmCluster, &dsTemplate, r.Scheme)
if err != nil {
return fmt.Errorf("failed to set controller reference on vgManager daemonset %q. %v", dsTemplate.Name, err)
}
Expand Down
16 changes: 4 additions & 12 deletions controllers/vgmanager_daemonset.go
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,6 @@ limitations under the License.
package controllers

import (
"context"
"os"

lvmv1alpha1 "github.com/red-hat-storage/lvm-operator/api/v1alpha1"
Expand Down Expand Up @@ -115,7 +114,7 @@ var (
)

// newVGManagerDaemonset returns the desired vgmanager daemonset for a given LVMCluster
func newVGManagerDaemonset(r *LVMClusterReconciler, ctx context.Context, lvmCluster *lvmv1alpha1.LVMCluster) (appsv1.DaemonSet, error) {
func newVGManagerDaemonset(lvmCluster *lvmv1alpha1.LVMCluster, namespace string, vgImage string) appsv1.DaemonSet {
// aggregate nodeSelector and tolerations from all deviceClasses
nodeSelector, tolerations := extractNodeSelectorAndTolerations(lvmCluster)
volumes := []corev1.Volume{LVMDConfVol, DevHostDirVol, UDevHostDirVol, SysHostDirVol}
Expand All @@ -126,17 +125,10 @@ func newVGManagerDaemonset(r *LVMClusterReconciler, ctx context.Context, lvmClus
// try to get vgmanager image from env and on absence get from running pod
// TODO: investigate why storing this env in a variable is failing tests
image := os.Getenv("VGMANAGER_IMAGE")
var err error
if image == "" {
image, err = getRunningPodImage(r, ctx)
if err != nil {
r.Log.Error(err, "failed to get image from running operator")
return appsv1.DaemonSet{}, err
}
image = vgImage
}

r.Log.Info("creating VG manager deployment", "image", image)

command := []string{
"/vgmanager",
}
Expand Down Expand Up @@ -185,7 +177,7 @@ func newVGManagerDaemonset(r *LVMClusterReconciler, ctx context.Context, lvmClus
ds := appsv1.DaemonSet{
ObjectMeta: metav1.ObjectMeta{
Name: VGManagerUnit,
Namespace: r.Namespace,
Namespace: namespace,
Labels: labels,
},
Spec: appsv1.DaemonSetSpec{
Expand All @@ -209,5 +201,5 @@ func newVGManagerDaemonset(r *LVMClusterReconciler, ctx context.Context, lvmClus

// set nodeSelector
setDaemonsetNodeSelector(nodeSelector, &ds)
return ds, nil
return ds
}

0 comments on commit 63ff71b

Please sign in to comment.