miscellaneous

package
v0.31.1 Latest Latest
Warning

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

Go to latest
Published: Nov 13, 2024 License: Apache-2.0 Imports: 34 Imported by: 0

Documentation

Index

Constants

View Source
const (
	// NoLeaderState defines the state when etcd returns LeaderID as 0.
	NoLeaderState uint64 = 0
	// EtcdConfigFilePath is the file path where the etcd config map is mounted.
	EtcdConfigFilePath string = "/var/etcd/config/etcd.conf.yaml"
	// ClusterStateNew defines the "new" state of etcd cluster.
	ClusterStateNew = "new"
	// ClusterStateExisting defines the "existing" state of etcd cluster.
	ClusterStateExisting = "existing"

	// ScaledToMultiNodeAnnotationKey defines annotation key for scale-up to multi-node cluster.
	ScaledToMultiNodeAnnotationKey = "gardener.cloud/scaled-to-multi-node"
)

Variables

This section is empty.

Functions

func CheckIfLearnerPresent added in v0.29.0

func CheckIfLearnerPresent(ctx context.Context, cli etcdClient.ClusterCloser) (bool, error)

CheckIfLearnerPresent checks whether a learner(non-voting) member present or not.

func ContainsBackup added in v0.29.0

func ContainsBackup(store brtypes.SnapStore, logger *logrus.Logger) bool

ContainsBackup checks whether the backup is present in given SnapStore or not.

func CreateBackoff added in v0.29.0

func CreateBackoff(retryPeriod time.Duration, steps int) wait.Backoff

CreateBackoff returns the backoff with Factor=2 with upper limit of 120sec.

func DoPromoteMember added in v0.29.0

func DoPromoteMember(ctx context.Context, member *etcdserverpb.Member, cli etcdClient.ClusterCloser, logger *logrus.Entry) error

DoPromoteMember promotes a given learner to a voting member.

func GetAllEtcdEndpoints added in v0.29.0

func GetAllEtcdEndpoints(ctx context.Context, client etcdClient.ClusterCloser, etcdConnectionConfig *brtypes.EtcdConnectionConfig, logger *logrus.Entry) ([]string, error)

GetAllEtcdEndpoints returns the endPoints of all etcd-member.

func GetBackupLeaderEndPoint added in v0.29.0

func GetBackupLeaderEndPoint(endPoints []string, port uint) (string, error)

GetBackupLeaderEndPoint takes etcd leader endpoint and portNo. of backup-restore and returns the backupLeader endpoint.

func GetClusterSize added in v0.29.0

func GetClusterSize(cluster string) (int, error)

GetClusterSize returns the size of a cluster passed as a string

func GetConfigFilePath added in v0.29.0

func GetConfigFilePath() string

GetConfigFilePath returns the path of the etcd configuration file

func GetEnvVarOrError added in v0.29.0

func GetEnvVarOrError(varName string) (string, error)

GetEnvVarOrError returns the value of specified environment variable or error if it's not defined.

func GetFakeKubernetesClientSet added in v0.29.0

func GetFakeKubernetesClientSet() client.Client

GetFakeKubernetesClientSet creates a fake client set. To be used for unit tests

func GetFilteredBackups added in v0.29.0

func GetFilteredBackups(store brtypes.SnapStore, maxBackups int, filter func(snaps brtypes.Snapshot) bool) (brtypes.SnapList, error)

GetFilteredBackups returns sorted by date (new -> old) SnapList. It will also filter the snapshots that should be included or not using the filter function. If the filter is nil it will return all snapshots. Also, maxBackups can be used to target only the last N snapshots (-1 = all).

func GetInitialClusterStateIfScaleup added in v0.29.0

func GetInitialClusterStateIfScaleup(ctx context.Context, logger logrus.Entry, clientSet client.Client, podName string, podNS string) (*string, error)

GetInitialClusterStateIfScaleup checks if it is the Scale-up scenario and returns the cluster state either `new` or `existing`.

func GetKubernetesClientSetOrError added in v0.29.0

func GetKubernetesClientSetOrError() (client.Client, error)

GetKubernetesClientSetOrError creates and returns a kubernetes clientset or an error if creation fails

func GetLatestFullSnapshotAndDeltaSnapList

func GetLatestFullSnapshotAndDeltaSnapList(store brtypes.SnapStore) (*brtypes.Snapshot, brtypes.SnapList, error)

