Skip to content

Commit 2c04f36

Browse files
authored
ci: merge main to release (#8407)
2 parents 4f53cad + e5c4a9f commit 2c04f36

25 files changed

+163
-324
lines changed

dev/INSTALL

-157
This file was deleted.

dev/deploy-to-container/settings_local.py

+1
Original file line numberDiff line numberDiff line change
@@ -64,6 +64,7 @@
6464
BIBXML_BASE_PATH = '/assets/ietfdata/derived/bibxml'
6565
IDSUBMIT_REPOSITORY_PATH = INTERNET_DRAFT_PATH
6666
FTP_DIR = '/assets/ftp'
67+
NFS_METRICS_TMP_DIR = '/assets/tmp'
6768

6869
NOMCOM_PUBLIC_KEYS_DIR = 'data/nomcom_keys/public_keys/'
6970
SLIDE_STAGING_PATH = '/test/staging/'

dev/diff/settings_local.py

+1
Original file line numberDiff line numberDiff line change
@@ -60,6 +60,7 @@
6060
INTERNET_ALL_DRAFTS_ARCHIVE_DIR = '/assets/ietf-ftp/internet-drafts/'
6161
BIBXML_BASE_PATH = '/assets/ietfdata/derived/bibxml'
6262
FTP_DIR = '/assets/ftp'
63+
NFS_METRICS_TMP_DIR = '/assets/tmp'
6364

6465
NOMCOM_PUBLIC_KEYS_DIR = 'data/nomcom_keys/public_keys/'
6566
SLIDE_STAGING_PATH = 'test/staging/'

dev/tests/settings_local.py

+1
Original file line numberDiff line numberDiff line change
@@ -59,6 +59,7 @@
5959
INTERNET_ALL_DRAFTS_ARCHIVE_DIR = '/assets/ietf-ftp/internet-drafts/'
6060
BIBXML_BASE_PATH = '/assets/ietfdata/derived/bibxml'
6161
FTP_DIR = '/assets/ftp'
62+
NFS_METRICS_TMP_DIR = '/assets/tmp'
6263

6364
NOMCOM_PUBLIC_KEYS_DIR = 'data/nomcom_keys/public_keys/'
6465
SLIDE_STAGING_PATH = 'test/staging/'

docker/configs/settings_local.py

+1
Original file line numberDiff line numberDiff line change
@@ -50,6 +50,7 @@
5050
BIBXML_BASE_PATH = '/assets/ietfdata/derived/bibxml'
5151
IDSUBMIT_REPOSITORY_PATH = INTERNET_DRAFT_PATH
5252
FTP_DIR = '/assets/ftp'
53+
NFS_METRICS_TMP_DIR = '/assets/tmp'
5354

5455
NOMCOM_PUBLIC_KEYS_DIR = 'data/nomcom_keys/public_keys/'
5556
SLIDE_STAGING_PATH = '/assets/www6s/staging/'

docker/scripts/app-create-dirs.sh

+1
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,7 @@ for sub in \
2929
/assets/www6/iesg \
3030
/assets/www6/iesg/evaluation \
3131
/assets/media/photo \
32+
/assets/tmp \
3233
/assets/ftp \
3334
/assets/ftp/charter \
3435
/assets/ftp/internet-drafts \

ietf/api/tests.py

+8
Original file line numberDiff line numberDiff line change
@@ -970,6 +970,14 @@ def test_api_appauth(self):
970970
self.assertEqual(jsondata['success'], True)
971971
self.client.logout()
972972

973+
@override_settings(APP_API_TOKENS={"ietf.api.views.nfs_metrics": ["valid-token"]})
974+
def test_api_nfs_metrics(self):
975+
url = urlreverse("ietf.api.views.nfs_metrics")
976+
r = self.client.get(url)
977+
self.assertEqual(r.status_code, 403)
978+
r = self.client.get(url, headers={"X-Api-Key": "valid-token"})
979+
self.assertContains(r, 'nfs_latency_seconds{operation="write"}')
980+
973981
def test_api_get_session_matherials_no_agenda_meeting_url(self):
974982
meeting = MeetingFactory(type_id='ietf')
975983
session = SessionFactory(meeting=meeting)

ietf/api/urls.py

+2
Original file line numberDiff line numberDiff line change
@@ -82,6 +82,8 @@
8282
url(r'^version/?$', api_views.version),
8383
# Application authentication API key
8484
url(r'^appauth/(?P<app>authortools|bibxml)$', api_views.app_auth),
85+
# NFS metrics endpoint
86+
url(r'^metrics/nfs/?$', api_views.nfs_metrics),
8587
# latest versions
8688
url(r'^rfcdiff-latest-json/%(name)s(?:-%(rev)s)?(\.txt|\.html)?/?$' % settings.URL_REGEXPS, api_views.rfcdiff_latest_json),
8789
url(r'^rfcdiff-latest-json/(?P<name>[Rr][Ff][Cc] [0-9]+?)(\.txt|\.html)?/?$', api_views.rfcdiff_latest_json),

ietf/api/views.py

+19-1
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,10 @@
33

44
import base64
55
import binascii
6+
import datetime
67
import json
8+
from pathlib import Path
9+
from tempfile import NamedTemporaryFile
710
import jsonschema
811
import pytz
912
import re
@@ -264,7 +267,22 @@ def app_auth(request, app: Literal["authortools", "bibxml"]):
264267
json.dumps({'success': True}),
265268
content_type='application/json')
266269

