utils

package
v1.5.3 Latest Latest
Warning

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

Go to latest
Published: Apr 16, 2024 License: Apache-2.0 Imports: 19 Imported by: 0

Documentation

Index

Constants

View Source
const (
	// LastAppliedConfigAnnotation is annotation key of last applied configuration
	LastAppliedConfigAnnotation = "pingcap.com/last-applied-configuration"
)

Variables

This section is empty.

Functions

func AddConfigMapDigestSuffix

func AddConfigMapDigestSuffix(cm *corev1.ConfigMap) error

func FindConfigMapNameFromTCAnno added in v1.5.3

func FindConfigMapNameFromTCAnno(ctx context.Context, cmLister corelisters.ConfigMapLister, tc *v1alpha1.TidbCluster, componentType v1alpha1.MemberType, newCm *corev1.ConfigMap) (cmName string, _ error)

FindConfigMapNameFromTCAnno is used to find ConfigMap name from tc.annotations which is saved before deleting STS. If the data of ConfigMap referenced in anno matches the newCm's data return the name in anno otherwise newCm's name.

In some cases, we may need to delete and recreate STS for updating some immutable fields and are expected to keep the name of ConfigMap unchanged to ensure no accidentally restart of pod. For example: Updating storage size, iops or throughput of PVC using by TiKV. Now, the annotation is set by pvc_resizer(not supported yet), pvc_modifier or pvc_replacer, See pkg/manager/utils/statefulset.go:DeleteStatefulSetWithOrphan.

func FindConfigMapVolume

func FindConfigMapVolume(podSpec *corev1.PodSpec, pred func(string) bool) string

FindConfigMapVolume returns the configmap which's name matches the predicate in a PodSpec, empty indicates not found

func SetStatefulSetLastAppliedConfigAnnotation

func SetStatefulSetLastAppliedConfigAnnotation(set *apps.StatefulSet) error

SetStatefulSetLastAppliedConfigAnnotation set last applied config to Statefulset's annotation

func SetUpgradePartition

func SetUpgradePartition(set *apps.StatefulSet, upgradeOrdinal int32)

SetUpgradePartition set statefulSet's rolling update partition

func Sha256Sum

func Sha256Sum(v interface{}) (string, error)

func StatefulSetIsUpgrading

func StatefulSetIsUpgrading(set *apps.StatefulSet) bool

StatefulSetIsUpgrading confirms whether the statefulSet is upgrading phase

func UpdateConfigMapIfNeed

func UpdateConfigMapIfNeed(
	cmLister corelisters.ConfigMapLister,
	configUpdateStrategy v1alpha1.ConfigUpdateStrategy,
	inUseName string,
	desired *corev1.ConfigMap,
) error

UpdateConfigMapIfNeed set the toml field as the old one if they are logically equal.

func UpdateStatefulSet

func UpdateStatefulSet(setCtl controller.StatefulSetControlInterface, object runtime.Object, newSet, oldSet *apps.StatefulSet) error

UpdateStatefulSet is a template function to update the statefulset of components

func UpdateStatefulSetWithPrecheck

func UpdateStatefulSetWithPrecheck(
	deps *controller.Dependencies,
	tc *v1alpha1.TidbCluster,
	reason string,
	newTiDBSet *apps.StatefulSet,
	oldTiDBSet *apps.StatefulSet,
) error

Types

type ContainerBuilder

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

func NewContainerBuilder

func NewContainerBuilder(container *corev1.Container) *ContainerBuilder

func (*ContainerBuilder) AddEnvFroms added in v1.3.5

func (cb *ContainerBuilder) AddEnvFroms(envFroms ...corev1.EnvFromSource)

func (*ContainerBuilder) AddEnvs

func (cb *ContainerBuilder) AddEnvs(envs ...corev1.EnvVar)

func (*ContainerBuilder) AddVolumeMounts

func (cb *ContainerBuilder) AddVolumeMounts(mounts ...corev1.VolumeMount)

func (*ContainerBuilder) Clone

func (cb *ContainerBuilder) Clone() *corev1.Container

func (*ContainerBuilder) Get

func (cb *ContainerBuilder) Get() *corev1.Container

type PodTemplateSpecBuilder

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

func NewPodTemplateSpecBuilder

func NewPodTemplateSpecBuilder(podTemplate *corev1.PodTemplateSpec) *PodTemplateSpecBuilder

func (*PodTemplateSpecBuilder) AddAnnotations

func (b *PodTemplateSpecBuilder) AddAnnotations(annos map[string]string)

func (*PodTemplateSpecBuilder) AddContainers

func (pb *PodTemplateSpecBuilder) AddContainers(containers ...corev1.Container)

AddContainers add container to pod's spec

NOTE: if container slice expand, old ContainerBuilder reference will be outdated.

func (*PodTemplateSpecBuilder) AddLabels

func (b *PodTemplateSpecBuilder) AddLabels(labels map[string]string)

func (*PodTemplateSpecBuilder) AddVolumes

func (b *PodTemplateSpecBuilder) AddVolumes(volumes ...corev1.Volume)

func (*PodTemplateSpecBuilder) Clone

func (*PodTemplateSpecBuilder) ContainerBuilder

func (pb *PodTemplateSpecBuilder) ContainerBuilder(name string) *ContainerBuilder

ContainerBuilder return the specified container builder

NOTE: don't save the builder, it will be outdated if container slice expand

func (*PodTemplateSpecBuilder) Get

type StatefulSetBuilder

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

func NewStatefulSetBuilder

func NewStatefulSetBuilder(sts *apps.StatefulSet) *StatefulSetBuilder

func (*StatefulSetBuilder) AddVolumeClaims

func (sb *StatefulSetBuilder) AddVolumeClaims(pvcs ...corev1.PersistentVolumeClaim)

func (*StatefulSetBuilder) Clone

func (sb *StatefulSetBuilder) Clone() *apps.StatefulSet

func (*StatefulSetBuilder) Get

func (sb *StatefulSetBuilder) Get() *apps.StatefulSet

func (*StatefulSetBuilder) PodTemplateSpecBuilder

func (sb *StatefulSetBuilder) PodTemplateSpecBuilder() *PodTemplateSpecBuilder

Jump to

Keyboard shortcuts

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