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 4300319
Show file tree
Hide file tree
Showing 2 changed files with 101 additions and 0 deletions.
46 changes: 46 additions & 0 deletions operator/v1/types_clustermanager.go
Original file line number Diff line number Diff line change
Expand Up @@ -339,3 +339,49 @@ 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.
ConditionClusterManagerApplied = "Applied"
ConditionHubRegistrationDegraded = "HubRegistrationDegraded"
ConditionHubPlacementDegraded = "HubPlacementDegraded"
ConditionProgressing = "Progressing"
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 failed to apply deployments.
ReasonRuntimeResourceApplyFailed = "RuntimeResourceApplyFailed"
// ReasonServiceAccountSyncFailed is the reason of the ConditionClusterManagerApplied condition to show failed to apply serviceAccounts.
ReasonServiceAccountSyncFailed = "ServiceAccountSyncFailed"
// ReasonClusterManagerCRDApplyFailed is the reason of the ConditionClusterManagerApplied condition to show failed to apply CRDs.
ReasonClusterManagerCRDApplyFailed = "CRDApplyFailed"
// ReasonWebhookApplyFailed is the reason of the ConditionClusterManagerApplied condition to show 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 he deployed deployments are up-to-date.
ReasonUpToDate = "ClusterManagerUpToDate"

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

// ReasonGetRegistrationDeploymentFailed is the reason of the ConditionRegistrationDegraded condition to show failed get registration deployment.
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 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"
)
55 changes: 55 additions & 0 deletions operator/v1/types_klusterlet.go
Original file line number Diff line number Diff line change
Expand Up @@ -244,3 +244,58 @@ type KlusterletList struct {
// Items is a list of Klusterlet agents.
Items []Klusterlet `json:"items"`
}

const (
// The types of klusterlet condition.
ConditionKlusterletApplied = "Applied"
ConditionReadyToApply = "ReadyToApply"
ConditionKlusterletAvailable = "Available"
ConditionHubConnectionDegraded = "HubConnectionDegraded"
ConditionRegistrationDesiredDegraded = "RegistrationDesiredDegraded"
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 failed to apply resources.
ReasonKlusterletApplyFailed = "KlusterletApplyFailed"
// ReasonKlusterletCRDApplyFailed is the reason of ConditionKlusterletApplied condition to show failed to apply CRDs.
ReasonKlusterletCRDApplyFailed = "CRDApplyFailed"
// ReasonManagedClusterResourceApplyFailed is the reason of ConditionKlusterletApplied condition to failed to apply resources on managed cluster.
ReasonManagedClusterResourceApplyFailed = "ManagedClusterResourceApplyFailed"
// ReasonManagementClusterResourceApplyFailed is the reason of ConditionKlusterletApplied condition failed to apply resources on management cluster.
ReasonManagementClusterResourceApplyFailed = "ManagementClusterResourceApplyFailed"

// ReasonKlusterletPrepareFailed is the reason of ConditionReadyToApply condition to show failed to prepare before apply/delete resources.
ReasonKlusterletPrepareFailed = "KlusterletPrepareFailed"
// ReasonKlusterletPrepared is the reason of ConditionReadyToApply condition to show it is prepared before apply/delete resources.
ReasonKlusterletPrepared = "KlusterletPrepared"

// ReasonKlusterletGetDeploymentFailed is the reason of ConditionKlusterletAvailable/ConditionRegistrationDesiredDegraded/ConditionWorkDesiredDegraded
// condition to show 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 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 4300319

Please sign in to comment.