[Launchpad-reviewers] [Merge] ~ines-almeida/txpkgupload:charm-bump-haproxy-timeouts into txpkgupload:master

2023-11-17 Thread Ines Almeida
Ines Almeida has proposed merging 
~ines-almeida/txpkgupload:charm-bump-haproxy-timeouts into txpkgupload:master.

Commit message:
charm: bump haproxy timeouts for ftp and sftp uploads

Requested reviews:
  Launchpad code reviewers (launchpad-reviewers)

For more details, see:
https://code.launchpad.net/~ines-almeida/txpkgupload/+git/txpkgupload/+merge/455796
-- 
Your team Launchpad code reviewers is requested to review the proposed merge of 
~ines-almeida/txpkgupload:charm-bump-haproxy-timeouts into txpkgupload:master.
diff --git a/charm/txpkgupload/config.yaml b/charm/txpkgupload/config.yaml
index c4fb6bf..f9bd5b7 100644
--- a/charm/txpkgupload/config.yaml
+++ b/charm/txpkgupload/config.yaml
@@ -22,6 +22,8 @@ options:
   - mode tcp
   - option tcplog
   - balance leastconn
+  - timeout client 180
+  - timeout server 180
   haproxy_service_options_sftp:
 type: string
 description: HAProxy options for the SFTP port.
@@ -29,6 +31,8 @@ options:
   - mode tcp
   - option tcplog
   - balance leastconn
+  - timeout client 180
+  - timeout server 180
   log_hosts_allow:
 type: string
 description: >
___
Mailing list: https://launchpad.net/~launchpad-reviewers
Post to : launchpad-reviewers@lists.launchpad.net
Unsubscribe : https://launchpad.net/~launchpad-reviewers
More help   : https://help.launchpad.net/ListHelp


[Launchpad-reviewers] [Merge] ~cjwatson/launchpad:charm-db-update-fix-backend-connections into launchpad:master

2023-11-17 Thread Colin Watson
Colin Watson has proposed merging 
~cjwatson/launchpad:charm-db-update-fix-backend-connections into 
launchpad:master.

Commit message:
charm: Fix launchpad-db-update's connections to backend databases

Requested reviews:
  Launchpad code reviewers (launchpad-reviewers)

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

The launchpad-db-update charm typically needs to connect directly to backend 
databases, bypassing pgbouncer, because it needs to be able to disable ordinary 
database access via pgbouncer before performing schema updates.  I discovered 
when testing this on staging that I hadn't quite got all the connection 
arrangements for this right.
-- 
Your team Launchpad code reviewers is requested to review the proposed merge of 
~cjwatson/launchpad:charm-db-update-fix-backend-connections into 
launchpad:master.
diff --git a/charm/launchpad-db-update/config.yaml b/charm/launchpad-db-update/config.yaml
new file mode 100644
index 000..90cc41d
--- /dev/null
+++ b/charm/launchpad-db-update/config.yaml
@@ -0,0 +1,12 @@
+options:
+  backend_database_name:
+type: string
+description: >
+  Name of the database we are updating.  (This must be the name of the
+  database as known to PostgreSQL, which is not necessarily the same as
+  that exposed by pgbouncer.)
+default: "launchpad_dev"
+  backend_database_user:
+type: string
+description: User name to use when connecting to backend databases.
+default: "postgres"
diff --git a/charm/launchpad-db-update/reactive/launchpad-db-update.py b/charm/launchpad-db-update/reactive/launchpad-db-update.py
index e9c4b06..0bb9806 100644
--- a/charm/launchpad-db-update/reactive/launchpad-db-update.py
+++ b/charm/launchpad-db-update/reactive/launchpad-db-update.py
@@ -21,8 +21,10 @@ from ols import base, postgres
 from psycopg2.extensions import make_dsn, parse_dsn
 
 
-def any_dbname(dsn):
+def any_host_or_port_or_dbname(dsn):
 parsed_dsn = parse_dsn(dsn)
+parsed_dsn["host"] = "*"
+parsed_dsn["port"] = "*"
 parsed_dsn["dbname"] = "*"
 return make_dsn(**parsed_dsn)
 
