Documentation
¶
Index ¶
- Constants
- Variables
- func CalculateExponentialBackoffWithJitter(retryCount int64) time.Duration
- func CompareAndGetObjectHash(hash string, obj ...any) (bool, string)
- func CurrentIP() string
- func CurrentNamespace() string
- func EqualConditionsDisregardTransitionTime(a, b []metav1.Condition) bool
- func EscapeJSONPointer(s string) string
- func ExtractPoolNameFromNodeLabel(node *tfv1.GPUNode) string
- func FindFirstLevelOwnerReference(obj metav1.Object) *metav1.OwnerReference
- func FindRootOwnerReference(ctx context.Context, c client.Client, namespace string, obj metav1.Object) (*metav1.OwnerReference, error)
- func GetEnvOrDefault(key, defaultValue string) string
- func GetGPUResource(pod *corev1.Pod, isRequest bool) (tfv1.Resource, error)
- func GetObjectHash(objs ...any) string
- func HandleFinalizer[T client.Object](ctx context.Context, obj T, r client.Client, ...) (shouldReturn bool, err error)
- func IsPodConditionTrue(conditions []corev1.PodCondition, conditionType corev1.PodConditionType) bool
- func IsPodTerminated(pod *corev1.Pod) bool
- func LoadConfigFromFile[T any](filename string, target *T) error
- func NewShortID(length int) string
- func WatchConfigFileChanges(ctx context.Context, filename string) (<-chan []byte, error)
Constants ¶
const (
WatchConfigFileChangesInterval = 15 * time.Second
)
Variables ¶
var ErrNextLoop = errors.New("stop this loop and return the associated Result object")
ErrNextLoop is not a real error. It forces the current reconciliation loop to stop and return the associated Result object
var ErrTerminateLoop = errors.New("stop this loop and do not requeue")
ErrTerminateLoop is not a real error. It forces the current reconciliation loop to stop
var IsTestMode = false
Functions ¶
func CompareAndGetObjectHash ¶ added in v1.28.0
func CurrentNamespace ¶
func CurrentNamespace() string
func EqualConditionsDisregardTransitionTime ¶ added in v1.35.0
func EscapeJSONPointer ¶ added in v1.26.3
EscapeJSONPointer escapes a string according to the JSON Pointer spec (RFC 6901). It escapes '~' as '~0' and '/' as '~1'.
func ExtractPoolNameFromNodeLabel ¶ added in v1.33.1
func FindFirstLevelOwnerReference ¶ added in v1.35.0
func FindFirstLevelOwnerReference(obj metav1.Object) *metav1.OwnerReference
FindFirstLevelOwnerReference recursively finds the root owner reference for a given object (e.g. Pod).
func FindRootOwnerReference ¶ added in v1.26.9
func FindRootOwnerReference(ctx context.Context, c client.Client, namespace string, obj metav1.Object) (*metav1.OwnerReference, error)
FindRootOwnerReference recursively finds the root owner reference for a given object (e.g. Pod).
func GetEnvOrDefault ¶ added in v1.34.0
func GetGPUResource ¶ added in v1.35.0
func GetObjectHash ¶
GetObjectHash generates a shorter FNV-1a hash for one or more objects
func HandleFinalizer ¶
func HandleFinalizer[T client.Object]( ctx context.Context, obj T, r client.Client, deleteHook func(context.Context, T) (bool, error), ) (shouldReturn bool, err error)
HandleFinalizer ensures proper finalizer management for Kubernetes resources. It automatically adds the finalizer when needed, and removes it after successful cleanup. Returns (shouldReturn, err):
- shouldReturn: true if the caller should immediately return and wait for the next reconcile.
- err: any error encountered during update or deleteHook.
func IsPodConditionTrue ¶
func IsPodConditionTrue(conditions []corev1.PodCondition, conditionType corev1.PodConditionType) bool
func IsPodTerminated ¶ added in v1.26.15
func LoadConfigFromFile ¶ added in v1.34.0
func NewShortID ¶ added in v1.35.0
func WatchConfigFileChanges ¶ added in v1.34.0
WatchConfigFileChanges watches a file for changes and sends the file content through a channel when changes are detected. The channel will receive the raw file content as []byte whenever the file is modified. The watch interval is set to 15 seconds by default.
Types ¶
This section is empty.