Skip to content
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.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions apis/core/v1beta1/conditions.go
Original file line number Diff line number Diff line change
Expand Up @@ -448,6 +448,9 @@ const (
// OpenStackControlPlaneExposeServiceReadyMessage
OpenStackControlPlaneExposeServiceReadyMessage = "OpenStackControlPlane %s service exposed"

// OpenStackControlPlaneExposeServiceReadyRouteAdmissionErrorMessage
OpenStackControlPlaneExposeServiceReadyRouteAdmissionErrorMessage = "OpenStackControlPlane %s route %s admission failed: %s"

// OpenStackControlPlaneCAReadyInitMessage
OpenStackControlPlaneCAReadyInitMessage = "OpenStackControlPlane CAs not started"

Expand Down
1 change: 1 addition & 0 deletions go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -114,6 +114,7 @@ require (
golang.org/x/tools v0.37.0 // indirect
gomodules.xyz/jsonpatch/v2 v2.5.0 // indirect
google.golang.org/protobuf v1.36.7 // indirect
gopkg.in/evanphx/json-patch.v4 v4.12.0 // indirect
gopkg.in/inf.v0 v0.9.1 // indirect
k8s.io/apiextensions-apiserver v0.33.2 // indirect
k8s.io/klog/v2 v2.130.1 // indirect
Expand Down
59 changes: 59 additions & 0 deletions pkg/openstack/common.go
Original file line number Diff line number Diff line change
Expand Up @@ -516,6 +516,26 @@ func (ed *EndpointDetail) ensureRoute(
return ctrlResult, nil
}

// Check the route admission status and update condition accordingly
err = checkRouteAdmissionStatus(ctx, helper, ed.Name, ed.Namespace)
if err != nil {
instance.Status.Conditions.Set(condition.FalseCondition(
condType,
condition.ErrorReason,
condition.SeverityWarning,
corev1.OpenStackControlPlaneExposeServiceReadyRouteAdmissionErrorMessage,
owner.GetName(),
ed.Name,
err.Error()))
return ctrl.Result{}, err
}

// Route is successfully created and admitted
instance.Status.Conditions.MarkTrue(
condType,
corev1.OpenStackControlPlaneExposeServiceReadyMessage,
owner.GetName())

return ctrl.Result{}, nil
}
instance.Status.Conditions.Remove(condType)
Expand Down Expand Up @@ -707,6 +727,45 @@ func (ed *EndpointDetail) CreateRoute(
return ctrl.Result{}, nil
}

// checkRouteAdmissionStatus checks the admission status of a route and returns an error if not admitted
func checkRouteAdmissionStatus(
ctx context.Context,
helper *helper.Helper,
routeName string,
namespace string,
) error {
serviceRoute := &routev1.Route{}
err := helper.GetClient().Get(ctx, types.NamespacedName{Name: routeName, Namespace: namespace}, serviceRoute)
if err != nil {
return err
}

// Check if the route has ingress status
if len(serviceRoute.Status.Ingress) == 0 {
// Route exists but has no ingress status yet - this is normal during initial creation
// Return nil to allow reconciliation to continue
return nil
}

// Check the admission status of the first ingress
for _, condition := range serviceRoute.Status.Ingress[0].Conditions {
// RouteAdmitted (value: "Admitted") is currently the only officially defined condition type in the OpenShift Route API
// https://github.com/openshift/api/blob/c9bef43e850983ce73f69a58b9da0bd02883c26a/route/v1/types.go#L384
// RouteAdmitted means the route is able to service requests for the provided Host
if condition.Type == routev1.RouteAdmitted {
if condition.Status != k8s_corev1.ConditionTrue {
// Route admission failed - return error with the message
return fmt.Errorf("%s", condition.Message)
}
// Route is admitted successfully
return nil
}
}

// No admission condition found yet - route is still being processed
return nil
}

// GetEndptCertSecret -
func (e *Endpoints) GetEndptCertSecret(endpt service.Endpoint) *string {
var endptTLSSecret *string
Expand Down
Loading