← Back to team overview

launchpad-reviewers team mailing list archive

[Merge] ~ines-almeida/txpkgupload:revert-haproxy-and-port-range-charm-changes into txpkgupload:master

 

Ines Almeida has proposed merging ~ines-almeida/txpkgupload:revert-haproxy-and-port-range-charm-changes into txpkgupload:master.

Commit message:
Revert port range and haproxy charm updates
    
This reverts all changes to the '/charm' directory from the last 12 commits (until abfb5cfe), except for the latest commit (baaf5915)

Requested reviews:
  Launchpad code reviewers (launchpad-reviewers)

For more details, see:
https://code.launchpad.net/~ines-almeida/txpkgupload/+git/txpkgupload/+merge/453645
-- 
Your team Launchpad code reviewers is requested to review the proposed merge of ~ines-almeida/txpkgupload:revert-haproxy-and-port-range-charm-changes into txpkgupload:master.
diff --git a/charm/txpkgupload/config.yaml b/charm/txpkgupload/config.yaml
index c4fb6bf..4fa1ef3 100644
--- a/charm/txpkgupload/config.yaml
+++ b/charm/txpkgupload/config.yaml
@@ -3,18 +3,10 @@ options:
     type: int
     default: 2221
     description: The port to run the FTP server on.
-  haproxy_ipv4_address:
-    type: string
-    description: >
-      The IPv4 address of the haproxy unit related to this charm. Only
-      one haproxy unit is expected.
-    default:
   haproxy_server_options:
     type: string
-    description: >
-      Options to add to HAProxy "server" lines. If "{port}" is part of the
-      value, it will be replaced by the 'ftp_port'/'sftp_port'.
-    default: check port {port} inter 5000 rise 2 fall 5 maxconn 16
+    description: Options to add to HAProxy "server" lines.
+    default: check inter 5000 rise 2 fall 5 maxconn 16
   haproxy_service_options_ftp:
     type: string
     description: HAProxy options for the FTP port.
@@ -35,18 +27,6 @@ options:
       Hosts that should be allowed to rsync logs.  Note that this relies on
       the nrpe subordinate charm to set up /etc/rsyncd.conf properly.
     default: ""
-  min_passive_port:
-    type: int
-    default:
-    description: > 
-      The minimum port number possible to use for passive FTP. This config will
-      only take effect if `max_passive_port` is also set.
-  max_passive_port:
-    type: int
-    default:
-    description: > 
-      The maximum port number possible to use for passive FTP. This config will
-      only take effect if `min_passive_port` is also set.
   oops_prefix:
     type: string
     default: local
diff --git a/charm/txpkgupload/reactive/txpkgupload.py b/charm/txpkgupload/reactive/txpkgupload.py
index 8c76b7e..a4adcf8 100644
--- a/charm/txpkgupload/reactive/txpkgupload.py
+++ b/charm/txpkgupload/reactive/txpkgupload.py
@@ -197,21 +197,10 @@ def configure_loadbalancer():
     hookenv.log("Configuring loadbalancer for txpkgupload")
     config = hookenv.config()
 
-    if config.get("haproxy_ipv4_address"):
-        hookenv.log(
-            "Waiting for 'haproxy_ipv4_address' value to be configured"
-        )
-        hookenv.status_set(
-            "blocked",
-            "Blocked until 'haproxy_ipv4_address' value is configured",
-        )
-        return
-
     try:
         service_options_ftp = yaml.safe_load(
             config["haproxy_service_options_ftp"]
         )
-        service_options_ftp = list(service_options_ftp)
     except yaml.YAMLError:
         hookenv.log("Could not parse haproxy_service_options_ftp YAML")
         hookenv.status_set(
@@ -222,7 +211,6 @@ def configure_loadbalancer():
         service_options_sftp = yaml.safe_load(
             config["haproxy_service_options_sftp"]
         )
-        service_options_sftp = list(service_options_sftp)
     except yaml.YAMLError:
         hookenv.log("Could not parse haproxy_service_options_sftp YAML")
         hookenv.status_set(
@@ -233,54 +221,38 @@ def configure_loadbalancer():
 
     unit_name = hookenv.local_unit().replace("/", "-")
     unit_ip = hookenv.unit_private_ip()
-
-    # For passive FTP transfer, we want our haproxy to bind to not only the
-    # usual FTP/SFTP ports but also to higher ports
-    if config.get("min_passive_port") and config.get("max_passive_port"):
-        extra_ports = (
-            f"bind 0.0.0.0:"
-            f"{config['min_passive_port']}-{config['max_passive_port']}"
-        )
-        service_options_ftp.append(extra_ports)
-        service_options_sftp.append(extra_ports)
-
-    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",
-            "service_port": ftp_port,
+            "service_port": config["ftp_port"],
             "service_host": "0.0.0.0",
-            "service_options": service_options_ftp,
+            "service_options": list(service_options_ftp),
             "servers": [
                 [
                     f"ftp_{unit_name}",
                     unit_ip,
-                    "",
-                    server_options.replace("{port}", str(ftp_port)),
+                    config["ftp_port"],
+                    server_options,
                 ]
             ],
         },
         {
             "service_name": "txpkgupload-sftp",
-            "service_port": sftp_port,
+            "service_port": config["sftp_port"],
             "service_host": "0.0.0.0",
-            "service_options": service_options_sftp,
+            "service_options": list(service_options_sftp),
             "servers": [
                 [
                     f"sftp_{unit_name}",
                     unit_ip,
-                    "",
-                    server_options.replace("{port}", str(sftp_port)),
+                    config["sftp_port"],
+                    server_options,
                 ]
             ],
         },
     ]
     services_yaml = yaml.dump(services)
+
     for rel in hookenv.relations_of_type("loadbalancer"):
         hookenv.relation_set(rel["__relid__"], services=services_yaml)
 
diff --git a/charm/txpkgupload/templates/txpkgupload_config.yaml.j2 b/charm/txpkgupload/templates/txpkgupload_config.yaml.j2
index 4b02352..ea1368c 100644
--- a/charm/txpkgupload/templates/txpkgupload_config.yaml.j2
+++ b/charm/txpkgupload/templates/txpkgupload_config.yaml.j2
@@ -17,7 +17,3 @@ fsroot: "{{ fsroot }}"
 
 temp_dir: "{{ base_dir }}/tmp-incoming"
 
-min_passive_port: {{ min_passive_port }}
-max_passive_port: {{ max_passive_port }}
-
-proxy_ipv4_address: {{ haproxy_ipv4_address }}