syncnode

package
v1.2.16 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Jan 16, 2023 License: MIT Imports: 22 Imported by: 0

README

Node Sync Controller

The Sync Node controller is responsible for sending nodes to persistent layer by polling StorageOS API periodically.

Node Sync Control Loop

The Node sync controller periodically polls the StorageOS control plane API to retrieve a list of nodes. The poll interval defaults to 5s and is tunable via the -api-poll-interval flag.

All K8s nodes will be considered. Controller persists existing nodes and delete orpahn ones.

Prometheus Metrics

The following metrics are collected:

  • storageos_api_request_duration_seconds A histogram of request latencies, partitioned by HTTP request method.
  • storageos_api_requests_total A counter for requests from the api client, partitioned by HTTP request method and response code.
  • storageos_sync_node_duration_seconds Distribution of the length of time taken to sync all nodes.
  • storageos_save_node_duration_seconds Distribution of the length of time taken to save a node.
  • storageos_delete_node_duration_seconds Distribution of the length of time taken to delete a node.

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func RegisterMetrics

func RegisterMetrics()

RegisterMetrics ensures that the package metrics are registered.

Types

type LatencyMetric

type LatencyMetric interface {
	Observe(latency time.Duration)
}

LatencyMetric observes latency.

var (
	// SyncDuration is the latency metric that measures the duration of the
	// node sync.
	SyncDuration LatencyMetric = &latencyAdapter{m: syncLatencyHistogram}

	// SaveDuration is the latency metric that measures the duration of the
	// node save.
	SaveDuration LatencyMetric = &latencyAdapter{m: saveLatencyHistogram}

	// DeleteDuration is the latency metric that measures the duration of the
	// node delete.
	DeleteDuration LatencyMetric = &latencyAdapter{m: saveLatencyHistogram}
)

type Lister

type Lister interface {
	NodeObjects(context.Context) (map[client.ObjectKey]storageos.Object, error)
}

Lister provides access to StorageOS Nodes.

type Reconciler

type Reconciler struct {
	client.Client
	// contains filtered or unexported fields
}

Reconciler is syncing StorageOS nodes into K8s datastore, by polling it periodically.

func NewReconciler

func NewReconciler(
	k8s client.Client,
	api Lister,
	apiReset chan<- struct{},
	apiPollInterval time.Duration,
	recorder record.EventRecorder) *Reconciler

NewReconciler returns a new node syncer.

func (*Reconciler) SetupWithManager

func (r *Reconciler) SetupWithManager(mgr ctrl.Manager) error

SetupWithManager registers with the controller manager.

Since this is an external controller, we don't need to register the controller, just add it as a Runnable so that the manager can control startup and shutdown.

func (*Reconciler) Start

func (r *Reconciler) Start(ctx context.Context) error

Start runs the main reconcile loop until the context is cancelled or there is a fatal error. It implements the controller-runtime Runnable interface so that it can be controlled by controller manager.

The reconcile loop spins up a separated routines for polling the API server and sync nodes into K8s datastore.

Directories

Path Synopsis
Package mocks is a generated GoMock package.
Package mocks is a generated GoMock package.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL