controller

package
v0.0.0-...-9e299b5 Latest Latest
Warning

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

Go to latest
Published: Oct 25, 2021 License: Apache-2.0 Imports: 40 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type CLIConfig

type CLIConfig struct {
	PrintVersion bool
	// The number of workers that are allowed to sync concurrently.
	// Larger number = more responsive management, but more CPU
	// (and network) load
	Workers int
	// Controls whether operator should manage kubernetes cluster
	LeaseDuration time.Duration
	RenewDuration time.Duration
	RetryPeriod   time.Duration
	WaitDuration  time.Duration
	// ResyncDuration is the resync time of informer
	ResyncDuration time.Duration
	// Defines whether tidb operator run in test mode, test mode is
	// only open when test
	TestMode bool
	// Selector is used to filter CR labels to decide
	// what resources should be watched and synced by controller
	Selector string

	// Default config read from config file
	Config Config

	InstanceFetchInterval   time.Duration
	ReadonlyAvailPercentage float64
	ProxyComponentHttpPort  int
	// contains filtered or unexported fields
}

CLIConfig is used save all configuration read from command line parameters

func DefaultCLIConfig

func DefaultCLIConfig() *CLIConfig

DefaultCLIConfig returns the default command line configuration

func (*CLIConfig) AddFlag

func (c *CLIConfig) AddFlag(_ *flag.FlagSet)

AddFlag adds a flag for setting global feature gates to the specified FlagSet.

type Config

type Config struct {
	Duration    Duration    `yaml:"duration"`
	Storage     Storage     `yaml:"storage"`
	TiDBCluster TiDBCluster `yaml:"tidbCluster"`
	Monitor     Monitor     `yaml:"monitor"`
	Proxy       Proxy       `yaml:"proxy"`
}

type Controls

type Controls struct {
	ServerlessControl ServerlessDBControlInterface
}

type Dependencies

type Dependencies struct {
	// CLIConfig represents all parameters read from command line
	CLIConfig *CLIConfig

	RestConfig *restclient.Config
	// Operator client interface
	Clientset versioned.Interface
	// pingcap client interface
	PingcapClientset pcversioned.Interface
	// Kubernetes client interface
	KubeClientset                  kubernetes.Interface
	GenericClient                  client.Client
	InformerFactory                informers.SharedInformerFactory
	PingcapInformerFactory         pcinformers.SharedInformerFactory
	KubeInformerFactory            kubeinformers.SharedInformerFactory
	LabelFilterKubeInformerFactory kubeinformers.SharedInformerFactory
	Recorder                       record.EventRecorder

	// Listers
	PodLister              corelisterv1.PodLister
	JobLister              batchlisters.JobLister
	ServiceLister          corelisterv1.ServiceLister
	SecretLister           corelisterv1.SecretLister
	PVCLister              corelisterv1.PersistentVolumeClaimLister
	DeploymentLister       appslisters.DeploymentLister
	StatefulSetLister      appslisters.StatefulSetLister
	ServerlessDBLister     listers.ServerlessDBLister
	TiDBClusterLister      pclisters.TidbClusterLister
	TiDBMonitorLister      pclisters.TidbMonitorLister
	TiDBInitializerLister  pclisters.TidbInitializerLister
	PcBackupLister         pclisters.BackupLister
	PcBackupScheduleLister pclisters.BackupScheduleLister
	PcRestoreLister        pclisters.RestoreLister

	// Controls
	Controls
}

Dependencies is used to store all shared dependent resources to avoid pass parameters everywhere.

func NewDependencies

func NewDependencies(ns string, cliCfg *CLIConfig, restConfig *restclient.Config, clientset versioned.Interface,
	pcCliset pcversioned.Interface, kubeClientset kubernetes.Interface, genericCli client.Client) *Dependencies

NewDependencies is used to construct the dependencies

func NewFakeDependencies

func NewFakeDependencies() *Dependencies

NewFakeDependencies returns a fake dependencies for testing

type Duration

type Duration struct {
	CreateTimeout string `yaml:"createTimeout"`
	RestartCheck  string `yaml:"restartCheck"`
	BackupTimeout string `yaml:"backupTimeout"`
}

type FakeServerlessDBControl

type FakeServerlessDBControl struct {
	SlLister  listers.ServerlessDBLister
	SlIndexer cache.Indexer
	// contains filtered or unexported fields
}

FakeTidbClusterControl is a fake TidbClusterControlInterface

func NewFakeServerlessDBControl

func NewFakeServerlessDBControl(slInformer informers.ServerlessDBInformer) *FakeServerlessDBControl

NewFakeTidbClusterControl returns a FakeTidbClusterControl

func (*FakeServerlessDBControl) Create

func (*FakeServerlessDBControl) Patch

func (c *FakeServerlessDBControl) Patch(tc *v1alpha1.ServerlessDB, data []byte, subresources ...string) (result *v1alpha1.ServerlessDB, err error)

func (*FakeServerlessDBControl) RecordServerlessDBEvent

func (c *FakeServerlessDBControl) RecordServerlessDBEvent(verb, message string, object runtime.Object, err error)

func (*FakeServerlessDBControl) Update

func (*FakeServerlessDBControl) UpdateServerlessDB

type Monitor

type Monitor struct {
	Specification         `yaml:",inline"`
	PrometheusReserveDays int `yaml:"prometheusReserveDays"`
}

type Proxy

type Proxy struct {
	Specification `yaml:",inline"`
}

type RequestTracker

type RequestTracker struct {
	// contains filtered or unexported fields
}

RequestTracker is used by unit test for mocking request error

type ResourceList

type ResourceList struct {
	Cpu     string `yaml:"cpu"`
	Memory  string `yaml:"memory"`
	Storage string `yaml:"storage,omitempty"`
}

type ResourceRequirements

type ResourceRequirements struct {
	Limits   ResourceList `yaml:"limits"`
	Requests ResourceList `yaml:"requests"`
}

ResourceRequirements describes the compute resource requirements.

func (*ResourceRequirements) ParseResource

type ServerlessDBControlInterface

type ServerlessDBControlInterface interface {
	Update(db *v1alpha1.ServerlessDB) (*v1alpha1.ServerlessDB, error)
	UpdateServerlessDB(*v1alpha1.ServerlessDB, *v1alpha1.ServerlessDBStatus, *v1alpha1.ServerlessDBStatus) (*v1alpha1.ServerlessDB, error)
	Create(*v1alpha1.ServerlessDB) error
	Patch(tc *v1alpha1.ServerlessDB, data []byte, subresources ...string) (result *v1alpha1.ServerlessDB, err error)
	RecordServerlessDBEvent(verb, message string, object runtime.Object, err error)
}

ServerlessDBControlInterface manages ServerlessDB

func NewRealServerlessDBControl

func NewRealServerlessDBControl(cli versioned.Interface,
	dbLister listers.ServerlessDBLister,
	recorder record.EventRecorder) ServerlessDBControlInterface

NewRealServerlessDBControl creates a new ServerlessDBControlInterface

type Specification

type Specification struct {
	Enable               bool   `yaml:"enable"`
	Image                string `yaml:"image"`
	Replicas             int32  `yaml:"replicas"`
	ResourceRequirements `yaml:",inline"`
}

type Storage

type Storage struct {
	StorageClassName string `yaml:"storageClassName"`
}

type TiDBCluster

type TiDBCluster struct {
	Version string        `yaml:"version"`
	PD      Specification `yaml:"pd"`
	TiDB    Specification `yaml:"tidb"`
	TiKV    Specification `yaml:"tikv"`
}

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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