in operator/controllers/operator/storage_controller.go [71:108]
func (r *StorageReconciler) Reconcile(ctx context.Context, req ctrl.Request) (ctrl.Result, error) {
log := runtimelog.FromContext(ctx)
log.Info("=====================storage reconcile started================================")
storage := operatorv1alpha1.Storage{}
if err := r.Client.Get(ctx, req.NamespacedName, &storage); err != nil {
return ctrl.Result{}, client.IgnoreNotFound(err)
}
if storage.Spec.ConnectType == "external" {
return ctrl.Result{RequeueAfter: schedDuration}, nil
}
r.createCert(ctx, log, &storage)
r.checkSecurity(ctx, log, &storage)
ff, err := r.FileRepo.GetFilesRecursive(storage.Spec.Type + "/templates")
if err != nil {
log.Error(err, "failed to load resource templates")
return ctrl.Result{}, err
}
app := kubernetes.Application{
Client: r.Client,
FileRepo: r.FileRepo,
CR: &storage,
GVK: operatorv1alpha1.GroupVersion.WithKind("Storage"),
Recorder: r.Recorder,
TmplFunc: tmplFunc(),
}
if err := app.ApplyAll(ctx, ff, log); err != nil {
return ctrl.Result{}, err
}
if err := r.checkState(ctx, log, &storage); err != nil {
log.Error(err, "failed to check sub resources state")
return ctrl.Result{}, err
}
return ctrl.Result{RequeueAfter: schedDuration}, nil
}