helpers

package
v0.0.0-...-5fa7f0c Latest Latest
Warning

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

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

Documentation

Index

Constants

View Source
const (
	DashboardConfigName          = "opensearch_dashboards.yml"
	DashboardChecksumName        = "checksum/dashboards.yml"
	ClusterLabel                 = "opster.io/opensearch-cluster"
	NodePoolLabel                = "opster.io/opensearch-nodepool"
	OsUserNameAnnotation         = "opensearchuser/name"
	OsUserNamespaceAnnotation    = "opensearchuser/namespace"
	DnsBaseEnvVariable           = "DNS_BASE"
	ParallelRecoveryEnabled      = "PARALLEL_RECOVERY_ENABLED"
	SkipInitContainerEnvVariable = "SKIP_INIT_CONTAINER"
)

Variables

This section is empty.

Functions

func BuildMainCommand

func BuildMainCommand(installerBinary string, pluginsList []string, batchMode bool, entrypoint string) []string

func BuildMainCommandOSD

func BuildMainCommandOSD(installerBinary string, pluginsList []string, entrypoint string) []string

func CalculateJvmHeapSize

func CalculateJvmHeapSize(nodePool *opsterv1.NodePool) string

func CheckVolumeExists

func CheckVolumeExists(volumes []corev1.Volume, volumeMounts []corev1.VolumeMount, secretName string, volumeName string) bool

func ClusterDnsBase

func ClusterDnsBase() string

func CompareVersions

func CompareVersions(v1 string, v2 string) bool

Compares whether v1 is LessThan v2

func ComponentStatusEqual

func ComponentStatusEqual(left opsterv1.ComponentStatus, right opsterv1.ComponentStatus) bool

func ContainsString

func ContainsString(slice []string, s string) bool

func CountPVCsForNodePool

func CountPVCsForNodePool(k8sClient k8s.K8sClient, cr *opsterv1.OpenSearchCluster, nodePool *opsterv1.NodePool) (int, error)

Count the number of PVCs created for the given NodePool

func CountRunningPodsForNodePool

func CountRunningPodsForNodePool(k8sClient k8s.K8sClient, cr *opsterv1.OpenSearchCluster, nodePool *opsterv1.NodePool) (int, error)

Count the number of pods running and ready and not terminating for a given nodePool

func DeleteDashboardsDeployment

func DeleteDashboardsDeployment(k8sClient k8s.K8sClient, clusterName, clusterNamespace string) error

DeleteDashboardsDeployment deletes the OSD deployment along with all its pods

func DeleteSTSForNodePool

func DeleteSTSForNodePool(k8sClient k8s.K8sClient, nodePool opsterv1.NodePool, clusterName, clusterNamespace string) error

DeleteSTSForNodePool deletes the sts for the corresponding nodePool

func DeleteSecurityUpdateJob

func DeleteSecurityUpdateJob(k8sClient k8s.K8sClient, clusterName, clusterNamespace string) error

DeleteSecurityUpdateJob deletes the securityconfig update job

func DeleteStuckPodWithOlderRevision

func DeleteStuckPodWithOlderRevision(k8sClient k8s.K8sClient, sts *appsv1.StatefulSet) error

DeleteStuckPodWithOlderRevision deletes the crashed pod only if there is any update in StatefulSet.

func DiffSlice

func DiffSlice(leftSlice, rightSlice []string) []string

Get leftSlice strings not in rightSlice

func FindByPath

func FindByPath(obj interface{}, keys []string) (interface{}, bool)

func GetDashboardsDeployment

func GetDashboardsDeployment(k8sClient k8s.K8sClient, clusterName, clusterNamespace string) (*appsv1.Deployment, error)

func GetField

func GetField(v *appsv1.StatefulSetSpec, field string) interface{}

func GetPodWithOlderRevision

func GetPodWithOlderRevision(k8sClient k8s.K8sClient, sts *appsv1.StatefulSet) (*corev1.Pod, error)

GetPodWithOlderRevision fetches the pod that is not having the updated revision.

func GetSTSForNodePool

func GetSTSForNodePool(k8sClient k8s.K8sClient, nodePool opsterv1.NodePool, clusterName, clusterNamespace string) (*appsv1.StatefulSet, error)

GetSTSForNodePool returns the corresponding sts for a given nodePool and cluster name

func HasDataRole

func HasDataRole(nodePool *opsterv1.NodePool) bool

func HasKeyWithBytes

func HasKeyWithBytes(data map[string][]byte, key string) bool

func HasManagerRole

func HasManagerRole(nodePool *opsterv1.NodePool) bool

func MapClusterRole

func MapClusterRole(role string, ver string) string

Map any cluster roles that have changed between major OpenSearch versions

func MapClusterRoles

func MapClusterRoles(roles []string, version string) []string

func MergeConfigs

func MergeConfigs(left map[string]string, right map[string]string) map[string]string

func NewMockPKI

func NewMockPKI() tls.PKI

func ParallelRecoveryMode

func ParallelRecoveryMode() bool

func RemoveDuplicateStrings

func RemoveDuplicateStrings(strSlice []string) []string

func ReplicaHostName

