Skip to content

Commit 13fa385

Browse files
committed
Re-add shouldDeleteRoute
1 parent cd82c8e commit 13fa385

File tree

1 file changed

+16
-0
lines changed

1 file changed

+16
-0
lines changed

controllers/webspherelibertyapplication_controller.go

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -971,6 +971,22 @@ func (r *ReconcileWebSphereLiberty) getDNSEgressRule(reqLogger logr.Logger, endp
971971
return true, dnsRule
972972
}
973973

974+
// If a custome hostname was previously set, but is now not set, any previous
975+
// route needs to be deleted, as the host in a route cannot be unset
976+
// and the default generated hostname is difficult to manually recreate
977+
func shouldDeleteRoute(ba common.BaseComponent) bool {
978+
rh := ba.GetStatus().GetReferences()[common.StatusReferenceRouteHost]
979+
if rh != "" {
980+
// The host was previously set.
981+
// If the host is now empty, delete the old route
982+
rt := ba.GetRoute()
983+
if rt == nil || (rt.GetHost() == "" && common.Config[common.OpConfigDefaultHostname] == "") {
984+
return true
985+
}
986+
}
987+
return false
988+
}
989+
974990
func (r *ReconcileWebSphereLiberty) getEndpoints(serviceName string, namespace string) (*corev1.Endpoints, error) {
975991
endpoints := &corev1.Endpoints{}
976992
if err := r.GetClient().Get(context.TODO(), types.NamespacedName{Name: serviceName, Namespace: namespace}, endpoints); err != nil {

0 commit comments

Comments
 (0)