GetLatestFullSnapshotAndDeltaSnapList returns the latest snapshot

func GetLeader added in v0.29.0

func GetLeader(ctx context.Context, clientMaintenance etcdClient.MaintenanceCloser, client etcdClient.ClusterCloser, endpoint string) (uint64, []string, error)

GetLeader will return the LeaderID as well as url of etcd leader.

func GetMemberPeerURL added in v0.30.2

func GetMemberPeerURL(configFile string, podName string) (string, error)

GetMemberPeerURL returns the peerURL from fiven configuration file provided to etcd member.

func GetPrevScheduledSnapTime added in v0.29.0

func GetPrevScheduledSnapTime(nextSnapSchedule time.Time, timeWindow float64) time.Time

GetPrevScheduledSnapTime returns the previous schedule snapshot time. TODO: Previous full snapshot time should be calculated on basis of previous cron schedule of full snapshot.

func GetStatefulSet added in v0.29.0

func GetStatefulSet(ctx context.Context, clientSet client.Client, podNamespace string, podName string) (*appsv1.StatefulSet, error)

GetStatefulSet gets the StatefulSet with the name podName in podNamespace namespace. It will return if there is any error or the StatefulSet is not found.

func IsAnnotationPresent added in v0.29.0

func IsAnnotationPresent(sts *appsv1.StatefulSet, annotation string) bool

IsAnnotationPresent checks the presence of given annotation in a given statefulset.

func IsBackupBucketEmpty added in v0.29.0

func IsBackupBucketEmpty(snapStoreConfig *brtypes.SnapstoreConfig, logger *logrus.Logger) bool

IsBackupBucketEmpty checks whether the backup bucket is empty or not.

func IsEtcdClusterHealthy added in v0.29.0

func IsEtcdClusterHealthy(ctx context.Context, client etcdClient.MaintenanceCloser, etcdConnectionConfig *brtypes.EtcdConnectionConfig, etcdEndpoints []string, logger *logrus.Entry) (bool, error)

IsEtcdClusterHealthy checks whether all members of etcd cluster are in healthy state or not.

func IsMultiNode added in v0.29.0

func IsMultiNode(logger *logrus.Entry) bool

IsMultiNode determines whether a pod is part of a multi node setup or not This is determined by checking the `initial-cluster` of the etcd configmap to check the number of members expected

func IsPeerURLTLSEnabled added in v0.29.0

func IsPeerURLTLSEnabled() (bool, error)

IsPeerURLTLSEnabled checks whether the peer address is TLS enabled or not.

func ParsePeerURL added in v0.29.0

func ParsePeerURL(initialAdvertisePeerURLs, podName string) (string, error)

ParsePeerURL forms a PeerURL, given podName by parsing the initial-advertise-peer-urls

func ProbeEtcd added in v0.29.0

func ProbeEtcd(ctx context.Context, clientFactory etcdClient.Factory, logger *logrus.Entry) error

ProbeEtcd probes the etcd endpoint to check if an etcd is available

func ReadConfigFileAsMap added in v0.29.0

func ReadConfigFileAsMap(path string) (map[string]interface{}, error)

ReadConfigFileAsMap reads the config file given a path and converts it into a map[string]interface{}

func RemoveDir added in v0.29.0

func RemoveDir(dir string) error

RemoveDir removes the directory(if exist) and do nothing if directory doesn't exist.

func RemoveMemberFromCluster added in v0.29.0

func RemoveMemberFromCluster(ctx context.Context, cli etcdClient.ClusterCloser, memberID uint64, logger *logrus.Entry) error

RemoveMemberFromCluster removes member of given ID from etcd cluster.

func RestartEtcdWrapper added in v0.30.2

func RestartEtcdWrapper(ctx context.Context, tlsEnabled bool, etcdConnectionConfig *brtypes.EtcdConnectionConfig) error

RestartEtcdWrapper is to call the "/stop" endpoint of etcd-wrapper to restart the etcd-wrapper container.

func SleepWithContext added in v0.29.0

func SleepWithContext(ctx context.Context, sleepFor time.Duration) error

SleepWithContext sleeps for a determined period while respecting a context

func StartEmbeddedEtcd added in v0.29.0

func StartEmbeddedEtcd(logger *logrus.Entry, ro *brtypes.RestoreOptions) (*embed.Etcd, error)

StartEmbeddedEtcd starts the embedded etcd server.

Types

This section is empty.

Jump to

Keyboard shortcuts

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