MCPcopy
hub / github.com/rook/rook / reconcile

Method reconcile

pkg/operator/ceph/nvmeof/controller.go:164–278  ·  view source on GitHub ↗
(request reconcile.Request)

Source from the content-addressed store, hash-verified

162}
163
164func (r *ReconcileCephNVMeOFGateway) reconcile(request reconcile.Request) (reconcile.Result, cephv1.CephNVMeOFGateway, error) {
165 cephNVMeOFGateway := &cephv1.CephNVMeOFGateway{}
166 err := r.client.Get(r.opManagerContext, request.NamespacedName, cephNVMeOFGateway)
167 if err != nil {
168 if kerrors.IsNotFound(err) {
169 return reconcile.Result{}, *cephNVMeOFGateway, nil
170 }
171 return reconcile.Result{}, *cephNVMeOFGateway, errors.Wrap(err, "failed to get CephNVMeOFGateway")
172 }
173
174 observedGeneration := cephNVMeOFGateway.ObjectMeta.Generation
175
176 generationUpdated, err := opcontroller.AddFinalizerIfNotPresent(r.opManagerContext, r.client, cephNVMeOFGateway)
177 if err != nil {
178 return reconcile.Result{}, *cephNVMeOFGateway, errors.Wrap(err, "failed to add finalizer")
179 }
180 if generationUpdated {
181 return reconcile.Result{}, *cephNVMeOFGateway, nil
182 }
183
184 if cephNVMeOFGateway.Status == nil {
185 cephxUninitialized := keyring.UninitializedCephxStatus()
186 err := r.updateStatus(k8sutil.ObservedGenerationNotAvailable, request.NamespacedName, &cephxUninitialized, k8sutil.EmptyStatus)
187 if err != nil {
188 return opcontroller.ImmediateRetryResult, *cephNVMeOFGateway, errors.Wrapf(err, "failed set empty status")
189 }
190 cephNVMeOFGateway.Status = &cephv1.NVMeOFGatewayStatus{
191 Status: cephv1.Status{},
192 Cephx: cephv1.LocalCephxStatus{Daemon: cephxUninitialized},
193 }
194 }
195
196 cephCluster, isReadyToReconcile, cephClusterExists, reconcileResponse := opcontroller.IsReadyToReconcile(r.opManagerContext, r.client, request.NamespacedName, controllerName)
197
198 if !isReadyToReconcile {
199 if !cephNVMeOFGateway.GetDeletionTimestamp().IsZero() && !cephClusterExists {
200 err := opcontroller.RemoveFinalizer(r.opManagerContext, r.client, cephNVMeOFGateway)
201 if err != nil {
202 return reconcile.Result{}, *cephNVMeOFGateway, errors.Wrap(err, "failed to remove finalizer")
203 }
204 r.recorder.Eventf(cephNVMeOFGateway, nil, v1.EventTypeNormal, string(cephv1.ReconcileSucceeded), string(cephv1.ReconcileSucceeded), "successfully removed finalizer")
205 return reconcile.Result{}, *cephNVMeOFGateway, nil
206 }
207 return reconcileResponse, *cephNVMeOFGateway, nil
208 }
209 r.cephClusterSpec = &cephCluster.Spec
210
211 r.clusterInfo, _, _, err = opcontroller.LoadClusterInfo(r.context, r.opManagerContext, request.NamespacedName.Namespace, r.cephClusterSpec)
212 if err != nil {
213 return reconcile.Result{}, *cephNVMeOFGateway, errors.Wrap(err, "failed to populate cluster info")
214 }
215
216 if !cephNVMeOFGateway.GetDeletionTimestamp().IsZero() {
217 logger.Infof("deleting ceph nvmeof gateway %q", cephNVMeOFGateway.Name)
218 r.recorder.Eventf(cephNVMeOFGateway, nil, v1.EventTypeNormal, string(cephv1.ReconcileStarted), string(cephv1.ReconcileStarted), "deleting CephNVMeOFGateway %q", cephNVMeOFGateway.Name)
219
220 runningCephVersion, err := cephclient.LeastUptodateDaemonVersion(r.context, r.clusterInfo, config.MonType)
221 if err != nil {

Callers 1

ReconcileMethod · 0.95

Calls 10

updateStatusMethod · 0.95
UninitializedCephxStatusFunction · 0.92
NewOwnerInfoFunction · 0.92
ShouldRotateCephxKeysFunction · 0.92
UpdatedCephxStatusFunction · 0.92
validateGatewayFunction · 0.85
ErrorMethod · 0.80
GetMethod · 0.65
InfofMethod · 0.65

Tested by

no test coverage detected