func ReplicaHostName(currentSts appsv1.StatefulSet, repNum int32) string

func ResolveClusterManagerRole

func ResolveClusterManagerRole(ver string) string

func ResolveDashboardsImage

func ResolveDashboardsImage(cr *opsterv1.OpenSearchCluster) (result opsterv1.ImageSpec)

func ResolveImage

func ResolveImage(cr *opsterv1.OpenSearchCluster, nodePool *opsterv1.NodePool) (result opsterv1.ImageSpec)

func ResolveInitHelperImage

func ResolveInitHelperImage(cr *opsterv1.OpenSearchCluster) (result opsterv1.ImageSpec)

func SkipInitContainer

func SkipInitContainer() bool

func SortedJsonKeys

func SortedJsonKeys(obj *apiextensionsv1.JSON) (*apiextensionsv1.JSON, error)

SortedJsonKeys helps to sort JSON object keys E.g. if API returns unsorted JSON object like this: {"resp": {"b": "2", "a": "1"}} this function could sort it and return {"resp": {"a": "1", "b": "2"}} This is useful for comparing Opensearch CRD objects and API responses

func SortedKeys

func SortedKeys(input map[string]string) []string

Return the keys of the input map in sorted order Can be used if you want to iterate over a map but have a stable order

func TranslateComponentTemplateToRequest

func TranslateComponentTemplateToRequest(spec v1.OpensearchComponentTemplateSpec) requests.ComponentTemplate

TranslateComponentTemplateToRequest rewrites the CRD format to the gateway format

func TranslateDatastreamToRequest

func TranslateDatastreamToRequest(spec *v1.OpensearchDatastreamSpec) *requests.Datastream

TranslateDatastreamToRequest rewrites the CRD format to the gateway format

func TranslateIndexTemplateToRequest

func TranslateIndexTemplateToRequest(spec v1.OpensearchIndexTemplateSpec) requests.IndexTemplate

TranslateIndexTemplateToRequest rewrites the CRD format to the gateway format

func TranslateIndexToRequest

func TranslateIndexToRequest(spec v1.OpensearchIndexSpec) requests.Index

TranslateIndexToRequest rewrites the CRD format to the gateway format

func UpgradeInProgress

func UpgradeInProgress(status opsterv1.ClusterStatus) bool

func UsernameAndPassword

func UsernameAndPassword(k8sClient k8s.K8sClient, cr *opsterv1.OpenSearchCluster) (string, string, error)

func VersionCheck

func VersionCheck(instance *opsterv1.OpenSearchCluster) (int32, int32, string)

Function to help identify httpPort, securityConfigPort and securityConfigPath for 1.x and 2.x OpenSearch Operator.

func WaitForSTSDelete

func WaitForSTSDelete(k8sClient k8s.K8sClient, obj *appsv1.StatefulSet) error

Delete a STS with cascade=orphan and wait until it is actually deleted from the kubernetes API

func WaitForSTSReplicas

func WaitForSTSReplicas(k8sClient k8s.K8sClient, obj *appsv1.StatefulSet, replicas int32) error

Wait for max 30s until a STS has at least the given number of replicas

func WaitForSTSStatus

func WaitForSTSStatus(k8sClient k8s.K8sClient, obj *appsv1.StatefulSet) (*appsv1.StatefulSet, error)

Wait for max 30s until a STS has a normal status (CurrentRevision != "")

func WorkingPodForRollingRestart

func WorkingPodForRollingRestart(k8sClient k8s.K8sClient, sts *appsv1.StatefulSet) (string, error)

Types

type CertMock

type CertMock struct{}

func (*CertMock) CertData

func (cert *CertMock) CertData() []byte

func (*CertMock) CreateAndSignCertificate

func (ca *CertMock) CreateAndSignCertificate(commonName string, orgUnit string, dnsnames []string) (cert tls.Cert, err error)

func (*CertMock) KeyData

func (cert *CertMock) KeyData() []byte

func (*CertMock) SecretData

func (cert *CertMock) SecretData(ca tls.Cert) map[string][]byte

func (*CertMock) SecretDataCA

func (cert *CertMock) SecretDataCA() map[string][]byte

type MockEventRecorder

type MockEventRecorder struct{}

A simple mock to use whenever a record.EventRecorder is needed for a test

func (*MockEventRecorder) AnnotatedEventf

func (r *MockEventRecorder) AnnotatedEventf(object runtime.Object, annotations map[string]string, eventtype, reason, messageFmt string, args ...interface{})

func (*MockEventRecorder) Event

func (r *MockEventRecorder) Event(object runtime.Object, eventtype, reason, message string)

func (*MockEventRecorder) Eventf

func (r *MockEventRecorder) Eventf(object runtime.Object, eventtype, reason, messageFmt string, args ...interface{})

type PkiMock

type PkiMock struct{}

func (*PkiMock) CAFromSecret

func (pki *PkiMock) CAFromSecret(data map[string][]byte) tls.Cert

func (*PkiMock) GenerateCA

func (pki *PkiMock) GenerateCA(name string) (ca tls.Cert, err error)

Jump to

Keyboard shortcuts

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