Forum OpenACS Q&A: Re: Issue with reachable method in 5.10.1 dynamic clustering setup

Hi Gustaf,

I tested out the changes you have made and found that a few more changes are required and one slight change to the util::join_location method.

Here is a git diff showing the necessary changes. Let me know if you need more info since maybe the line numbers don't match up on your side. It includes all of the changes from this thread and a couple of other changes. Mainly two additional changes

1. Inside current_server_locations needs to use the noabbrev flag as well otherwise it won't match when checking against the dynamic peers list to see if it is already in the list and a few other checks

2. In util::join_location the port was being set to "" before the new if clause in your last patch since $proto is set. Needed to make sure noabbrev_p  is false in that case to not clear the port. Also the new check needs to validate noabbrev_p is true rather than false to append the port.

diff --git a/packages/acs-tcl/tcl/cluster-procs.tcl b/packages/acs-tcl/tcl/cluster-procs.tcl
@@ -529,7 +530,7 @@ namespace eval ::acs {
            #
            dict set d host [ns_addrbyhost [dict get $d host]]
            dict with d {
-                set result [util::join_location -proto $proto -hostname $host -port $port]
+                set result [util::join_location -noabbrev -proto $proto -hostname $host -port $port]
            }
            return $result
        }
@@ -586,15 +587,17 @@ namespace eval ::acs {
                                lappend result [util::join_location \
-                                                    -proto [dict get $protos $module_type] \
+                                                    -noabbrev -proto [dict get $protos $module_type] \
                                                    -hostname $ip \
                                                    -port $port]
                            }
@@ -646,7 +649,8 @@ namespace eval ::acs {
                #
                ns_log notice "Cluster join_request $peerLocation accepted from $peerLocation"
                set dynamicClusterNodes [parameter::get -package_id $::acs::kernel_id -parameter DynamicClusterPeers]
-                set dynamicClusterNodes [lsort -unique [concat $dynamicClusterNodes $peerLocation]]
+                set dynamicClusterNodes [lsort -unique [concat $dynamicClusterNodes [:qualified_location $peerLocation]]]
                #
                # The parameter::set_value operation causes a
                # clusterwide cache-flush for the parameters

diff --git a/packages/acs-tcl/tcl/utilities-procs.tcl b/packages/acs-tcl/tcl/utilities-procs.tcl
index 4b41b73ba..89b289b22 100644
--- a/packages/acs-tcl/tcl/utilities-procs.tcl
+++ b/packages/acs-tcl/tcl/utilities-procs.tcl
@@ -1923,13 +1923,16 @@ ad_proc util::split_location {location protoVar hostnameVar portVar} {
    return $success
}

-ad_proc util::join_location {{-proto ""} {-hostname} {-port ""}} {
+ad_proc util::join_location {{-noabbrev:boolean} {-proto ""} {-hostname} {-port ""}} {
    Join hostname and port and use IP-literal notation when necessary.
    The function is the inverse function of  util::split_location.
+    @param noabbrev when specified, the location is joined as requested.
+                     Otherwise, default ports are omitted from the result.
    @return location consisting of hostname and optionally port
    @author Gustaf Neumann
    @see util::split_location
} {
    set result ""
    if {$proto ne ""} {
        append result $proto://
@@ -1937,7 +1940,7 @@ ad_proc util::join_location {{-proto ""} {-hostname} {-port ""}} {
        # When the specified port is equal to the default port, omit
        # it from the result.
        #
-        if {$port ne "" && $port eq [dict get {http 80 https 443 udp "" smtp ""} $proto]} {
+        if {!$noabbrev_p && $port ne "" && $port eq [dict get {http 80 https 443 udp "" smtp ""} $proto]} {
            set port ""
        }
    }
@@ -1946,7 +1949,10 @@ ad_proc util::join_location {{-proto ""} {-hostname} {-port ""}} {
    } else {
        append result $hostname
    }
-    if {$port ne ""} {
+    if {$noabbrev_p
+         && $port ne ""
+         && $port eq [dict get {http 80 https 443 udp "" smtp ""} $proto]
+     } {
        append result :$port
    }
    return $result