Skip to content

Commit

Permalink
add condition and reason in operator
Browse files Browse the repository at this point in the history
Signed-off-by: Zhiwei Yin <zyin@redhat.com>
  • Loading branch information
zhiweiyin318 committed Apr 11, 2024
1 parent 19eb7b5 commit 46b2dad
Show file tree
Hide file tree
Showing 2 changed files with 114 additions and 0 deletions.
51 changes: 51 additions & 0 deletions operator/v1/types_clustermanager.go
Original file line number Diff line number Diff line change
Expand Up @@ -339,3 +339,54 @@ type ClusterManagerList struct {
// Items is a list of deployment configurations for registration and work distribution controllers.
Items []ClusterManager `json:"items"`
}

const (
// The types of ClusterManager condition status.
// ConditionClusterManagerApplied is the ClusterManager condition status which means all components have been applied on the hub.
ConditionClusterManagerApplied = "Applied"
// ConditionHubRegistrationDegraded is the ClusterManager condition status which means the registration is not ready to serve on the hub.
ConditionHubRegistrationDegraded = "HubRegistrationDegraded"
// ConditionHubPlacementDegraded is the ClusterManager condition status which means the placement is not ready to serve on the hub.
ConditionHubPlacementDegraded = "HubPlacementDegraded"
// ConditionProgressing is the ClusterManager condition status which means the ClusterManager are in upgrading phase.
ConditionProgressing = "Progressing"
// ConditionMigrationSucceeded is the ClusterManager condition status which means the API migration is succeeded on the hub.
ConditionMigrationSucceeded = "MigrationSucceeded"

// ReasonClusterManagerApplied is the reason of the ConditionClusterManagerApplied condition to show all resources are applied.
ReasonClusterManagerApplied = "ClusterManagerApplied"
// ReasonRuntimeResourceApplyFailed is the reason of the ConditionClusterManagerApplied condition to show it is failed to apply deployments.
ReasonRuntimeResourceApplyFailed = "RuntimeResourceApplyFailed"
// ReasonServiceAccountSyncFailed is the reason of the ConditionClusterManagerApplied condition to show it is failed to apply serviceAccounts.
ReasonServiceAccountSyncFailed = "ServiceAccountSyncFailed"
// ReasonClusterManagerCRDApplyFailed is the reason of the ConditionClusterManagerApplied condition to show it is failed to apply CRDs.
ReasonClusterManagerCRDApplyFailed = "CRDApplyFailed"
// ReasonWebhookApplyFailed is the reason of the ConditionClusterManagerApplied condition to show it is failed to apply webhooks.
ReasonWebhookApplyFailed = "WebhookApplyFailed"

// ReasonDeploymentRolling is the reason of the ConditionProgressing condition to show the deployed deployments are rolling.
ReasonDeploymentRolling = "ClusterManagerDeploymentRolling"
// ReasonUpToDate is the reason of the ConditionProgressing condition to show the deployed deployments are up-to-date.
ReasonUpToDate = "ClusterManagerUpToDate"

// ReasonStorageVersionMigrationFailed is the reason of the ConditionMigrationSucceeded condition to show the API storageVersion migration is failed.
ReasonStorageVersionMigrationFailed = "StorageVersionMigrationFailed"
// ReasonStorageVersionMigrationProcessing is the reason of the ConditionMigrationSucceeded condition to show the API storageVersion migration is not completed.
ReasonStorageVersionMigrationProcessing = "StorageVersionMigrationProcessing"
// ReasonStorageVersionMigrationSucceed is the reason of the ConditionMigrationSucceeded condition to show the API storageVersion migration is succeeded.
ReasonStorageVersionMigrationSucceed = "StorageVersionMigrationSucceed"

// ReasonGetRegistrationDeploymentFailed is the reason of the ConditionRegistrationDegraded condition to show getting registration deployment failed.
ReasonGetRegistrationDeploymentFailed = "GetRegistrationDeploymentFailed"
// ReasonUnavailableRegistrationPod is the reason of the ConditionRegistrationDegraded condition to show the registration pods are unavailable.
ReasonUnavailableRegistrationPod = "UnavailableRegistrationPod"
// ReasonRegistrationFunctional is the reason of the ConditionRegistrationDegraded condition to show registration is functional.
ReasonRegistrationFunctional = "RegistrationFunctional"

// ReasonGetPlacementDeploymentFailed is the reason of the ConditionPlacementDegraded condition to show it is failed get placement deployment.
ReasonGetPlacementDeploymentFailed = "GetPlacementDeploymentFailed"
// ReasonUnavailablePlacementPod is the reason of the ConditionPlacementDegraded condition to show the registration pods are unavailable.
ReasonUnavailablePlacementPod = "UnavailablePlacementPod"
// ReasonPlacementFunctional is the reason of the ConditionPlacementDegraded condition to show placement is functional.
ReasonPlacementFunctional = "PlacementFunctional"
)
63 changes: 63 additions & 0 deletions operator/v1/types_klusterlet.go
Original file line number Diff line number Diff line change
Expand Up @@ -244,3 +244,66 @@ type KlusterletList struct {
// Items is a list of Klusterlet agents.
Items []Klusterlet `json:"items"`
}

