Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Move all HC conditions into its own file #1887

Merged
merged 1 commit into from
Nov 23, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
118 changes: 118 additions & 0 deletions api/v1alpha1/conditions.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,118 @@
package v1alpha1

// HostedCluster conditions.
const (
// HostedClusterAvailable indicates whether the HostedCluster has a healthy
// control plane.
HostedClusterAvailable ConditionType = "Available"
// HostedClusterProgressing indicates whether the HostedCluster is attempting
// an initial deployment or upgrade.
HostedClusterProgressing ConditionType = "Progressing"
// HostedClusterDegraded indicates whether the HostedCluster is encountering
// an error that may require user intervention to resolve.
HostedClusterDegraded ConditionType = "Degraded"

// Bubble up from HCP.

// InfrastructureReady bubbles up the same condition from HCP.
InfrastructureReady ConditionType = "InfrastructureReady"
// KubeAPIServerAvailable bubbles up the same condition from HCP.
KubeAPIServerAvailable ConditionType = "KubeAPIServerAvailable"
// EtcdAvailable bubbles up the same condition from HCP.
EtcdAvailable ConditionType = "EtcdAvailable"
// ValidHostedControlPlaneConfiguration bubbles up the same condition from HCP.
ValidHostedControlPlaneConfiguration ConditionType = "ValidHostedControlPlaneConfiguration"

// Bubble up from HCP which bubbles up from CVO.

// ClusterVersionSucceeding indicates the current status of the desired release
// version of the HostedCluster as indicated by the Failing condition in the
// underlying cluster's ClusterVersion.
ClusterVersionSucceeding ConditionType = "ClusterVersionSucceeding"
// ClusterVersionUpgradeable indicates the Upgradeable condition in the
// underlying cluster's ClusterVersion.
ClusterVersionUpgradeable ConditionType = "ClusterVersionUpgradeable"
// ClusterVersionFailing bubbles up Failing from the CVO.
ClusterVersionFailing ConditionType = "ClusterVersionFailing"
// ClusterVersionProgressing bubbles up configv1.OperatorProgressing from the CVO.
ClusterVersionProgressing ConditionType = "ClusterVersionProgressing"
// ClusterVersionAvailable bubbles up Failing configv1.OperatorAvailable from the CVO.
ClusterVersionAvailable ConditionType = "ClusterVersionAvailable"
// ClusterVersionReleaseAccepted bubbles up Failing ReleaseAccepted from the CVO.
ClusterVersionReleaseAccepted ConditionType = "ClusterVersionReleaseAccepted"

// UnmanagedEtcdAvailable indicates whether a user-managed etcd cluster is
// healthy.
UnmanagedEtcdAvailable ConditionType = "UnmanagedEtcdAvailable"

// IgnitionEndpointAvailable indicates whether the ignition server for the
// HostedCluster is available to handle ignition requests.
IgnitionEndpointAvailable ConditionType = "IgnitionEndpointAvailable"

// ValidHostedClusterConfiguration indicates (if status is true) that the
// ClusterConfiguration specified for the HostedCluster is valid.
ValidHostedClusterConfiguration ConditionType = "ValidConfiguration"

// SupportedHostedCluster indicates whether a HostedCluster is supported by
// the current configuration of the hypershift-operator.
// e.g. If HostedCluster requests endpointAcess Private but the hypershift-operator
// is running on a management cluster outside AWS or is not configured with AWS
// credentials, the HostedCluster is not supported.
SupportedHostedCluster ConditionType = "SupportedHostedCluster"

// ValidOIDCConfiguration indicates if an AWS cluster's OIDC condition is
// detected as invalid.
ValidOIDCConfiguration ConditionType = "ValidOIDCConfiguration"

// ValidReleaseImage indicates if the release image set in the spec is valid
// for the HostedCluster. For example, this can be set false if the
// HostedCluster itself attempts an unsupported version before 4.9 or an
// unsupported upgrade e.g y-stream upgrade before 4.11.
ValidReleaseImage ConditionType = "ValidReleaseImage"

// PlatformCredentialsFound indicates that credentials required for the
// desired platform are valid.
PlatformCredentialsFound ConditionType = "PlatformCredentialsFound"

// ReconciliationActive indicates if reconciliation of the HostedCluster is
// active or paused.
ReconciliationActive ConditionType = "ReconciliationActive"
// ReconciliationSucceeded indicates if the HostedCluster reconciliation
// succeeded.
ReconciliationSucceeded ConditionType = "ReconciliationSucceeded"
)