@@ -43,8 +45,11 @@ def configure():
 db_admin = endpoint_from_flag("db-admin.master.available")
 db_admin_primary, _ = postgres.get_db_uris(db_admin)
 # We assume that this admin user works for any database on this host,
-# which seems to be true in practice.
-update_pgpass(any_dbname(db_admin_primary))
+# which seems to be true in practice.  Indeed, since we need to bypass
+# pgbouncer and contact backend databases directly, assume that it works
+# for any host or port too so that we don't need to configure
+# credentials for all the database hosts individually.
+update_pgpass(any_host_or_port_or_dbname(db_admin_primary))
 config["db_admin_primary"] = strip_dsn_authentication(db_admin_primary)
 
 if is_flag_set("pgbouncer.master.available"):
diff --git a/charm/launchpad-db-update/templates/db-update.j2 b/charm/launchpad-db-update/templates/db-update.j2
index 4ca8e87..002933d 100755
--- a/charm/launchpad-db-update/templates/db-update.j2
+++ b/charm/launchpad-db-update/templates/db-update.j2
@@ -11,7 +11,9 @@ export LPCONFIG=launchpad-db-update
 {% if pgbouncer_primary -%}
 # Fastdowntime update, managing connections using pgbouncer.
 {{ code_dir }}/database/schema/full-update.py \
---pgbouncer='{{ pgbouncer_primary }}'
+--pgbouncer='{{ pgbouncer_primary }}' \
+--dbname='{{ backend_database_name }}' \
+--dbuser='{{ backend_database_user }}'
 {% else -%}
 # We can't manage connections using pgbouncer in this environment.  Attempt
 # a simple schema upgrade, which may fail if anything has an active database
diff --git a/charm/launchpad-db-update/templates/preflight.j2 b/charm/launchpad-db-update/templates/preflight.j2
index ef2a88f..906938f 100755
--- a/charm/launchpad-db-update/templates/preflight.j2
+++ b/charm/launchpad-db-update/templates/preflight.j2
@@ -7,5 +7,7 @@
 set -e
 
 LPCONFIG=launchpad-db-update {{ code_dir }}/database/schema/preflight.py \
---skip-connection-check --pgbouncer='{{ pgbouncer_primary }}'
+--skip-connection-check --pgbouncer='{{ pgbouncer_primary }}' \
+--dbname='{{ backend_database_name }}' \
+--dbuser='{{ backend_database_user }}'
 
___
Mailing list: https://launchpad.net/~launchpad-reviewers
Post to : launchpad-reviewers@lists.launchpad.net
Unsubscribe : https://launchpad.net/~launchpad-reviewers
More help   : https://help.launchpad.net/ListHelp


[Launchpad-reviewers] [Merge] ~ines-almeida/txpkgupload:remove-passive-ftp-ports-from-sftp-haproxy-config into txpkgupload:master

2023-11-17 Thread Ines Almeida
Ines Almeida has proposed merging 
~ines-almeida/txpkgupload:remove-passive-ftp-ports-from-sftp-haproxy-config 
into txpkgupload:master.

Commit message:
Remove passive ftp ports from sftp haproxy config

Requested reviews:
  Launchpad code reviewers (launchpad-reviewers)

For more details, see:
https://code.launchpad.net/~ines-almeida/txpkgupload/+git/txpkgupload/+merge/455770
-- 
Your team Launchpad code reviewers is requested to review the proposed merge of 
~ines-almeida/txpkgupload:remove-passive-ftp-ports-from-sftp-haproxy-config 
into txpkgupload:master.
diff --git a/charm/txpkgupload/reactive/txpkgupload.py b/charm/txpkgupload/reactive/txpkgupload.py
index bb22539..f0d5de6 100644
--- a/charm/txpkgupload/reactive/txpkgupload.py
+++ b/charm/txpkgupload/reactive/txpkgupload.py
@@ -251,7 +251,6 @@ def configure_loadbalancer():
 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"]
___
Mailing list: https://launchpad.net/~launchpad-reviewers
Post to : launchpad-reviewers@lists.launchpad.net
Unsubscribe : https://launchpad.net/~launchpad-reviewers
More help   : https://help.launchpad.net/ListHelp