util

package
v0.9.1-beta.14 Latest Latest
Warning

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

Go to latest
Published: Aug 8, 2024 License: AGPL-3.0 Imports: 20 Imported by: 1

Documentation

Index

Constants

View Source
const (
	RespFieldEvent   = "event"
	RespFieldMessage = "message"
	RespTypMeta      = "metadata"
	RespEveSucc      = "Success"
	RespEveFail      = "Failed"

	GetOperation    OperationKind = "get"
	CreateOperation OperationKind = "create"
	DeleteOperation OperationKind = "delete"
	ListOperation   OperationKind = "list"

	CheckRunningOperation OperationKind = "checkRunning"
	HealthyCheckOperation OperationKind = "healthyCheck"
	CheckRoleOperation    OperationKind = "checkRole"
	GetRoleOperation      OperationKind = "getRole"
	GetLagOperation       OperationKind = "getLag"
	SwitchoverOperation   OperationKind = "switchover"
	ExecOperation         OperationKind = "exec"
	QueryOperation        OperationKind = "query"
	CloseOperation        OperationKind = "close"

	LockOperation    OperationKind = "lockInstance"
	UnlockOperation  OperationKind = "unlockInstance"
	VolumeProtection OperationKind = "volumeProtection"

	// for component
	PostProvisionOperation OperationKind = "postProvision"
	PreTerminateOperation  OperationKind = "preTerminate"

	// actions for cluster accounts management
	ListUsersOp          OperationKind = "listUsers"
	CreateUserOp         OperationKind = "createUser"
	DeleteUserOp         OperationKind = "deleteUser"
	DescribeUserOp       OperationKind = "describeUser"
	GrantUserRoleOp      OperationKind = "grantUserRole"
	RevokeUserRoleOp     OperationKind = "revokeUserRole"
	ListSystemAccountsOp OperationKind = "listSystemAccounts"

	JoinMemberOperation  OperationKind = "joinMember"
	LeaveMemberOperation OperationKind = "leaveMember"

	OperationNotImplemented    = "NotImplemented"
	OperationInvalid           = "Invalid"
	OperationSuccess           = "Success"
	OperationFailed            = "Failed"
	DefaultProbeTimeoutSeconds = 2

	DataDumpOperation OperationKind = "dataDump"
	DataLoadOperation OperationKind = "dataLoad"

	LegacyEventFieldPath = "spec.containers{kb-checkrole}"
	LorryEventFieldPath  = "spec.containers{lorry}"

	// this is a general script template, which can be used for all kinds of exec request to databases.
	DataScriptRequestTpl string = `` /* 305-byte string literal not displayed */

)

Variables

View Source
var ErrNotImplemented = errors.New("not implemented")

Functions

func CheckDNSReadyWithRetry added in v0.8.2

func CheckDNSReadyWithRetry(dns string, times int) (bool, error)

func CreateEvent

func CreateEvent(reason string, data map[string]any) (*corev1.Event, error)

func ExecCommand added in v0.8.2

func ExecCommand(ctx context.Context, command []string, envs []string) (string, error)

func GetGlobalSharedEnvs added in v0.8.2

func GetGlobalSharedEnvs() ([]string, error)

func IsDNSReady added in v0.8.2

func IsDNSReady(dns string) (bool, error)

IsDNSReady checks if dns and ip is ready, it can successfully resolve dns. Since the vast majority of container runtimes currently prohibit the NET_RAW capability, we can't rely on ICMP protocol to detect DNS resolution. Instead, we directly depend on TCP for port detection.

func IsTCPReady added in v0.8.4

func IsTCPReady(host, port string) (bool, error)

func NewProbeError

func NewProbeError(msg string) error

func SendEvent

func SendEvent(ctx context.Context, event *corev1.Event) error

func SentEventForProbe

func SentEventForProbe(ctx context.Context, data map[string]any) error

func WaitForDNSReady added in v0.8.2

func WaitForDNSReady(dns string)

WaitForDNSReady checks if dns is ready

func WaitForPodReady added in v0.8.2

func WaitForPodReady(checkPodHeadless bool)

WaitForPodReady checks if pod is ready

Types

type OperationKind

type OperationKind string

type ProbeError

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

ProbeError is the error for Lorry probe api, it implements error interface

func (ProbeError) Error

func (e ProbeError) Error() string

type RoleType

type RoleType string
const (
	SuperUserRole  RoleType = "superuser"
	ReadWriteRole  RoleType = "readwrite"
	ReadOnlyRole   RoleType = "readonly"
	NoPrivileges   RoleType = ""
	CustomizedRole RoleType = "customized"
	InvalidRole    RoleType = "invalid"
)

func (RoleType) EqualTo

func (r RoleType) EqualTo(role string) bool

func (RoleType) GetWeight

func (r RoleType) GetWeight() int32

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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