// Reasons.
const (
StatusUnknownReason = "StatusUnknown"
AsExpectedReason = "AsExpected"
NotFoundReason = "NotFound"
WaitingForAvailableReason = "waitingForAvailable"
SecretNotFoundReason = "SecretNotFound"

InfraStatusFailureReason = "InfraStatusFailure"
WaitingOnInfrastructureReadyReason = "WaitingOnInfrastructureReady"

EtcdQuorumAvailableReason = "QuorumAvailable"
EtcdWaitingForQuorumReason = "EtcdWaitingForQuorum"
EtcdStatefulSetNotFoundReason = "StatefulSetNotFound"

UnmanagedEtcdMisconfiguredReason = "UnmanagedEtcdMisconfigured"
UnmanagedEtcdAsExpected = "UnmanagedEtcdAsExpected"

FromClusterVersionReason = "FromClusterVersion"

InvalidConfigurationReason = "InvalidConfiguration"
KubeconfigWaitingForCreateReason = "KubeconfigWaitingForCreate"
UnsupportedHostedClusterReason = "UnsupportedHostedCluster"
InsufficientClusterCapabilitiesReason = "InsufficientClusterCapabilities"
OIDCConfigurationInvalidReason = "OIDCConfigurationInvalid"
PlatformCredentialsNotFoundReason = "PlatformCredentialsNotFound"
InvalidImageReason = "InvalidImage"
)

