@@ -6,12 +6,9 @@ import (
6
6
storagev1alpha1 "github.com/scality/metalk8s/storage-operator/pkg/apis/storage/v1alpha1"
7
7
corev1 "k8s.io/api/core/v1"
8
8
"k8s.io/apimachinery/pkg/api/errors"
9
- metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
10
9
"k8s.io/apimachinery/pkg/runtime"
11
- "k8s.io/apimachinery/pkg/types"
12
10
"sigs.k8s.io/controller-runtime/pkg/client"
13
11
"sigs.k8s.io/controller-runtime/pkg/controller"
14
- "sigs.k8s.io/controller-runtime/pkg/controller/controllerutil"
15
12
"sigs.k8s.io/controller-runtime/pkg/handler"
16
13
"sigs.k8s.io/controller-runtime/pkg/manager"
17
14
"sigs.k8s.io/controller-runtime/pkg/reconcile"
@@ -83,7 +80,7 @@ type ReconcileVolume struct {
83
80
// The Controller will requeue the Request to be processed again if the returned error is non-nil or
84
81
// Result.Requeue is true, otherwise upon completion it will remove the work from the queue.
85
82
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 )
87
84
reqLogger .Info ("Reconciling Volume" )
88
85
89
86
// Fetch the Volume instance
@@ -100,54 +97,5 @@ func (r *ReconcileVolume) Reconcile(request reconcile.Request) (reconcile.Result
100
97
return reconcile.Result {}, err
101
98
}
102
99
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 )
129
100
return reconcile.Result {}, nil
130
101
}
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