Merge ~cjwatson/txpkgupload:fix-systemd-socket-activation into txpkgupload:master

Proposed by Colin Watson
Status: Merged
Approved by: Colin Watson
Approved revision: fab943402b1f88cf01458116d870891aff7586e7
Merge reported by: Otto Co-Pilot
Merged at revision: not available
Proposed branch: ~cjwatson/txpkgupload:fix-systemd-socket-activation
Merge into: txpkgupload:master
Diff against target: 132 lines (+25/-14)
7 files modified
charm/txpkgupload/charmcraft.yaml (+1/-1)
charm/txpkgupload/templates/txpkgupload.service.j2 (+1/-0)
charm/txpkgupload/templates/txpkgupload.socket.j2 (+4/-2)
charm/txpkgupload/templates/txpkgupload_config.yaml.j2 (+2/-2)
src/txpkgupload/plugin.py (+4/-2)
src/txpkgupload/tests/test_plugin.py (+9/-6)
src/txpkgupload/twistedftp.py (+4/-1)
Reviewer Review Type Date Requested Status
Simone Pelosi Approve
Review via email: mp+450808@code.launchpad.net

Commit message

Fix systemd socket activation

Description of the change

We noticed that the application didn't start up in the new charmed deployment on qastaging. I found that this was because socket activation wasn't set up quite right.

To post a comment you must log in.
Revision history for this message
Simone Pelosi (pelpsi) wrote :

Lgtm!

