Documentation
¶
Index ¶
- Constants
- Variables
- func DecodeBase64Proto[T proto.Message](raw string, into T) error
- func DoItSlowly(count int, initialBatchSize int, fn func() error) (int, error)
- func DoItSlowlyWithInputs[T any](inputs []T, initialBatchSize int, fn func(T) error) (int, error)
- func DumpJson(o interface{}) string
- func EncodeBase64Proto[T proto.Message](data T) (string, error)
- func GenerateSandboxName(baseName string) string
- func GetClusterIDHash() string
- func GetControllerKey(obj client.Object) string
- func GetFirstNonLoopbackIP() string
- func GetFromInformerOrApiServer[T client.Object](ctx context.Context, target T, key client.ObjectKey, client client.Client, ...) error
- func GetPodCondition(status *corev1.PodStatus, condType corev1.PodConditionType) *corev1.PodCondition
- func GetSandboxCondition(status *agentsv1alpha1.SandboxStatus, condType string) *metav1.Condition
- func GetSandboxControllerUsername() string
- func GetTemplateFromSandbox(sbx metav1.Object) string
- func HashData(by []byte) string
- func IsLoopbackIP(ip string) bool
- func PatchFinalizer(ctx context.Context, c client.Client, object client.Object, op FinalizerOpType, ...) (client.Object, error)
- func RemoveSandboxCondition(status *agentsv1alpha1.SandboxStatus, condType string)
- func RetryIfContextNotCanceled(ctx context.Context) func(err error) bool
- func SetSandboxCondition(status *agentsv1alpha1.SandboxStatus, condition metav1.Condition)
- func TruncateConditionMessage(msg string) string
- func UpdateFinalizer(c client.Client, object client.Object, op FinalizerOpType, finalizer string) error
- type FinalizerOpType
Constants ¶
const ( // SandboxFinalizer is sandbox finalizer SandboxFinalizer = "agents.kruise.io/sandbox" // PodAnnotationCreatedBy is used to identify Pod source: created by Sandbox controller or externally created (bypassing Sandbox syntax sugar) PodAnnotationCreatedBy = "agents.kruise.io/created-by" // PodLabelCreatedBy is a label mirroring PodAnnotationCreatedBy, used as a label selector // for informer filtering so that only agent-related pods are cached. PodLabelCreatedBy = "agents.kruise.io/created-by" // default sandbox deploy namespace DefaultSandboxDeployNamespace = "sandbox-system" PodConditionContainersPaused = "ContainersPaused" PodConditionContainersResumed = "ContainersResumed" )
const ( True = "true" False = "false" CreatedByExternal = "external" CreatedBySandbox = "sandbox" )
Variables ¶
var ( // MaxConditionMessageLen is the max length for a Condition.Message. // Configurable via MAX_CONDITION_MESSAGE_LEN env var, defaults to 1024. MaxConditionMessageLen = getEnvIntOrDefault("MAX_CONDITION_MESSAGE_LEN", 1024) CacheBackoff = wait.Backoff{ Duration: 100 * time.Millisecond, Factor: 2.0, Steps: 10, Jitter: 1.1, } )
Functions ¶
func DecodeBase64Proto ¶ added in v0.1.0
func DoItSlowly ¶
DoItSlowly tries to call the provided function a total of 'count' times, starting slow to check for errors, then speeding up if calls succeed.
It groups the calls into batches, starting with a group of initialBatchSize. Within each batch, it may call the function multiple times concurrently.
If a whole batch succeeds, the next batch may get exponentially larger. If there are any failures in a batch, all remaining batches are skipped after waiting for the current batch to complete.
It returns the number of successful calls to the function.
func DoItSlowlyWithInputs ¶
func EncodeBase64Proto ¶ added in v0.1.0
func GenerateSandboxName ¶ added in v0.3.0
GenerateSandboxName generates a K8s generateName prefix for sandbox objects. When SandboxMultiClusterNaming feature gate is enabled and CLUSTER_ID env is set, the cluster ID hash is embedded in the prefix to prevent cross-cluster naming conflicts. The returned prefix always ends with "-" and is truncated to 58 characters max.
func GetClusterIDHash ¶ added in v0.3.0
func GetClusterIDHash() string
GetClusterIDHash returns a 4-character hex hash of the CLUSTER_ID environment variable. Returns empty string if CLUSTER_ID is not set.
func GetControllerKey ¶ added in v0.1.0
func GetFirstNonLoopbackIP ¶ added in v0.2.0
func GetFirstNonLoopbackIP() string
func GetFromInformerOrApiServer ¶ added in v0.3.0
func GetPodCondition ¶
func GetPodCondition(status *corev1.PodStatus, condType corev1.PodConditionType) *corev1.PodCondition
func GetSandboxCondition ¶
func GetSandboxCondition(status *agentsv1alpha1.SandboxStatus, condType string) *metav1.Condition
func GetSandboxControllerUsername ¶ added in v0.2.0
func GetSandboxControllerUsername() string
func GetTemplateFromSandbox ¶ added in v0.3.0
func IsLoopbackIP ¶ added in v0.2.0
func PatchFinalizer ¶
func RemoveSandboxCondition ¶
func RemoveSandboxCondition(status *agentsv1alpha1.SandboxStatus, condType string)
func RetryIfContextNotCanceled ¶ added in v0.2.0
func SetSandboxCondition ¶
func SetSandboxCondition(status *agentsv1alpha1.SandboxStatus, condition metav1.Condition)
func TruncateConditionMessage ¶ added in v0.3.0
func UpdateFinalizer ¶
func UpdateFinalizer(c client.Client, object client.Object, op FinalizerOpType, finalizer string) error
UpdateFinalizer add/remove a finalizer from a object
Types ¶
type FinalizerOpType ¶
type FinalizerOpType string
const ( AddFinalizerOpType FinalizerOpType = "Add" RemoveFinalizerOpType FinalizerOpType = "Remove" )
Directories
¶
| Path | Synopsis |
|---|---|
|
Package utils provides utility functions for parsing and handling Kubernetes resource quantities.
|
Package utils provides utility functions for parsing and handling Kubernetes resource quantities. |