const (
// The types of klusterlet condition status.
// ConditionKlusterletApplied is the klusterlet condition status which means all components have been applied on the managed cluster.
ConditionKlusterletApplied = "Applied"
// ConditionReadyToApply is a klusterlet condition status which means it is ready to apply the resources on the managed cluster.
ConditionReadyToApply = "ReadyToApply"
// ConditionKlusterletAvailable is the klusterlet condition status which means all components are available and ready to serve.
ConditionKlusterletAvailable = "Available"
// ConditionHubConnectionDegraded is the klusterlet condition status which means the agent on the managed cluster cannot access the hub cluster.
ConditionHubConnectionDegraded = "HubConnectionDegraded"
// ConditionRegistrationDesiredDegraded is the klusterlet condition status which means the registration agent on the managed cluster is not ready to serve.
ConditionRegistrationDesiredDegraded = "RegistrationDesiredDegraded"
// ConditionWorkDesiredDegraded is the klusterlet condition status which means the work agent on the managed cluster is not ready to serve.
ConditionWorkDesiredDegraded = "WorkDesiredDegraded"

// ReasonKlusterletApplied is the reason of ConditionKlusterletApplied condition to show resources are applied.
ReasonKlusterletApplied = "KlusterletApplied"
// ReasonKlusterletApplyFailed is the reason of ConditionKlusterletApplied condition to show it is failed to apply resources.
ReasonKlusterletApplyFailed = "KlusterletApplyFailed"
// ReasonKlusterletCRDApplyFailed is the reason of ConditionKlusterletApplied condition to show it is failed to apply CRDs.
ReasonKlusterletCRDApplyFailed = "CRDApplyFailed"
// ReasonManagedClusterResourceApplyFailed is the reason of ConditionKlusterletApplied condition to show it is failed to apply resources on managed cluster.
ReasonManagedClusterResourceApplyFailed = "ManagedClusterResourceApplyFailed"
// ReasonManagementClusterResourceApplyFailed is the reason of ConditionKlusterletApplied condition to show it is failed to apply resources on management cluster.
ReasonManagementClusterResourceApplyFailed = "ManagementClusterResourceApplyFailed"

// ReasonKlusterletPrepareFailed is the reason of ConditionReadyToApply condition to show it is failed to get the kubeConfig
// of managed cluster from the external-managed-kubeconfig secret in the hosted mode.
ReasonKlusterletPrepareFailed = "KlusterletPrepareFailed"
// ReasonKlusterletPrepared is the reason of ConditionReadyToApply condition to show the kubeConfig of managed cluster is
// validated from the external-managed-kubeconfig secret in the hosted mode.
ReasonKlusterletPrepared = "KlusterletPrepared"

// ReasonKlusterletGetDeploymentFailed is the reason of ConditionKlusterletAvailable/ConditionRegistrationDesiredDegraded/ConditionWorkDesiredDegraded
// condition to show it is failed to get deployments.
ReasonKlusterletGetDeploymentFailed = "GetDeploymentFailed"
// ReasonKlusterletUnavailablePods is the reason of ConditionKlusterletAvailable/ConditionRegistrationDesiredDegraded/ConditionWorkDesiredDegraded
// condition to show there is unavailable pod.
ReasonKlusterletUnavailablePods = "UnavailablePods"
// ReasonKlusterletDeploymentsFunctional is the reason of ConditionKlusterletAvailable/ConditionRegistrationDesiredDegraded/ConditionWorkDesiredDegraded
// condition to show all deployments are functional.
ReasonKlusterletDeploymentsFunctional = "DeploymentsFunctional"
// ReasonKlusterletNoAvailablePods is the reason of ConditionKlusterletAvailable/ConditionRegistrationDesiredDegraded/ConditionWorkDesiredDegraded
// condition to show there is no available pod.
ReasonKlusterletNoAvailablePods = "NoAvailablePods"

// ReasonKlusterletAvailable is the reason of ConditionKlusterletAvailable condition to show all deployed resources are available.
ReasonKlusterletAvailable = "KlusterletAvailable"

// ReasonHubConnectionFunctional is the reason of ConditionHubConnectionDegraded condition to show spoke cluster connects hub cluster.
ReasonHubConnectionFunctional = "HubConnectionFunctional"
// ReasonHubKubeConfigSecretMissing is the reason of ConditionHubConnectionDegraded condition to show hubKubeConfigSecret is missing.
ReasonHubKubeConfigSecretMissing = "HubKubeConfigSecretMissing"
// ReasonHubKubeConfigMissing is the reason of ConditionHubConnectionDegraded condition to show HubKubeConfig in hubKubeConfigSecret is missing.
ReasonHubKubeConfigMissing = "HubKubeConfigMissing"
// ReasonHubKubeConfigError is the reason of ConditionHubConnectionDegraded condition to show it is failed to get hubKubeConfig.
ReasonHubKubeConfigError = "HubKubeConfigError"
// ReasonClusterNameMissing is the reason of ConditionHubConnectionDegraded condition to show the cluster-name is missing in the hubKubeConfigSecret.
ReasonClusterNameMissing = "ClusterNameMissing"
// ReasonHubKubeConfigUnauthorized is the reason of ConditionHubConnectionDegraded condition to show there is no permission to access hub using the hubKubeConfigSecret.
ReasonHubKubeConfigUnauthorized = "HubKubeConfigUnauthorized"
)

0 comments on commit 46b2dad

Please sign in to comment.