Skip to content

Commit 33e80c7

Browse files
committed
storage-operator: remove stub controller implementation
1 parent e76823f commit 33e80c7

File tree

1 file changed

+1
-53
lines changed

1 file changed

+1
-53
lines changed

storage-operator/pkg/controller/volume/volume_controller.go

+1-53
Original file line numberDiff line numberDiff line change
@@ -6,12 +6,9 @@ import (
66
storagev1alpha1 "github.com/scality/metalk8s/storage-operator/pkg/apis/storage/v1alpha1"
77
corev1 "k8s.io/api/core/v1"
88
"k8s.io/apimachinery/pkg/api/errors"
9-
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
109
"k8s.io/apimachinery/pkg/runtime"
11-
"k8s.io/apimachinery/pkg/types"
1210
"sigs.k8s.io/controller-runtime/pkg/client"
1311
"sigs.k8s.io/controller-runtime/pkg/controller"
14-
"sigs.k8s.io/controller-runtime/pkg/controller/controllerutil"
1512
"sigs.k8s.io/controller-runtime/pkg/handler"
1613
"sigs.k8s.io/controller-runtime/pkg/manager"
1714
"sigs.k8s.io/controller-runtime/pkg/reconcile"
@@ -83,7 +80,7 @@ type ReconcileVolume struct {
8380
// The Controller will requeue the Request to be processed again if the returned error is non-nil or
8481
// Result.Requeue is true, otherwise upon completion it will remove the work from the queue.
8582
func (r *ReconcileVolume) Reconcile(request reconcile.Request) (reconcile.Result, error) {
86-
reqLogger := log.WithValues("Request.Namespace", request.Namespace, "Request.Name", request.Name)
83+
reqLogger := log.WithValues("Request.Name", request.Name)
8784
reqLogger.Info("Reconciling Volume")
8885

8986
// Fetch the Volume instance
@@ -100,54 +97,5 @@ func (r *ReconcileVolume) Reconcile(request reconcile.Request) (reconcile.Result
10097
return reconcile.Result{}, err
10198
}
10299

103-
// Define a new Pod object
104-
pod := newPodForCR(instance)
105-
106-
// Set Volume instance as the owner and controller
107-
if err := controllerutil.SetControllerReference(instance, pod, r.scheme); err != nil {
108-
return reconcile.Result{}, err
109-
}
110-
111-
// Check if this Pod already exists
112-
found := &corev1.Pod{}
113-
err = r.client.Get(context.TODO(), types.NamespacedName{Name: pod.Name, Namespace: pod.Namespace}, found)
114-
if err != nil && errors.IsNotFound(err) {
115-
reqLogger.Info("Creating a new Pod", "Pod.Namespace", pod.Namespace, "Pod.Name", pod.Name)
116-
err = r.client.Create(context.TODO(), pod)
117-
if err != nil {
118-
return reconcile.Result{}, err
119-
}
120-
121-
// Pod created successfully - don't requeue
122-
return reconcile.Result{}, nil
123-
} else if err != nil {
124-
return reconcile.Result{}, err
125-
}
126-
127-
// Pod already exists - don't requeue
128-
reqLogger.Info("Skip reconcile: Pod already exists", "Pod.Namespace", found.Namespace, "Pod.Name", found.Name)
129100
return reconcile.Result{}, nil
130101
}
131-
132-
// newPodForCR returns a busybox pod with the same name/namespace as the cr
133-
func newPodForCR(cr *storagev1alpha1.Volume) *corev1.Pod {
134-
labels := map[string]string{
135-
"app": cr.Name,
136-
}
137-
return &corev1.Pod{
138-
ObjectMeta: metav1.ObjectMeta{
139-
Name: cr.Name + "-pod",
140-
Namespace: cr.Namespace,
141-
Labels: labels,
142-
},
143-
Spec: corev1.PodSpec{
144-
Containers: []corev1.Container{
145-
{
146-
Name: "busybox",
147-
Image: "busybox",
148-
Command: []string{"sleep", "3600"},
149-
},
150-
},
151-
},
152-
}
153-
}

0 commit comments

Comments
 (0)