267-
270+
@requires_api_token
271+
@csrf_exempt
272+
def nfs_metrics(request):
273+
with NamedTemporaryFile(dir=settings.NFS_METRICS_TMP_DIR,delete=False) as fp:
274+
fp.close()
275+
mark = datetime.datetime.now()
276+
with open(fp.name, mode="w") as f:
277+
f.write("whyioughta"*1024)
278+
write_latency = (datetime.datetime.now() - mark).total_seconds()
279+
mark = datetime.datetime.now()
280+
with open(fp.name, "r") as f:
281+
_=f.read()
282+
read_latency = (datetime.datetime.now() - mark).total_seconds()
283+
Path(f.name).unlink()
284+
response=f'nfs_latency_seconds{{operation="write"}} {write_latency}\nnfs_latency_seconds{{operation="read"}} {read_latency}\n'
285+
return HttpResponse(response)
268286

269287
def find_doc_for_rfcdiff(name, rev):
270288
"""rfcdiff lookup heuristics

ietf/doc/expire.py

+5-43
Original file line numberDiff line numberDiff line change
@@ -13,10 +13,10 @@
1313

1414
from typing import List, Optional # pyflakes:ignore
1515

16-
from ietf.doc.utils import new_state_change_event, update_action_holders
16+
from ietf.doc.utils import update_action_holders
1717
from ietf.utils import log
1818
from ietf.utils.mail import send_mail
19-
from ietf.doc.models import Document, DocEvent, State, StateDocEvent
19+
from ietf.doc.models import Document, DocEvent, State
2020
from ietf.person.models import Person
2121
from ietf.meeting.models import Meeting
2222
from ietf.mailtrigger.utils import gather_address_lists
@@ -213,11 +213,11 @@ def splitext(fn):
213213

214214
def move_file_to(subdir):
215215
# Similar to move_draft_files_to_archive
216-
# ghostlinkd would keep this in the combined all archive since it would
217-
# be sourced from a different place. But when ghostlinkd is removed, nothing
218-
# new is needed here - the file will already exist in the combined archive
219216
shutil.move(path,
220217
os.path.join(settings.INTERNET_DRAFT_ARCHIVE_DIR, subdir, basename))
218+
mark = Path(settings.FTP_DIR) / "internet-drafts" / basename
219+
if mark.exists():
220+
mark.unlink()
221221

222222
try:
223223
doc = Document.objects.get(name=filename, rev=revision)
@@ -235,41 +235,3 @@ def move_file_to(subdir):
235235
# All uses of this past 2014 seem related to major system failures.
236236
move_file_to("unknown_ids")
237237

238-
239-
def repair_dead_on_expire():
240-
by = Person.objects.get(name="(System)")
241-
id_exists = State.objects.get(type="draft-iesg", slug="idexists")
242-
dead = State.objects.get(type="draft-iesg", slug="dead")
243-
dead_drafts = Document.objects.filter(
244-
states__type="draft-iesg", states__slug="dead", type_id="draft"
245-
)
246-
for d in dead_drafts:
247-
dead_event = d.latest_event(
248-
StateDocEvent, state_type="draft-iesg", state__slug="dead"
249-
)
250-
if dead_event is not None:
251-
if d.docevent_set.filter(type="expired_document").exists():
252-
closest_expiry = min(
253-
[
254-
abs(e.time - dead_event.time)
255-
for e in d.docevent_set.filter(type="expired_document")
256-
]
257-
)
258-
if closest_expiry.total_seconds() < 60:
259-
d.set_state(id_exists)
260-
events = []
261-
e = DocEvent(
262-
doc=d,
263-
rev=d.rev,
264-
type="added_comment",
265-
by=by,
266-
desc="IESG Dead state was set due only to document expiry - changing IESG state to ID-Exists",
267-
)
268-
e.skip_community_list_notification = True
269-
e.save()
270-
events.append(e)
271-
e = new_state_change_event(d, by, dead, id_exists)
272-
e.skip_community_list_notification = True
273-
e.save()
274-
events.append(e)
275-
d.save_with_history(events)

ietf/doc/tasks.py

-6
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,6 @@
1818
in_draft_expire_freeze,
1919
get_expired_drafts,
2020
expirable_drafts,
21-
repair_dead_on_expire,
2221
send_expire_notice_for_draft,
2322
expire_draft,
2423
clean_up_draft_files,
@@ -62,11 +61,6 @@ def expire_ids_task():
6261
raise
6362

6463

65-
@shared_task
66-
def repair_dead_on_expire_task():
67-
repair_dead_on_expire()
68-
69-
7064
@shared_task
7165
def notify_expirations_task(notify_days=14):
7266
for doc in get_soon_to_expire_drafts(notify_days):

ietf/doc/tests_conflict_review.py

+11-3
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@
44

55
import io
66
import os
7+
from pathlib import Path
78

89
from pyquery import PyQuery
910
from textwrap import wrap
@@ -387,7 +388,7 @@ def setUp(self):
387388

388389

389390
class ConflictReviewSubmitTests(TestCase):
390-
settings_temp_path_overrides = TestCase.settings_temp_path_overrides + ['CONFLICT_REVIEW_PATH']
391+
settings_temp_path_overrides = TestCase.settings_temp_path_overrides + ['CONFLICT_REVIEW_PATH','FTP_PATH']
391392
def test_initial_submission(self):
392393
doc = Document.objects.get(name='conflict-review-imaginary-irtf-submission')
393394
url = urlreverse('ietf.doc.views_conflict_review.submit',kwargs=dict(name=doc.name))
@@ -403,16 +404,23 @@ def test_initial_submission(self):
403404
# Right now, nothing to test - we let people put whatever the web browser will let them put into that textbox
404405

405406
# sane post using textbox
406-
path = os.path.join(settings.CONFLICT_REVIEW_PATH, '%s-%s.txt' % (doc.name, doc.rev))
407+
basename = f"{doc.name}-{doc.rev}.txt"
408+
path = Path(settings.CONFLICT_REVIEW_PATH) / basename
409+
ftp_dir = Path(settings.FTP_DIR) / "conflict-reviews"
410+
if not ftp_dir.exists():
411+
ftp_dir.mkdir()
412+
ftp_path = ftp_dir / basename
407413
self.assertEqual(doc.rev,'00')
408-
self.assertFalse(os.path.exists(path))
414+
self.assertFalse(path.exists())
415+
self.assertFalse(ftp_path.exists())
409416
r = self.client.post(url,dict(content="Some initial review text\n",submit_response="1"))
410417
self.assertEqual(r.status_code,302)
411418
doc = Document.objects.get(name='conflict-review-imaginary-irtf-submission')
412419
self.assertEqual(doc.rev,'00')
413420
with io.open(path) as f:
414421
self.assertEqual(f.read(),"Some initial review text\n")
415422
f.close()
423+
self.assertTrue(ftp_path.exists())
416424
self.assertTrue( "submission-00" in doc.latest_event(NewRevisionDocEvent).desc)
417425

418426
def test_subsequent_submission(self):

0 commit comments

Comments
 (0)