Merge ~pappacena/txpkgupload:dtp-timeout-config into txpkgupload:master

Proposed by Thiago F. Pappacena
Status: Rejected
Rejected by: Thiago F. Pappacena
Proposed branch: ~pappacena/txpkgupload:dtp-timeout-config
Merge into: txpkgupload:master
Diff against target: 104 lines (+22/-4)
4 files modified
etc/txpkgupload.yaml (+3/-0)
src/txpkgupload/plugin.py (+5/-1)
src/txpkgupload/tests/test_plugin.py (+9/-0)
src/txpkgupload/twistedftp.py (+5/-3)
Reviewer Review Type Date Requested Status
William Grant Disapprove
Review via email: mp+393503@code.launchpad.net

Commit message

Adding config parameter for dtp timeout

To post a comment you must log in.
Revision history for this message
William Grant (wgrant) wrote :

If something can't connect within 10 seconds, I'm not sure we care. That's almost always going to be a firewall problem -- even the Moon is only a 3s round trip.

review: Disapprove
Revision history for this message
Thiago F. Pappacena (pappacena) wrote :

The idea was not to have this timeout increased in production, but rather to let a sys admin do, in production, the test they needed to do.

Anyway, I'm closing this MP.

Unmerged commits

6daa850... by Thiago F. Pappacena

Adding config parameter for dtp timeout

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1diff --git a/etc/txpkgupload.yaml b/etc/txpkgupload.yaml
2index 45f7a99..ae94b52 100644
3--- a/etc/txpkgupload.yaml
4+++ b/etc/txpkgupload.yaml
5@@ -40,6 +40,9 @@ oops:
6 ## disconnected.
7 # idle_timeout: 3600
8
9+## DTP connection timeout for FTP connections (defaults to 10).
10+dtp_timeout: 15
11+
12 ## Where on the filesystem do uploads live?
13 # fsroot: "/var/tmp/txpkgupload/incoming"
14
15diff --git a/src/txpkgupload/plugin.py b/src/txpkgupload/plugin.py
16index 0168643..c93933e 100644
17--- a/src/txpkgupload/plugin.py
18+++ b/src/txpkgupload/plugin.py
19@@ -123,6 +123,9 @@ class Config(Schema):
20 # disconnected.
21 idle_timeout = Int(if_missing=3600)
22
23+ # DTP timeout for FTP connections.
24+ dtp_timeout = Int(if_missing=10)
25+
26 # Where on the filesystem do uploads live?
27 fsroot = String(if_missing=None)
28
29@@ -238,7 +241,8 @@ class PkgUploadServiceMaker:
30 port=ftp_config["port"],
31 root=root,
32 temp_dir=temp_dir,
33- idle_timeout=config["idle_timeout"])
34+ idle_timeout=config["idle_timeout"],
35+ dtp_timeout=config["dtp_timeout"])
36 ftp_service.name = "ftp"
37 ftp_service.setServiceParent(services)
38
39diff --git a/src/txpkgupload/tests/test_plugin.py b/src/txpkgupload/tests/test_plugin.py
40index 162c289..9413fe8 100644
41--- a/src/txpkgupload/tests/test_plugin.py
42+++ b/src/txpkgupload/tests/test_plugin.py
43@@ -111,6 +111,7 @@ class TestConfig(TestCase):
44 "port": 2121,
45 },
46 "idle_timeout": 3600,
47+ "dtp_timeout": 10,
48 "oops": {
49 "directory": "",
50 "reporter": "PKGUPLOAD",
51@@ -164,6 +165,11 @@ class TestConfig(TestCase):
52 {"idle_timeout": "bob"},
53 "idle_timeout: Please enter an integer value")
54
55+ def test_option_dtp_timeout_integer(self):
56+ self.check_exception(
57+ {"dtp_timeout": "bob"},
58+ "dtp_timeout: Please enter an integer value")
59+
60
61 class TestOptions(TestCase):
62 """Tests for `txpkgupload.plugin.Options`."""
63@@ -521,6 +527,9 @@ class TestPkgUploadServiceMakerMixin:
64 self.assertEqual(
65 len(service.namedServices), len(service.services),
66 "Not all services are named.")
67+ # Make sure we are using the configurations from the config file.
68+ ftp_service = service.services[0]
69+ self.assertEqual(15, ftp_service.factory.protocol.dtpTimeout)
70
71 def _uploadPath(self, path):
72 """Return system path of specified path inside an upload.
73diff --git a/src/txpkgupload/twistedftp.py b/src/txpkgupload/twistedftp.py
74index 37deffb..8e58b32 100644
75--- a/src/txpkgupload/twistedftp.py
76+++ b/src/txpkgupload/twistedftp.py
77@@ -360,7 +360,7 @@ class FTPWithEPSV(ftp.FTP):
78 class FTPServiceFactory(service.Service):
79 """A factory that makes an `FTPService`"""
80
81- def __init__(self, port, root, temp_dir, idle_timeout):
82+ def __init__(self, port, root, temp_dir, idle_timeout, dtp_timeout):
83 realm = FTPRealm(root, temp_dir)
84 portal = Portal(realm)
85 portal.registerChecker(AccessCheck())
86@@ -368,6 +368,7 @@ class FTPServiceFactory(service.Service):
87
88 factory.tld = root
89 factory.protocol = FTPWithEPSV
90+ factory.protocol.dtpTimeout = dtp_timeout
91 factory.welcomeMessage = "Launchpad upload server"
92 factory.timeOut = idle_timeout
93
94@@ -375,7 +376,8 @@ class FTPServiceFactory(service.Service):
95 self.portno = port
96
97 @staticmethod
98- def makeFTPService(port, root, temp_dir, idle_timeout):
99+ def makeFTPService(port, root, temp_dir, idle_timeout, dtp_timeout):
100 strport = "tcp6:%s" % port
101- factory = FTPServiceFactory(port, root, temp_dir, idle_timeout)
102+ factory = FTPServiceFactory(
103+ port, root, temp_dir, idle_timeout, dtp_timeout)
104 return strports.service(strport, factory.ftpfactory)

Subscribers

People subscribed via source and target branches