Skip to content
This repository has been archived by the owner on Aug 12, 2024. It is now read-only.

Commit

Permalink
handle case where no probes are configured
Browse files Browse the repository at this point in the history
Signed-off-by: Per Goncalves da Silva <[email protected]>
  • Loading branch information
Per Goncalves da Silva committed Oct 16, 2023
1 parent bd9be90 commit 44c7e40
Show file tree
Hide file tree
Showing 2 changed files with 25 additions and 20 deletions.
35 changes: 18 additions & 17 deletions api/v1alpha1/bundledeployment_types.go
Original file line number Diff line number Diff line change
Expand Up @@ -32,23 +32,24 @@ const (
TypeInstalled = "Installed"
TypeAvailable = "Available"

ReasonBundleLoadFailed = "BundleLoadFailed"
ReasonCreateDynamicWatchFailed = "CreateDynamicWatchFailed"
ReasonErrorGettingClient = "ErrorGettingClient"
ReasonErrorGettingReleaseState = "ErrorGettingReleaseState"
ReasonHealthy = "Healthy"
ReasonInstallationStatusFalse = "InstallationStatusFalse"
ReasonInstallationStatusUnknown = "InstallationStatusUnknown"
ReasonInstallationSucceeded = "InstallationSucceeded"
ReasonInstallFailed = "InstallFailed"
ReasonObjectLookupFailure = "ObjectLookupFailure"
ReasonReadingContentFailed = "ReadingContentFailed"
ReasonReconcileFailed = "ReconcileFailed"
ReasonUnhealthy = "Unhealthy"
ReasonUpgradeFailed = "UpgradeFailed"
ReasonInvalidProbeSyntax = "InvalidAvailabilityProbeSyntax"
ReasonAvailabilityProbeFailed = "AvailabilityProbeFailed"
ReasonAvailabilityProbeSucceeded = "AvailabilityProbeSucceeded"
ReasonBundleLoadFailed = "BundleLoadFailed"
ReasonCreateDynamicWatchFailed = "CreateDynamicWatchFailed"
ReasonErrorGettingClient = "ErrorGettingClient"
ReasonErrorGettingReleaseState = "ErrorGettingReleaseState"
ReasonHealthy = "Healthy"
ReasonInstallationStatusFalse = "InstallationStatusFalse"
ReasonInstallationStatusUnknown = "InstallationStatusUnknown"
ReasonInstallationSucceeded = "InstallationSucceeded"
ReasonInstallFailed = "InstallFailed"
ReasonObjectLookupFailure = "ObjectLookupFailure"
ReasonReadingContentFailed = "ReadingContentFailed"
ReasonReconcileFailed = "ReconcileFailed"
ReasonUnhealthy = "Unhealthy"
ReasonUpgradeFailed = "UpgradeFailed"
ReasonInvalidProbeSyntax = "InvalidAvailabilityProbeSyntax"
ReasonAvailabilityProbeFailed = "AvailabilityProbeFailed"
ReasonAvailabilityProbeSucceeded = "Available"
ReasonAvailabilityNoProbesConfigured = "NoProbesConfigured"
)

// BundleDeploymentSpec defines the desired state of BundleDeployment
Expand Down
10 changes: 7 additions & 3 deletions internal/controllers/bundledeployment/bundledeployment.go
Original file line number Diff line number Diff line change
Expand Up @@ -390,8 +390,7 @@ func (c *controller) reconcile(ctx context.Context, bd *rukpakv1alpha1.BundleDep
})
}

// todo: unknown condition if there are no probes? or just no condition?
if features.RukpakFeatureGate.Enabled(features.BundleDeploymentCustomAvailabilityProbes) && len(bd.Spec.AvailabilityProbes) > 0 {
if features.RukpakFeatureGate.Enabled(features.BundleDeploymentCustomAvailabilityProbes) {
probe, err := probing.Parse(ctx, bd.Spec.AvailabilityProbes)
if err != nil {
meta.SetStatusCondition(&bd.Status.Conditions, metav1.Condition{
Expand All @@ -415,10 +414,15 @@ func (c *controller) reconcile(ctx context.Context, bd *rukpakv1alpha1.BundleDep
return ctrl.Result{}, err
}

successReason := rukpakv1alpha1.ReasonAvailabilityProbeSucceeded
if len(bd.Spec.AvailabilityProbes) == 0 {
successReason = rukpakv1alpha1.ReasonAvailabilityNoProbesConfigured
}

meta.SetStatusCondition(&bd.Status.Conditions, metav1.Condition{
Type: rukpakv1alpha1.TypeAvailable,
Status: metav1.ConditionTrue,
Reason: rukpakv1alpha1.ReasonAvailabilityProbeSucceeded,
Reason: successReason,
Message: "BundleDeployment is available",
})
}
Expand Down

0 comments on commit 44c7e40

Please sign in to comment.