← Back to team overview

launchpad-reviewers team mailing list archive

[Merge] ~cjwatson/txpkgupload:charm-send-sftp-port into txpkgupload:master

 

Colin Watson has proposed merging ~cjwatson/txpkgupload:charm-send-sftp-port into txpkgupload:master.

Commit message:
charm: Tell haproxy to send to the SFTP port

Requested reviews:
  Launchpad code reviewers (launchpad-reviewers)

For more details, see:
https://code.launchpad.net/~cjwatson/txpkgupload/+git/txpkgupload/+merge/455549

The arrangements to use whatever port the client used are only actually necessary for FTP.  On production, we're using iptables to redirect incoming traffic on port 22 to port 5022, and not specifying the port causes haproxy to send traffic to port 22 on the backend, which is not what we want to happen.
-- 
Your team Launchpad code reviewers is requested to review the proposed merge of ~cjwatson/txpkgupload:charm-send-sftp-port into txpkgupload:master.
diff --git a/charm/txpkgupload/reactive/txpkgupload.py b/charm/txpkgupload/reactive/txpkgupload.py
index 689aa90..ab13487 100644
--- a/charm/txpkgupload/reactive/txpkgupload.py
+++ b/charm/txpkgupload/reactive/txpkgupload.py
@@ -250,9 +250,6 @@ def configure_loadbalancer():
     ftp_port = config["ftp_port"]
     sftp_port = config["sftp_port"]
 
-    # Note that we don't send specific ports for the services.servers list.
-    # Not setting a port makes the haproxy use the same port used in the
-    # client's request.
     services = [
         {
             "service_name": "txpkgupload-ftp",
@@ -263,6 +260,8 @@ def configure_loadbalancer():
                 [
                     f"ftp_{unit_name}",
                     unit_ip,
+                    # Not setting a port makes haproxy use the same port
+                    # used in the client's request.
                     "",
                     server_options.replace("{port}", str(ftp_port)),
                 ]
@@ -277,7 +276,7 @@ def configure_loadbalancer():
                 [
                     f"sftp_{unit_name}",
                     unit_ip,
-                    "",
+                    sftp_port,
                     server_options.replace("{port}", str(sftp_port)),
                 ]
             ],