Documentation ¶
Index ¶
- Constants
- Variables
- func AddInstrumentationLabels(meta *metav1.ObjectMeta, instrumentationSuccess bool, ...)
- func AddWebhookIgnoreOnceLabel(meta *metav1.ObjectMeta)
- func AttachEventToInvolvedObject(ctx context.Context, k8sClient client.Client, ...) error
- func CheckAndDeleteIgnoreOnceLabel(meta *metav1.ObjectMeta) bool
- func CheckIfNamespaceExists(ctx context.Context, clientset *kubernetes.Clientset, namespace string, ...) (bool, error)
- func CheckImminentDeletionAndHandleFinalizers(ctx context.Context, k8sClient client.Client, ...) (bool, bool, error)
- func CreateEnvVarForAuthorization(dash0Authorization dash0v1alpha1.Authorization, envVarName string) (corev1.EnvVar, error)
- func FindUniqueOrMostRecentResourceInScope(ctx context.Context, k8sClient client.Client, namespace string, ...) (dash0common.Dash0Resource, error)
- func GetReceiverForWorkloadType(apiVersion string, kind string) (client.Object, error)
- func HasBeenInstrumentedSuccessfully(meta *metav1.ObjectMeta) bool
- func HasBeenInstrumentedSuccessfullyByThisVersion(meta *metav1.ObjectMeta, images Images) bool
- func HasOptedOutOfInstrumentation(meta *metav1.ObjectMeta) bool
- func HasOptedOutOfInstrumentationAndIsUninstrumented(meta *metav1.ObjectMeta) bool
- func ImageNameToLabel(imageName string) string
- func InitStatusConditions(ctx context.Context, k8sClient client.Client, ...) (bool, error)
- func InstrumentationAttemptHasFailed(meta *metav1.ObjectMeta) bool
- func QueueFailedInstrumentationEvent(eventRecorder record.EventRecorder, resource runtime.Object, ...)
- func QueueFailedUninstrumentationEvent(eventRecorder record.EventRecorder, resource runtime.Object, ...)
- func QueueNoInstrumentationNecessaryEvent(eventRecorder record.EventRecorder, resource runtime.Object, ...)
- func QueueNoUninstrumentationNecessaryEvent(eventRecorder record.EventRecorder, resource runtime.Object, ...)
- func QueueSuccessfulInstrumentationEvent(eventRecorder record.EventRecorder, resource runtime.Object, ...)
- func QueueSuccessfulUninstrumentationEvent(eventRecorder record.EventRecorder, resource runtime.Object, ...)
- func ReadBoolPointerWithDefault(pointer *bool, defaultValue bool) bool
- func RemoveInstrumentationLabels(meta *metav1.ObjectMeta)
- func Retry(operationLabel string, operation func() error, logger *logr.Logger) error
- func RetryWithCustomBackoff(operationLabel string, operation func() error, backoff wait.Backoff, ...) error
- func VerifyThatResourceIsUniqueInScope(ctx context.Context, k8sClient client.Client, req ctrl.Request, ...) (bool, error)
- func WasInstrumentedButHasOptedOutNow(meta *metav1.ObjectMeta) bool
- type CheckResourceResult
- type DanglingEventsTimeouts
- type Images
- type InstrumentationMetadata
- type ModificationMode
- type Reason
- type SortByCreationTimestamp
Constants ¶
const ( AuthorizationHeaderName = "Authorization" Dash0DatasetHeaderName = "Dash0-Dataset" DatasetDefault = "default" DatasetInsights = "dash0-internal" SelfMonitoringAndApiAuthTokenEnvVarName = "SELF_MONITORING_AND_API_AUTH_TOKEN" FieldManager = "dash0-operator" )
Variables ¶
var ( EmptyListOptions = metav1.ListOptions{} WorkloadsWithDash0InstrumentedLabelFilter = metav1.ListOptions{ LabelSelector: instrumentedLabelKey, } )
Functions ¶
func AddInstrumentationLabels ¶
func AddInstrumentationLabels( meta *metav1.ObjectMeta, instrumentationSuccess bool, instrumentationMetadata InstrumentationMetadata, )
func AddWebhookIgnoreOnceLabel ¶
func AddWebhookIgnoreOnceLabel(meta *metav1.ObjectMeta)
func AttachEventToInvolvedObject ¶
func AttachEventToInvolvedObject( ctx context.Context, k8sClient client.Client, eventApi clientcorev1.EventInterface, event *corev1.Event, ) error
func CheckAndDeleteIgnoreOnceLabel ¶
func CheckAndDeleteIgnoreOnceLabel(meta *metav1.ObjectMeta) bool
func CheckIfNamespaceExists ¶
func CheckIfNamespaceExists( ctx context.Context, clientset *kubernetes.Clientset, namespace string, logger *logr.Logger, ) (bool, error)
CheckIfNamespaceExists checks if the given namespace (which is supposed to be the namespace from a reconcile request) exists in the cluster. If the namespace does not exist, it returns false, and this is supposed to stop the reconcile
func CheckImminentDeletionAndHandleFinalizers ¶
func CheckImminentDeletionAndHandleFinalizers( ctx context.Context, k8sClient client.Client, resource dash0common.Dash0Resource, finalizerId string, logger *logr.Logger, ) (bool, bool, error)
CheckImminentDeletionAndHandleFinalizers checks if the resource is marked for deletion, that is, if it has a deletion timestamp set and whether it has a finalizer set.
Returns (isMarkedForDeletion, runCleanupActions, error). If isMarkedForDeletion and runCleanupActions are both true, the resource has a deletion timestamp, but it also still has a finalizer set. The caller is expected to run all cleanup actions for this resource and remove the finalizer, then stop the reconcile. If isMarkedForDeletion is true and runCleanupActions is false, the resource has a deletion timestamp and does not have a finalizer set. The caller does not need to take any particular action and can stop the reconcile.
func CreateEnvVarForAuthorization ¶
func CreateEnvVarForAuthorization( dash0Authorization dash0v1alpha1.Authorization, envVarName string, ) (corev1.EnvVar, error)
func FindUniqueOrMostRecentResourceInScope ¶
func FindUniqueOrMostRecentResourceInScope( ctx context.Context, k8sClient client.Client, namespace string, resourcePrototype dash0common.Dash0Resource, logger *logr.Logger, ) (dash0common.Dash0Resource, error)
FindUniqueOrMostRecentResourceInScope tries to fetch the unique resource of a given type in a scope (cluster or namespace). If multiple resources exist, it returns the most recent one. If no resources exist, it returns nil.
func HasBeenInstrumentedSuccessfully ¶
func HasBeenInstrumentedSuccessfully(meta *metav1.ObjectMeta) bool
func HasBeenInstrumentedSuccessfullyByThisVersion ¶
func HasBeenInstrumentedSuccessfullyByThisVersion( meta *metav1.ObjectMeta, images Images, ) bool
func HasOptedOutOfInstrumentation ¶
func HasOptedOutOfInstrumentation(meta *metav1.ObjectMeta) bool
func HasOptedOutOfInstrumentationAndIsUninstrumented ¶
func HasOptedOutOfInstrumentationAndIsUninstrumented(meta *metav1.ObjectMeta) bool
func ImageNameToLabel ¶
func InitStatusConditions ¶
func InstrumentationAttemptHasFailed ¶
func InstrumentationAttemptHasFailed(meta *metav1.ObjectMeta) bool
func QueueNoInstrumentationNecessaryEvent ¶
func QueueNoInstrumentationNecessaryEvent(eventRecorder record.EventRecorder, resource runtime.Object, eventSource string)
func QueueNoUninstrumentationNecessaryEvent ¶
func QueueNoUninstrumentationNecessaryEvent(eventRecorder record.EventRecorder, resource runtime.Object, eventSource string)
func QueueSuccessfulInstrumentationEvent ¶
func QueueSuccessfulInstrumentationEvent(eventRecorder record.EventRecorder, resource runtime.Object, eventSource string)
func QueueSuccessfulUninstrumentationEvent ¶
func QueueSuccessfulUninstrumentationEvent(eventRecorder record.EventRecorder, resource runtime.Object, eventSource string)
func RemoveInstrumentationLabels ¶
func RemoveInstrumentationLabels(meta *metav1.ObjectMeta)
func RetryWithCustomBackoff ¶
func VerifyThatResourceIsUniqueInScope ¶
func VerifyThatResourceIsUniqueInScope( ctx context.Context, k8sClient client.Client, req ctrl.Request, resource dash0common.Dash0Resource, updateStatusFailedMessage string, logger *logr.Logger, ) (bool, error)
VerifyThatResourceIsUniqueInScope checks whether there are any additional resources of the same type in the namespace, besides the one that the current reconcile request applies to. The bool the function returns has the semantic stopReconcile, that is, if the function returns true, it expects the caller to stop the reconcile. If there are no errors and the resource is unique, the function will return (false, nil). If there are multiple resources in the namespace, but the given resource is the most recent one, the function will return (false, nil) as well, since the newest resource should be reconciled. If there are multiple resources and the given one is not the most recent one, the function will return (true, nil), and the caller is expected to stop the reconcile and not requeue it. If any error is encountered when searching for other resource etc., that error will be returned, the caller is expected to ignore the bool result and requeue the reconcile request.
func WasInstrumentedButHasOptedOutNow ¶
func WasInstrumentedButHasOptedOutNow(meta *metav1.ObjectMeta) bool
Types ¶
type CheckResourceResult ¶
type CheckResourceResult struct { Resource dash0common.Dash0Resource StopReconcile bool ResourceDoesNotExist bool }
func VerifyThatResourceExists ¶
func VerifyThatResourceExists( ctx context.Context, k8sClient client.Client, req ctrl.Request, resourcePrototype dash0common.Dash0Resource, logger *logr.Logger, ) (CheckResourceResult, error)
VerifyThatResourceExists loads the resource that the current reconcile request applies to. If that resource does not exist, the function logs a message and returns (nil, true, nil) and expects the caller to stop the reconciliation (without requeing it). If any other error occurs while trying to fetch the resource, the function logs the error and returns (nil, true, err) and expects the caller to requeue the reconciliation.
func VerifyThatUniqueResourceExists ¶
func VerifyThatUniqueResourceExists( ctx context.Context, k8sClient client.Client, req ctrl.Request, resourcePrototype dash0common.Dash0Resource, updateStatusFailedMessage string, logger *logr.Logger, ) (CheckResourceResult, error)
VerifyThatUniqueResourceExists loads the resource that the current reconcile request applies to, if it exists. It also checks whether there is only one such resource (or, if there are multiple, if the currently reconciled one is the most recently created one). The bool returned has the meaning "stop the reconcile request", that is, if the function returns true, it expects the caller to stop the reconcile request immediately and not requeue it.
If an error occurs during any of the checks (for example while talking to the Kubernetes API server), the function will return that error, the caller should then ignore the bool result and requeue the reconcile request.
- If the resource does not exist, the function logs a message and returns (nil, true, nil) and expects the caller to stop the reconciliation (without requeing it).
- If there are multiple resources in the namespace, but the given resource is the most recent one, the function will return the resource together with (false, nil) as well, since the newest resource should be reconciled. The caller should continue with the reconcile request in that case.
- If there are multiple resources and the given one is not the most recent one, the function will return true for stopReconcile and the caller is expected to stop the reconcile and not requeue it.
- If any error is encountered when searching for resources etc., that error will be returned, the caller is expected to ignore the bool result and requeue the reconcile request.
type DanglingEventsTimeouts ¶
type Images ¶
type Images struct { OperatorImage string InitContainerImage string InitContainerImagePullPolicy corev1.PullPolicy CollectorImage string CollectorImagePullPolicy corev1.PullPolicy ConfigurationReloaderImage string ConfigurationReloaderImagePullPolicy corev1.PullPolicy FilelogOffsetSynchImage string FilelogOffsetSynchImagePullPolicy corev1.PullPolicy }
func (Images) GetOperatorVersion ¶
type InstrumentationMetadata ¶
type ModificationMode ¶
type ModificationMode string
const ( ModificationModeInstrumentation ModificationMode = "instrumentation" ModificationModeUninstrumentation ModificationMode = "uninstrumentation" )
type Reason ¶
type Reason string
const ( ReasonSuccessfulInstrumentation Reason = "SuccessfulInstrumentation" ReasonNoInstrumentationNecessary Reason = "AlreadyInstrumented" ReasonFailedInstrumentation Reason = "FailedInstrumentation" ReasonSuccessfulUninstrumentation Reason = "SuccessfulUninstrumentation" ReasonNoUninstrumentationNecessary Reason = "AlreadyNotInstrumented" ReasonFailedUninstrumentation Reason = "FailedUninstrumentation" )
type SortByCreationTimestamp ¶
func (SortByCreationTimestamp) Len ¶
func (s SortByCreationTimestamp) Len() int
func (SortByCreationTimestamp) Less ¶
func (s SortByCreationTimestamp) Less(i, j int) bool
func (SortByCreationTimestamp) Swap ¶
func (s SortByCreationTimestamp) Swap(i, j int)