// Messages.
const (
// AllIsWellMessage is standard message.
AllIsWellMessage = "All is well"
)
24 changes: 5 additions & 19 deletions api/v1alpha1/hosted_controlplane.go
Original file line number Diff line number Diff line change
Expand Up @@ -214,25 +214,11 @@ type KubeconfigSecretRef struct {
type ConditionType string

const (
HostedControlPlaneAvailable ConditionType = "Available"
HostedControlPlaneDegraded ConditionType = "Degraded"
EtcdAvailable ConditionType = "EtcdAvailable"
EtcdSnapshotRestored ConditionType = "EtcdSnapshotRestored"
KubeAPIServerAvailable ConditionType = "KubeAPIServerAvailable"
InfrastructureReady ConditionType = "InfrastructureReady"
ValidHostedControlPlaneConfiguration ConditionType = "ValidHostedControlPlaneConfiguration"
// ClusterVersionFailing bubbles up Failing from the CVO.
ClusterVersionFailing ConditionType = "ClusterVersionFailing"
// ClusterVersionProgressing bubbles up configv1.OperatorProgressing from the CVO.
ClusterVersionProgressing ConditionType = "ClusterVersionProgressing"
// ClusterVersionAvailable bubbles up Failing configv1.OperatorAvailable from the CVO.
ClusterVersionAvailable ConditionType = "ClusterVersionAvailable"
// ClusterVersionReleaseAccepted bubbles up Failing ReleaseAccepted from the CVO.
ClusterVersionReleaseAccepted ConditionType = "ClusterVersionReleaseAccepted"
CVOScaledDown ConditionType = "CVOScaledDown"
CloudResourcesDestroyed ConditionType = "CloudResourcesDestroyed"
InfraStatusFailureReason = "InfraStatusFailure"
WaitingOnInfrastructureReadyReason = "WaitingOnInfrastructureReady"
HostedControlPlaneAvailable ConditionType = "Available"
HostedControlPlaneDegraded ConditionType = "Degraded"
EtcdSnapshotRestored ConditionType = "EtcdSnapshotRestored"
CVOScaledDown ConditionType = "CVOScaledDown"
CloudResourcesDestroyed ConditionType = "CloudResourcesDestroyed"
)

// HostedControlPlaneStatus defines the observed state of HostedControlPlane
Expand Down
106 changes: 0 additions & 106 deletions api/v1alpha1/hostedcluster_types.go
Original file line number Diff line number Diff line change
Expand Up @@ -1639,112 +1639,6 @@ type AESCBCSpec struct {
BackupKey *corev1.LocalObjectReference `json:"backupKey,omitempty"`
}

const (
// HostedClusterAvailable indicates whether the HostedCluster has a healthy
// control plane.
HostedClusterAvailable ConditionType = "Available"

// HostedClusterProgressing indicates whether the HostedCluster is attempting
// an initial deployment or upgrade.
HostedClusterProgressing ConditionType = "Progressing"

// HostedClusterDegraded indicates whether the HostedCluster is encountering
// an error that may require user intervention to resolve.
HostedClusterDegraded ConditionType = "Degraded"

// IgnitionEndpointAvailable indicates whether the ignition server for the
// HostedCluster is available to handle ignition requests.
IgnitionEndpointAvailable ConditionType = "IgnitionEndpointAvailable"

// UnmanagedEtcdAvailable indicates whether a user-managed etcd cluster is
// healthy.
UnmanagedEtcdAvailable ConditionType = "UnmanagedEtcdAvailable"

// ValidHostedClusterConfiguration indicates (if status is true) that the
// ClusterConfiguration specified for the HostedCluster is valid.
ValidHostedClusterConfiguration ConditionType = "ValidConfiguration"

// SupportedHostedCluster indicates whether a HostedCluster is supported by
// the current configuration of the hypershift-operator.
// e.g. If HostedCluster requests endpointAcess Private but the hypershift-operator
// is running on a management cluster outside AWS or is not configured with AWS
// credentials, the HostedCluster is not supported.
SupportedHostedCluster ConditionType = "SupportedHostedCluster"

// ClusterVersionSucceeding indicates the current status of the desired release
// version of the HostedCluster as indicated by the Failing condition in the
// underlying cluster's ClusterVersion.
ClusterVersionSucceeding ConditionType = "ClusterVersionSucceeding"

// ClusterVersionUpgradeable indicates the Upgradeable condition in the
// underlying cluster's ClusterVersion.
ClusterVersionUpgradeable ConditionType = "ClusterVersionUpgradeable"

// ReconciliationActive indicates if reconciliation of the hostedcluster is
// active or paused.
ReconciliationActive ConditionType = "ReconciliationActive"

// ReconciliationSucceeded indicates if the hostedcluster reconciliation
// succeeded.
ReconciliationSucceeded ConditionType = "ReconciliationSucceeded"

// ValidOIDCConfiguration indicates if an AWS cluster's OIDC condition is
// detected as invalid.
ValidOIDCConfiguration ConditionType = "ValidOIDCConfiguration"

// ValidReleaseImage indicates if the release image set in the spec is valid
// for the HostedCluster. For example, this can be set false if the
// HostedCluster itself attempts an unsupported version before 4.9 or an
// unsupported upgrade e.g y-stream upgrade before 4.11.
ValidReleaseImage ConditionType = "ValidReleaseImage"

// PlatformCredentialsFound indicates that credentials required for the
// desired platform are valid.
PlatformCredentialsFound ConditionType = "PlatformCredentialsFound"
)

const (
IgnitionServerDeploymentAsExpectedReason = "IgnitionServerDeploymentAsExpected"
IgnitionServerDeploymentStatusUnknownReason = "IgnitionServerDeploymentStatusUnknown"
IgnitionServerDeploymentNotFoundReason = "IgnitionServerDeploymentNotFound"
IgnitionServerDeploymentUnavailableReason = "IgnitionServerDeploymentUnavailable"

HostedClusterAsExpectedReason = "HostedClusterAsExpected"
HostedClusterWaitingForAvailableReason = "HostedClusterWaitingForAvailable"
InvalidConfigurationReason = "InvalidConfiguration"

DeploymentNotFoundReason = "DeploymentNotFound"
DeploymentStatusUnknownReason = "DeploymentStatusUnknown"
DeploymentWaitingForAvailableReason = "DeploymentWaitingForAvailable"

HostedControlPlaneComponentsUnavailableReason = "ComponentsUnavailable"
KubeconfigWaitingForCreateReason = "KubeconfigWaitingForCreate"
ClusterVersionStatusUnknownReason = "ClusterVersionStatusUnknown"
FromClusterVersionReason = "FromClusterVersion"

StatusUnknownReason = "StatusUnknown"
AsExpectedReason = "AsExpected"

EtcdQuorumAvailableReason = "QuorumAvailable"
EtcdWaitingForQuorumReason = "EtcdWaitingForQuorum"
EtcdStatusUnknownReason = "EtcdStatusUnknown"
EtcdStatefulSetNotFoundReason = "StatefulSetNotFound"

UnsupportedHostedClusterReason = "UnsupportedHostedCluster"

UnmanagedEtcdStatusUnknownReason = "UnmanagedEtcdStatusUnknown"
UnmanagedEtcdMisconfiguredReason = "UnmanagedEtcdMisconfigured"
UnmanagedEtcdAsExpected = "UnmanagedEtcdAsExpected"

InsufficientClusterCapabilitiesReason = "InsufficientClusterCapabilities"

OIDCConfigurationInvalidReason = "OIDCConfigurationInvalid"
PlatformCredentialsNotFoundReason = "PlatformCredentialsNotFound"

SecretNotFoundReason = "SecretNotFound"
InvalidImageReason = "InvalidImage"
)

// HostedClusterStatus is the latest observed status of a HostedCluster.
type HostedClusterStatus struct {
// Version is the status of the release version applied to the
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -260,7 +260,7 @@ func (r *HostedControlPlaneReconciler) Reconcile(ctx context.Context, req ctrl.R
} else {
condition.Status = metav1.ConditionTrue
condition.Message = "Configuration passes validation"
condition.Reason = hyperv1.HostedClusterAsExpectedReason
condition.Reason = hyperv1.AsExpectedReason
}
meta.SetStatusCondition(&hostedControlPlane.Status.Conditions, condition)
}
Expand All @@ -270,7 +270,7 @@ func (r *HostedControlPlaneReconciler) Reconcile(ctx context.Context, req ctrl.R
newCondition := metav1.Condition{
Type: string(hyperv1.EtcdAvailable),
Status: metav1.ConditionUnknown,
Reason: hyperv1.EtcdStatusUnknownReason,
Reason: hyperv1.StatusUnknownReason,
}
switch hostedControlPlane.Spec.Etcd.ManagementType {
case hyperv1.Managed:
Expand Down Expand Up @@ -338,7 +338,7 @@ func (r *HostedControlPlaneReconciler) Reconcile(ctx context.Context, req ctrl.R
newCondition = metav1.Condition{
Type: string(hyperv1.KubeAPIServerAvailable),
Status: metav1.ConditionFalse,
Reason: hyperv1.DeploymentNotFoundReason,
Reason: hyperv1.NotFoundReason,
Message: "Kube APIServer deployment not found",
}
} else {
Expand All @@ -349,7 +349,7 @@ func (r *HostedControlPlaneReconciler) Reconcile(ctx context.Context, req ctrl.R
newCondition = metav1.Condition{
Type: string(hyperv1.KubeAPIServerAvailable),
Status: metav1.ConditionFalse,
Reason: hyperv1.DeploymentStatusUnknownReason,
Reason: hyperv1.StatusUnknownReason,
}
for _, cond := range deployment.Status.Conditions {
if cond.Type == appsv1.DeploymentAvailable {
Expand All @@ -364,7 +364,7 @@ func (r *HostedControlPlaneReconciler) Reconcile(ctx context.Context, req ctrl.R
newCondition = metav1.Condition{
Type: string(hyperv1.KubeAPIServerAvailable),
Status: metav1.ConditionFalse,
Reason: hyperv1.DeploymentWaitingForAvailableReason,
Reason: hyperv1.WaitingForAvailableReason,
Message: "Waiting for Kube APIServer deployment to become available",
}
}
Expand Down Expand Up @@ -434,9 +434,10 @@ func (r *HostedControlPlaneReconciler) Reconcile(ctx context.Context, req ctrl.R
Port: infraStatus.APIPort,
}
newCondition = metav1.Condition{
Type: string(hyperv1.InfrastructureReady),
Status: metav1.ConditionTrue,
Reason: hyperv1.AsExpectedReason,
Type: string(hyperv1.InfrastructureReady),
Status: metav1.ConditionTrue,
Message: hyperv1.AllIsWellMessage,
Reason: hyperv1.AsExpectedReason,
}
hostedControlPlane.Status.OAuthCallbackURLTemplate = fmt.Sprintf("https://%s:%d/oauthcallback/[identity-provider-name]", infraStatus.OAuthHost, infraStatus.OAuthPort)
} else {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -116,7 +116,7 @@ func (h *hcpStatusReconciler) reconcile(ctx context.Context, hcp *hyperv1.Hosted
hcpCVOCondition = metav1.Condition{
Type: string(conditionType),
Status: metav1.ConditionUnknown,
Reason: hyperv1.ClusterVersionStatusUnknownReason,
Reason: hyperv1.StatusUnknownReason,
Message: unknownStatusMessage,
ObservedGeneration: hcp.Generation,
}
Expand Down
16 changes: 10 additions & 6 deletions docs/content/reference/api.md
Original file line number Diff line number Diff line change
Expand Up @@ -2818,7 +2818,8 @@ underlying cluster&rsquo;s ClusterVersion.</p>
underlying cluster&rsquo;s ClusterVersion.</p>
</td>
</tr><tr><td><p>&#34;EtcdAvailable&#34;</p></td>
<td></td>
<td><p>EtcdAvailable bubbles up the same condition from HCP.</p>
</td>
</tr><tr><td><p>&#34;EtcdSnapshotRestored&#34;</p></td>
<td></td>
</tr><tr><td><p>&#34;Available&#34;</p></td>
Expand All @@ -2842,19 +2843,21 @@ an initial deployment or upgrade.</p>
HostedCluster is available to handle ignition requests.</p>
</td>
</tr><tr><td><p>&#34;InfrastructureReady&#34;</p></td>
<td></td>
<td><p>InfrastructureReady bubbles up the same condition from HCP.</p>
</td>
</tr><tr><td><p>&#34;KubeAPIServerAvailable&#34;</p></td>
<td></td>
<td><p>KubeAPIServerAvailable bubbles up the same condition from HCP.</p>
</td>
</tr><tr><td><p>&#34;PlatformCredentialsFound&#34;</p></td>
<td><p>PlatformCredentialsFound indicates that credentials required for the
desired platform are valid.</p>
</td>
</tr><tr><td><p>&#34;ReconciliationActive&#34;</p></td>
<td><p>ReconciliationActive indicates if reconciliation of the hostedcluster is
<td><p>ReconciliationActive indicates if reconciliation of the HostedCluster is
active or paused.</p>
</td>
</tr><tr><td><p>&#34;ReconciliationSucceeded&#34;</p></td>
<td><p>ReconciliationSucceeded indicates if the hostedcluster reconciliation
<td><p>ReconciliationSucceeded indicates if the HostedCluster reconciliation
succeeded.</p>
</td>
</tr><tr><td><p>&#34;SupportedHostedCluster&#34;</p></td>
Expand All @@ -2873,7 +2876,8 @@ healthy.</p>
ClusterConfiguration specified for the HostedCluster is valid.</p>
</td>
</tr><tr><td><p>&#34;ValidHostedControlPlaneConfiguration&#34;</p></td>
<td></td>
<td><p>ValidHostedControlPlaneConfiguration bubbles up the same condition from HCP.</p>
</td>
</tr><tr><td><p>&#34;ValidOIDCConfiguration&#34;</p></td>
<td><p>ValidOIDCConfiguration indicates if an AWS cluster&rsquo;s OIDC condition is
detected as invalid.</p>
Expand Down