Documentation
¶
Overview ¶
Package status provides a generic way to report status and conditions for any resource of type client.Object.
The Reporter struct centralizes the management of status and condition updates for any resource type that implements client.Object. This approach consolidates the previously scattered updateStatus functions found in DSCI and DSC controllers into a single, reusable component.
Reporter handles the reporting of a resource's condition based on the operational state and errors encountered during processing. It uses a closure, DetermineCondition, defined by the developer to determine how conditions should be updated, particularly in response to errors. This closure is similar to its previous incarnation "update func(saved)", which appends the target object's conditions, with the only difference being access to an optional error to make changes in the condition to be reported based on the occurred error.
Example:
createReporter initializes a new status reporter for a DSCInitialization resource. It encapsulates the logic for updating the condition based on errors encountered during the resource's lifecycle operations.
func createReporter(cli client.GetClient, object *dsciv1.DSCInitialization, condition *conditionsv1.Condition) *status.Reporter[*dsciv1.DSCInitialization] {
return status.NewStatusReporter[*dsciv1.DSCInitialization](
cli,
object,
func(err error) status.SaveStatusFunc[*dsciv1.DSCInitialization] {
return func(saved *dsciv1.DSCInitialization) {
if err != nil {
condition.Status = corev1.ConditionFalse
condition.Message = err.Error()
condition.Reason = status.CapabilityFailed
var missingOperatorErr *feature.MissingOperatorError
if errors.As(err, &missingOperatorErr) {
condition.Reason = status.MissingOperatorReason
}
}
conditionsv1.SetStatusCondition(&saved.Status.Conditions, *condition)
}
},
)
}
doServiceMeshStuff manages the Service Mesh configuration process during DSCInitialization reconcile. It creates a reporter and reports any conditions derived from the service mesh configuration process.
func (r *DSCInitializationReconciler) doStdoServiceMeshStuffff(instance *dsciv1.DSCInitialization) error {
reporter := createReporter(r.GetClient, instance, &conditionsv1.Condition{
Type: status.CapabilityServiceMesh,
Status: corev1.ConditionTrue,
Reason: status.ConfiguredReason,
Message: "Service Mesh configured",
})
serviceMeshErr := createServiceMesh(instance)
_, reportError := reporter.ReportCondition(serviceMeshErr)
return multierror.Append(serviceMeshErr, reportError) // return all errors
}
Package status contains different conditions, phases and progresses, being used by DataScienceCluster and DSCInitialization's controller
Index ¶
- Constants
- func SetCompleteCondition(conditions *[]common.Condition, reason string, message string)
- func SetCondition(conditions *[]common.Condition, conditionType string, reason string, ...)
- func SetErrorCondition(conditions *[]common.Condition, reason string, message string)
- func SetProgressingCondition(conditions *[]common.Condition, reason string, message string)
- func UpdateWithRetry[T client.Object](ctx context.Context, cli client.Client, original T, update SaveStatusFunc[T]) (T, error)
- type DetermineCondition
- type Reporter
- type SaveStatusFunc
Constants ¶
const ( // PhaseIgnored is used when a resource is ignored // is an example of a constant that is not used anywhere in the code. PhaseIgnored = "Ignored" // PhaseNotReady is used when waiting for system to be ready after reconcile is successful // is an example of a constant that is not used anywhere in the code. PhaseNotReady = "Not Ready" // PhaseClusterExpanding is used when cluster is expanding capacity // is an example of a constant that is not used anywhere in the code. PhaseClusterExpanding = "Expanding Capacity" // PhaseDeleting is used when cluster is deleting // is an example of a constant that is not used anywhere in the code. PhaseDeleting = "Deleting" // PhaseConnecting is used when cluster is connecting to external cluster // is an example of a constant that is not used anywhere in the code. PhaseConnecting = "Connecting" // PhaseOnboarding is used when consumer is Onboarding // is an example of a constant that is not used anywhere in the code. PhaseOnboarding = "Onboarding" // PhaseProgressing is used when SetProgressingCondition() is called. PhaseProgressing = "Progressing" // PhaseError is used when SetErrorCondition() is called. PhaseError = "Error" // PhaseReady is used when SetCompleteCondition is called. PhaseReady = "Ready" )
These constants represent the overall Phase as used by .Status.Phase.
const ( // ReconcileFailed is used when multiple DSCI instance exists or DSC reconcile failed/removal failed. ReconcileFailed = "ReconcileFailed" ReconcileInit = "ReconcileInit" ReconcileCompleted = "ReconcileCompleted" ReconcileCompletedWithComponentErrors = "ReconcileCompletedWithComponentErrors" ReconcileCompletedMessage = "Reconcile completed successfully" )
List of constants to show different reconciliation messages and statuses.
const ( // ConditionTypeAvailable indicates whether the resource is available. ConditionTypeAvailable = "Available" // ConditionTypeProgressing indicates whether the resource is progressing. ConditionTypeProgressing = "Progressing" // ConditionTypeDegraded indicates whether the resource is degraded. ConditionTypeDegraded = "Degraded" // ConditionTypeUpgradeable indicates whether the resource is upgradeable. ConditionTypeUpgradeable = "Upgradeable" // ConditionTypeReady indicates whether the resource is ready. ConditionTypeReady = "Ready" // ConditionTypeReconcileComplete indicates whether reconciliation is complete. ConditionTypeReconcileComplete = "ReconcileComplete" // Component-specific condition types. ConditionTypeProvisioningSucceeded = "ProvisioningSucceeded" ConditionDeploymentsNotAvailableReason = "DeploymentsNotReady" ConditionDeploymentsAvailable = "DeploymentsAvailable" ConditionServerlessAvailable = "ServerlessAvailable" ConditionServiceMeshAvailable = "ServiceMeshAvailable" ConditionArgoWorkflowAvailable = "ArgoWorkflowAvailable" ConditionTypeComponentsReady = "ComponentsReady" ConditionServingAvailable = "ServingAvailable" ConditionMonitoringAvailable = "MonitoringAvailable" ConditionMonitoringStackAvailable = "MonitoringStackAvailable" ConditionTempoAvailable = "TempoAvailable" ConditionOpenTelemetryCollectorAvailable = "OpenTelemetryCollectorAvailable" ConditionInstrumentationAvailable = "InstrumentationAvailable" ConditionAlertingAvailable = "AlertingAvailable" )
const ( CapabilityServiceMesh string = "CapabilityServiceMesh" CapabilityServiceMeshAuthorization string = "CapabilityServiceMeshAuthorization" CapabilityDSPv2Argo string = "CapabilityDSPv2Argo" )
const ( MissingOperatorReason string = "MissingOperator" ConfiguredReason string = "Configured" RemovedReason string = "Removed" UnmanagedReason string = "Unmanaged" CapabilityFailed string = "CapabilityFailed" ArgoWorkflowExist string = "ArgoWorkflowExist" NoManagedComponentsReason = "NoManagedComponents" DegradedReason = "Degraded" AvailableReason = "Available" UnknownReason = "Unknown" NotReadyReason = "NotReady" ErrorReason = "Error" ReadyReason = "Ready" )
const ( ServiceMeshNotConfiguredReason = "ServiceMeshNotConfigured" ServiceMeshNotReadyReason = "ServiceMeshNotReady" ServiceMeshNeedConfiguredMessage = "ServiceMesh needs to be set to 'Managed' in DSCI CR" ServiceMeshNotConfiguredMessage = "ServiceMesh is not configured in DSCI CR" ServiceMeshNotReadyMessage = "ServiceMesh is not ready" ServiceMeshOperatorNotInstalledReason = "ServiceMeshOperatorNotInstalled" ServiceMeshOperatorNotInstalledMessage = "ServiceMesh operator must be installed for this component's configuration" ServerlessOperatorNotInstalledReason = "ServerlessOperatorNotInstalled" ServerlessOperatorNotInstalledMessage = "Serverless operator must be installed for this component's configuration" ServerlessUnsupportedCertMessage = "Serverless certificate type is not supported" )
const ( DataSciencePipelinesDoesntOwnArgoCRDReason = "DataSciencePipelinesDoesntOwnArgoCRD" DataSciencePipelinesArgoWorkflowsNotManagedReason = "DataSciencePipelinesArgoWorkflowsNotManaged" DataSciencePipelinesArgoWorkflowsCRDMissingReason = "DataSciencePipelinesArgoWorkflowsCRDMissing" DataSciencePipelinesDoesntOwnArgoCRDMessage = "Failed upgrade: workflows.argoproj.io CRD already exists but not deployed by this operator " + "remove existing Argo workflows or set `spec.components.datasciencepipelines.managementState` to Removed to proceed" DataSciencePipelinesArgoWorkflowsNotManagedMessage = "Argo Workflows controllers are not managed by this operator" DataSciencePipelinesArgoWorkflowsCRDMissingMessage = "Argo Workflows controllers are not managed by this operator, but the CRD is missing" )
const ( MultiKueueCRDReason = "MultiKueueCRDV1Alpha1Exist" MultiKueueCRDMessage = "Kueue CRDs MultiKueueConfig v1alpha1 and/or MultiKueueCluster v1alpha1 exist, please remove them to proceed" KueueOperatorAlreadyInstalleReason = "KueueOperatorAlreadyInstalled" KueueOperatorAlreadyInstalledMessage = "Kueue operator already installed, uninstall it or change kueue component state to Unmanaged" KueueOperatorNotInstalleReason = "KueueOperatorNotInstalleReason" KueueOperatorNotInstalledMessage = "Kueue operator not installed, install it or change kueue component state to Managed" )
For Kueue MultiKueue CRD.
const ( ISVCMissingCRDReason = "InferenceServiceCRDMissing" ISVCMissingCRDMessage = "InferenceServices CRD does not exist, please enable serving component first" )
For TrustyAI require ISVC CRD.
const ( MetricsNotConfiguredReason = "MetricsNotConfigured" MetricsNotConfiguredMessage = "Metrics not configured in DSCI CR" TracesNotConfiguredReason = "TracesNotConfigured" TracesNotConfiguredMessage = "Traces not configured in DSCI CR" AlertingNotConfiguredReason = "AlertingNotConfigured" AlertingNotConfiguredMessage = "Alerting not configured in DSCI CR" TempoOperatorMissingMessage = "Tempo operator must be installed for traces configuration" COOMissingMessage = "ClusterObservability operator must be installed for metrics configuration" OpenTelemetryCollectorOperatorMissingMessage = "OpenTelemetryCollector operator must be installed for OpenTelemetry configuration" )
For Monitoring service checks.
const (
ReadySuffix = "Ready"
)
Variables ¶
This section is empty.
Functions ¶
func SetCompleteCondition ¶
SetCompleteCondition sets the ConditionTypeReconcileComplete to True and other Conditions to indicate that the reconciliation process has completed successfully.
func SetCondition ¶
func SetCondition(conditions *[]common.Condition, conditionType string, reason string, message string, status metav1.ConditionStatus)
SetCondition is a general purpose function to update any type of condition.
func SetErrorCondition ¶
SetErrorCondition sets the ConditionTypeReconcileComplete to False in case of any errors during the reconciliation process.
func SetProgressingCondition ¶
SetProgressingCondition sets the ProgressingCondition to True and other conditions to false or Unknown. Used when we are just starting to reconcile, and there are no existing conditions.
func UpdateWithRetry ¶
func UpdateWithRetry[T client.Object](ctx context.Context, cli client.Client, original T, update SaveStatusFunc[T]) (T, error)
UpdateWithRetry updates the status of object using passed function and retries on conflict.
Types ¶
type DetermineCondition ¶
type DetermineCondition[T client.Object] func(err error) SaveStatusFunc[T]
DetermineCondition is a function that allow to define how condition should be set. It can use err if available to set faulty condition. It should return a SaveStatusFunc which will be used to update the status of the object.
type Reporter ¶
Reporter handles condition reporting for a given object. The logic of how the given condition should be calculated is defined by the determineCondition function.
func NewStatusReporter ¶
func NewStatusReporter[T client.Object](cli client.Client, object T, determine DetermineCondition[T]) *Reporter[T]
NewStatusReporter creates r new Reporter with all required fields.
type SaveStatusFunc ¶
SaveStatusFunc is a function that allow to define custom logic of updating status of a concrete resource object.