Skip to content

Commit

Permalink
Re-add shouldDeleteRoute
Browse files Browse the repository at this point in the history
  • Loading branch information
kabicin committed Apr 23, 2024
1 parent cd82c8e commit 13fa385
Showing 1 changed file with 16 additions and 0 deletions.
16 changes: 16 additions & 0 deletions controllers/webspherelibertyapplication_controller.go
Original file line number Diff line number Diff line change
Expand Up @@ -971,6 +971,22 @@ func (r *ReconcileWebSphereLiberty) getDNSEgressRule(reqLogger logr.Logger, endp
return true, dnsRule
}

// If a custome hostname was previously set, but is now not set, any previous
// route needs to be deleted, as the host in a route cannot be unset
// and the default generated hostname is difficult to manually recreate
func shouldDeleteRoute(ba common.BaseComponent) bool {
rh := ba.GetStatus().GetReferences()[common.StatusReferenceRouteHost]
if rh != "" {
// The host was previously set.
// If the host is now empty, delete the old route
rt := ba.GetRoute()
if rt == nil || (rt.GetHost() == "" && common.Config[common.OpConfigDefaultHostname] == "") {
return true
}
}
return false
}

func (r *ReconcileWebSphereLiberty) getEndpoints(serviceName string, namespace string) (*corev1.Endpoints, error) {
endpoints := &corev1.Endpoints{}
if err := r.GetClient().Get(context.TODO(), types.NamespacedName{Name: serviceName, Namespace: namespace}, endpoints); err != nil {
Expand Down

0 comments on commit 13fa385

Please sign in to comment.