Skip to content

Commit c7f7bee

Browse files
authored
Merge pull request #318 from ooni/fastpath-sshfeeder-fixes
FP 0.29: S3 cache trim, sshfeeder fixes
2 parents 10f082d + 78cdc3a commit c7f7bee

File tree

4 files changed

+21
-2
lines changed

4 files changed

+21
-2
lines changed

af/fastpath/debian/changelog

+7
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,10 @@
1+
fastpath (0.29) unstable; urgency=medium
2+
3+
* Trim S3 cache immediately
4+
* Sshfeeder fixes
5+
6+
-- Federico Ceratto <[email protected]> Mon, 25 May 2020 12:35:26 +0100
7+
18
fastpath (0.28) unstable; urgency=medium
29

310
* Add file trimming safety

af/fastpath/fastpath/core.py

+7-1
Original file line numberDiff line numberDiff line change
@@ -110,6 +110,8 @@ def setup():
110110
help="Do not write measurement on disk")
111111
ap.add_argument("--no-write-to-db", action="store_true",
112112
help="Do not insert measurement in database")
113+
ap.add_argument("--keep-s3-cache", action="store_true",
114+
help="Keep files downloaded from S3 in the local cache")
113115
conf = ap.parse_args()
114116

115117
if conf.devel or conf.stdout or no_journal_handler:
@@ -291,8 +293,12 @@ def match_fingerprints(measurement):
291293
zzfps = fingerprints["ZZ"]
292294
ccfps = fingerprints.get(msm_cc, {})
293295

296+
test_keys = measurement["test_keys"]
297+
if test_keys is None:
298+
return []
299+
294300
matches = []
295-
for req in measurement["test_keys"].get("requests", ()):
301+
for req in test_keys.get("requests", ()):
296302
r = req.get("response", None)
297303
if r is None:
298304
continue

af/fastpath/fastpath/s3feeder.py

+6
Original file line numberDiff line numberDiff line change
@@ -222,6 +222,12 @@ def stream_cans(conf, start_day: date, end_day: date) -> Generator[MsmtTup, None
222222
except Exception as e:
223223
log.error(str(e), exc_info=True)
224224

225+
if not conf.keep_s3_cache:
226+
try:
227+
can_f.unlink()
228+
except FileNotFoundError:
229+
pass
230+
225231
day += timedelta(days=1)
226232

227233
if end_day:

af/fastpath/fastpath/sshfeeder.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -119,7 +119,7 @@ def scan_new_files(self):
119119
stdin, stdout, stderr = self.ssh.exec_command(find_cmd, timeout=10)
120120
except (paramiko.ssh_exception.SSHException, AttributeError):
121121
# handle: AttributeError: 'NoneType' object has no attribute 'open_session'
122-
self.error("Broken SSH connection. Retrying.")
122+
log.error("Broken SSH connection. Retrying.")
123123
# We retry only once here. On failure we'll try again on the new
124124
# call to scan_new_files
125125
self._tryconnect()

0 commit comments

Comments
 (0)