Documentation ¶
Index ¶
Constants ¶
This section is empty.
Variables ¶
View Source
var CheckServiceMonitorExists = polardbxv1reconcile.NewStepBinder("CreateServiceMonitorIfNeeded", func(rc *polardbxv1reconcile.Context, flow control.Flow) (reconcile.Result, error) { polardbx := rc.MustGetPolarDBX() labels := convention.ConstLabels(polardbx) var serviceMonitors promv1.ServiceMonitorList err := rc.Client().List(rc.Context(), &serviceMonitors, client.InNamespace(rc.Namespace()), client.MatchingLabels(labels)) if err != nil { return flow.Continue("Unable to get servicemonitor for polardbx, skip!") } if len(serviceMonitors.Items) != 0 { return flow.Error(errors.New("servicemonitor already exists for polardbx"), "Unable to create service monitor for polardbx", "polardbx", polardbx.Name) } return flow.Pass() }, )
View Source
var CreateServiceMonitorIfNeeded = polardbxv1reconcile.NewStepBinder("CreateServiceMonitorIfNeeded", func(rc *polardbxv1reconcile.Context, flow control.Flow) (reconcile.Result, error) { objectFactory := factory.NewObjectFactory(rc) serviceMonitors, err := objectFactory.NewServiceMonitors() if err != nil { return flow.Error(err, "Unable to generate service monitors") } polardbx := rc.MustGetPolarDBX() polardbxmonitor := rc.MustGetPolarDBXMonitor() polardbxmonitor.Labels = convention.ConstLabels(polardbx) rc.SetControllerRefAndUpdate(polardbxmonitor) for role, serviceMonitor := range serviceMonitors { ctrl.SetControllerReference(polardbxmonitor, &serviceMonitor, rc.Scheme()) err = rc.Client().Create(rc.Context(), &serviceMonitor) if err != nil { flow.Logger().Error(err, "Unable to create service monitors for role: "+role) return flow.Error(err, "Unable to create service monitors for role: "+role) } } return flow.Pass() }, )
View Source
var PersistPolarDBXMonitor = polardbxv1reconcile.NewStepBinder("PersistPolarDBXMonitor", func(rc *polardbxv1reconcile.Context, flow control.Flow) (reconcile.Result, error) { polardbxmonitor := rc.MustGetPolarDBXMonitor() err := rc.Client().Update(rc.Context(), polardbxmonitor) if err != nil { return flow.Error(err, "Unable to persist polardbx monitor status") } return flow.Pass() }, )
View Source
var SyncPolarDBXMonitorSpecToStatus = polardbxv1reconcile.NewStepBinder("SyncPolarDBXMonitorSpecToStatus", func(rc *polardbxv1reconcile.Context, flow control.Flow) (reconcile.Result, error) { polardbxMonitor := rc.MustGetPolarDBXMonitor() polardbxMonitor.Status.MonitorSpecSnapshot = polardbxMonitor.Spec.DeepCopy() return flow.Pass() }, )
View Source
var UpdateServiceMonitorIfNeeded = polardbxv1reconcile.NewStepBinder("UpdateServiceMonitorIfNeeded", func(rc *polardbxv1reconcile.Context, flow control.Flow) (reconcile.Result, error) { monitor := rc.MustGetPolarDBXMonitor() polardbx := rc.MustGetPolarDBX() labels := convention.ConstLabels(polardbx) var serviceMonitors promv1.ServiceMonitorList err := rc.Client().List(rc.Context(), &serviceMonitors, client.InNamespace(rc.Namespace()), client.MatchingLabels(labels)) if err != nil { return flow.Error(err, "Unable to get servicemonitor for polardbx", "polardbx", polardbx.Name) } for _, serviceMonitor := range serviceMonitors.Items { serviceMonitor.Spec.Endpoints[0].Interval = fmt.Sprintf("%.0fs", monitor.Spec.MonitorInterval.Seconds()) serviceMonitor.Spec.Endpoints[0].ScrapeTimeout = fmt.Sprintf("%.0fs", monitor.Spec.ScrapeTimeout.Seconds()) err := rc.Client().Update(rc.Context(), serviceMonitor) if err != nil { return flow.Error(err, "Unable to update service monitor", "servicemonitor", serviceMonitor.Name) } } return flow.Pass() }, )
Functions ¶
func TransferMonitorStatusTo ¶
func TransferMonitorStatusTo(status polardbxv1polardbx.MonitorStatus, requeue bool) control.BindFunc
Types ¶
This section is empty.
Click to show internal directories.
Click to hide internal directories.