-
Notifications
You must be signed in to change notification settings - Fork 18
/
machinehealthcheck_controller.go
62 lines (50 loc) · 2 KB
/
machinehealthcheck_controller.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
package controllers
import (
"context"
"github.com/go-logr/logr"
"github.com/openshift/api/machine/v1beta1"
"k8s.io/apimachinery/pkg/runtime"
"k8s.io/client-go/tools/record"
ctrl "sigs.k8s.io/controller-runtime"
"sigs.k8s.io/controller-runtime/pkg/client"
"github.com/medik8s/node-healthcheck-operator/controllers/cluster"
"github.com/medik8s/node-healthcheck-operator/controllers/mhc"
)
// MachineHealthCheckReconciler reconciles a MachineHealthCheck object
type MachineHealthCheckReconciler struct {
client.Client
Log logr.Logger
Scheme *runtime.Scheme
Recorder record.EventRecorder
ClusterUpgradeStatusChecker cluster.UpgradeChecker
MHCChecker mhc.Checker
}
// +kubebuilder:rbac:groups=machine.openshift.io,resources=machinehealthchecks,verbs=get;list;watch
// Reconcile is part of the main kubernetes reconciliation loop which aims to
// move the current state of the cluster closer to the desired state.
func (r *MachineHealthCheckReconciler) Reconcile(ctx context.Context, req ctrl.Request) (ctrl.Result, error) {
//log := r.Log.WithValues("MachineHealthCheck", req.NamespacedName)
// update MHCChecker status
r.MHCChecker.UpdateStatus()
result := ctrl.Result{}
// fetch mhc
//mhc := &v1beta1.MachineHealthCheck{}
//err := r.Get(ctx, req.NamespacedName, mhc)
//if err != nil {
// if apierrors.IsNotFound(err) {
// log.Info("MachineHealthCheck not found", "name", req.Name, "namespace", req.Namespace)
// return result, nil
// }
// log.Error(err, "failed fetching MachineHealthCheck", "name", req.Name, "namespace", req.Namespace)
// return result, err
//}
//
//log.Info("reconciling MachineHealthCheck", "name", req.Name, "namespace", req.Namespace)
return result, nil
}
// SetupWithManager sets up the controller with the Manager.
func (r *MachineHealthCheckReconciler) SetupWithManager(mgr ctrl.Manager) error {
return ctrl.NewControllerManagedBy(mgr).
For(&v1beta1.MachineHealthCheck{}).
Complete(r)
}