review: Approve

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
diff --git a/charm/txpkgupload/charmcraft.yaml b/charm/txpkgupload/charmcraft.yaml
index 98f3499..6462c4e 100644
--- a/charm/txpkgupload/charmcraft.yaml
+++ b/charm/txpkgupload/charmcraft.yaml
@@ -35,7 +35,7 @@ parts:
35 after:35 after:
36 - ols-layers36 - ols-layers
37 source: https://git.launchpad.net/launchpad-layers37 source: https://git.launchpad.net/launchpad-layers
38 source-commit: "300b0d9fd332c055395fe209512335cea03c7af3"38 source-commit: "06169f9fa1548bd6abf9be39edf8b81c411595be"
39 source-submodules: []39 source-submodules: []
40 source-type: git40 source-type: git
41 plugin: dump41 plugin: dump
diff --git a/charm/txpkgupload/templates/txpkgupload.service.j2 b/charm/txpkgupload/templates/txpkgupload.service.j2
index efd5b4e..ef44de4 100644
--- a/charm/txpkgupload/templates/txpkgupload.service.j2
+++ b/charm/txpkgupload/templates/txpkgupload.service.j2
@@ -1,6 +1,7 @@
1[Unit]1[Unit]
2Description=Launchpad FTP/SFTP package upload service2Description=Launchpad FTP/SFTP package upload service
3After=network.target3After=network.target
4Requires=txpkgupload.socket
4ConditionPathExists=!{{ code_dir }}/maintenance.txt5ConditionPathExists=!{{ code_dir }}/maintenance.txt
56
6[Service]7[Service]
diff --git a/charm/txpkgupload/templates/txpkgupload.socket.j2 b/charm/txpkgupload/templates/txpkgupload.socket.j2
index 2bdfdf9..435a710 100644
--- a/charm/txpkgupload/templates/txpkgupload.socket.j2
+++ b/charm/txpkgupload/templates/txpkgupload.socket.j2
@@ -1,9 +1,11 @@
1[Unit]1[Unit]
2Description=Twisted package uploader service2Description=Twisted package uploader socket
33
4[Socket]4[Socket]
5ListenStream={{ sftp_port }}5{# The order here must match the index= parameters in
6 txpkgupload_config.yaml.j2. -#}
6ListenStream={{ ftp_port }}7ListenStream={{ ftp_port }}
8ListenStream={{ sftp_port }}
79
8[Install]10[Install]
9WantedBy=sockets.target11WantedBy=sockets.target
diff --git a/charm/txpkgupload/templates/txpkgupload_config.yaml.j2 b/charm/txpkgupload/templates/txpkgupload_config.yaml.j2
index 78b1edb..ea1368c 100644
--- a/charm/txpkgupload/templates/txpkgupload_config.yaml.j2
+++ b/charm/txpkgupload/templates/txpkgupload_config.yaml.j2
@@ -1,11 +1,11 @@
1ftp:1ftp:
2 port: {{ ftp_port }}2 port: "systemd:domain=INET6:index=0"
33
4sftp:4sftp:
5 authentication_endpoint: "{{ sftp_authentication_endpoint }}"5 authentication_endpoint: "{{ sftp_authentication_endpoint }}"
6 host_key_private: "{{ sftp_host_key_private_path }}"6 host_key_private: "{{ sftp_host_key_private_path }}"
7 host_key_public: "{{ sftp_host_key_public_path }}"7 host_key_public: "{{ sftp_host_key_public_path }}"
8 port: "tcp6:{{ sftp_port }}"8 port: "systemd:domain=INET6:index=1"
99
10oops:10oops:
11 directory: "{{ oopses_dir }}"11 directory: "{{ oopses_dir }}"
diff --git a/src/txpkgupload/plugin.py b/src/txpkgupload/plugin.py
index 9cf30ec..b78923c 100644
--- a/src/txpkgupload/plugin.py
+++ b/src/txpkgupload/plugin.py
@@ -72,8 +72,10 @@ class ConfigFtp(Schema):
7272
73 if_key_missing = None73 if_key_missing = None
7474
75 # The port to run the FTP server on.75 # The port to run the FTP server on. This may be a plain integer (in
76 port = Int(if_missing=2121)76 # which case it is prefixed with "tcp6:"), or it may be expressed in
77 # Twisted's "strports" mini-language.
78 port = String(if_missing="2121")
7779
7880
79class ConfigSftp(Schema):81class ConfigSftp(Schema):
diff --git a/src/txpkgupload/tests/test_plugin.py b/src/txpkgupload/tests/test_plugin.py
index 183de40..bb5ee29 100644
--- a/src/txpkgupload/tests/test_plugin.py
+++ b/src/txpkgupload/tests/test_plugin.py
@@ -108,7 +108,7 @@ class TestConfig(TestCase):
108 "debug": False,108 "debug": False,
109 "fsroot": None,109 "fsroot": None,
110 "ftp": {110 "ftp": {
111 "port": 2121,111 "port": "2121",
112 },112 },
113 "idle_timeout": 3600,113 "idle_timeout": 3600,
114 "oops": {114 "oops": {
@@ -148,17 +148,20 @@ class TestConfig(TestCase):
148 "etc", "txpkgupload.yaml")148 "etc", "txpkgupload.yaml")
149 Config.load(filename)149 Config.load(filename)
150150
151 def test_load_ftp_integer(self):
152 observed = Config.parse("ftp:\n port: 21")
153 self.assertEqual("21", observed["ftp"]["port"])
154
155 def test_load_ftp_strports(self):
156 observed = Config.parse("ftp:\n port: tcp6:21")
157 self.assertEqual("tcp6:21", observed["ftp"]["port"])
158
151 def check_exception(self, config, message):159 def check_exception(self, config, message):
152 # Check that a UsageError is raised when parsing options.160 # Check that a UsageError is raised when parsing options.
153 self.assertThat(161 self.assertThat(
154 partial(Config.to_python, config),162 partial(Config.to_python, config),
155 Raises(MatchesException(Invalid, message)))163 Raises(MatchesException(Invalid, message)))
156164
157 def test_option_ftp_port_integer(self):
158 self.check_exception(
159 {"ftp": {"port": "bob"}},
160 "ftp: port: Please enter an integer value")
161
162 def test_option_idle_timeout_integer(self):165 def test_option_idle_timeout_integer(self):
163 self.check_exception(166 self.check_exception(
164 {"idle_timeout": "bob"},167 {"idle_timeout": "bob"},
diff --git a/src/txpkgupload/twistedftp.py b/src/txpkgupload/twistedftp.py
index 37deffb..995fa08 100644
--- a/src/txpkgupload/twistedftp.py
+++ b/src/txpkgupload/twistedftp.py
@@ -376,6 +376,9 @@ class FTPServiceFactory(service.Service):
376376
377 @staticmethod377 @staticmethod
378 def makeFTPService(port, root, temp_dir, idle_timeout):378 def makeFTPService(port, root, temp_dir, idle_timeout):
379 strport = "tcp6:%s" % port379 if port.isdigit():
380 strport = "tcp6:%s" % port
381 else:
382 strport = port
380 factory = FTPServiceFactory(port, root, temp_dir, idle_timeout)383 factory = FTPServiceFactory(port, root, temp_dir, idle_timeout)
381 return strports.service(strport, factory.ftpfactory)384 return strports.service(strport, factory.ftpfactory)

Subscribers

People subscribed via source and target branches

to all changes: