From 629ea43e9c361d2a2bed28bf093addd849029374 Mon Sep 17 00:00:00 2001 From: Mattia Rizzolo Date: Mon, 19 Oct 2015 09:35:36 +0000 Subject: reproducible: save the schedule message in the db and show it in the "test history" table --- bin/reproducible_build.sh | 7 ++++--- bin/reproducible_common.py | 5 +++-- bin/reproducible_db_maintenance.py | 4 ++++ bin/reproducible_html_packages.py | 2 +- bin/reproducible_remote_scheduler.py | 8 +++++--- 5 files changed, 17 insertions(+), 9 deletions(-) (limited to 'bin') diff --git a/bin/reproducible_build.sh b/bin/reproducible_build.sh index 87dda59a..ce471cc1 100755 --- a/bin/reproducible_build.sh +++ b/bin/reproducible_build.sh @@ -121,8 +121,8 @@ update_db_and_html() { sqlite3 -init $INIT ${PACKAGES_DB} "REPLACE INTO results (package_id, version, status, build_date, build_duration, node1, node2, job) VALUES ('$SRCPKGID', '$VERSION', '$STATUS', '$DATE', '$DURATION', '$NODE1', '$NODE2', '$JOB')" || \ sqlite3 -init $INIT ${PACKAGES_DB} "REPLACE INTO results (package_id, version, status, build_date, build_duration, node1, node2, job) VALUES ('$SRCPKGID', '$VERSION', '$STATUS', '$DATE', '$DURATION', '$NODE1', '$NODE2', '$JOB')" if [ ! -z "$DURATION" ] ; then # this happens when not 404 and not_for_us - sqlite3 -init $INIT ${PACKAGES_DB} "INSERT INTO stats_build (name, version, suite, architecture, status, build_date, build_duration, node1, node2, job) VALUES ('$SRCPACKAGE', '$VERSION', '$SUITE', '$ARCH', '$STATUS', '$DATE', '$DURATION', '$NODE1', '$NODE2', '$JOB')" || \ - sqlite3 -init $INIT ${PACKAGES_DB} "INSERT INTO stats_build (name, version, suite, architecture, status, build_date, build_duration, node1, node2, job) VALUES ('$SRCPACKAGE', '$VERSION', '$SUITE', '$ARCH', '$STATUS', '$DATE', '$DURATION', '$NODE1', '$NODE2', '$JOB')" + sqlite3 -init $INIT ${PACKAGES_DB} "INSERT INTO stats_build (name, version, suite, architecture, status, build_date, build_duration, node1, node2, job, schedule_message) VALUES ('$SRCPACKAGE', '$VERSION', '$SUITE', '$ARCH', '$STATUS', '$DATE', '$DURATION', '$NODE1', '$NODE2', '$JOB', '$SCHEDULE_MESSAGE')" || \ + sqlite3 -init $INIT ${PACKAGES_DB} "INSERT INTO stats_build (name, version, suite, architecture, status, build_date, build_duration, node1, node2, job, schedule_message) VALUES ('$SRCPACKAGE', '$VERSION', '$SUITE', '$ARCH', '$STATUS', '$DATE', '$DURATION', '$NODE1', '$NODE2', '$JOB', '$SCHEDULE_MESSAGE')" fi # unmark build since it's properly finished sqlite3 -init $INIT ${PACKAGES_DB} "DELETE FROM schedule WHERE package_id='$SRCPKGID';" || \ @@ -401,7 +401,7 @@ call_diffoscope_on_changes_files() { choose_package() { local RESULT=$(sqlite3 -init $INIT ${PACKAGES_DB} " - SELECT s.suite, s.id, s.name, sch.date_scheduled, sch.save_artifacts, sch.notify, s.notify_maintainer + SELECT s.suite, s.id, s.name, sch.date_scheduled, sch.save_artifacts, sch.notify, s.notify_maintainer, sch.message FROM schedule AS sch JOIN sources AS s ON sch.package_id=s.id WHERE sch.date_build_started='' AND s.architecture='$ARCH' @@ -417,6 +417,7 @@ choose_package() { SAVE_ARTIFACTS=$(echo $RESULT|cut -d "|" -f5) NOTIFY=$(echo $RESULT|cut -d "|" -f6) NOTIFY_MAINTAINER=$(echo $RESULT|cut -d "|" -f7) + SCHEDULE_MESSAGE=$(echo $RESULT|cut -d "|" -f8) # remove previous build attempts which didnt finish correctly: BUILDER_PREFIX="${JOB_NAME#reproducible_builder_}/" BAD_BUILDS=$(mktemp --tmpdir=$TMPDIR) diff --git a/bin/reproducible_common.py b/bin/reproducible_common.py index c3a64299..47dc4fe9 100755 --- a/bin/reproducible_common.py +++ b/bin/reproducible_common.py @@ -734,10 +734,11 @@ class Package: def _load_history(self): keys = ['build ID', 'version', 'suite', 'architecture', 'result', - 'build date', 'build duration', 'node1', 'node2', 'job'] + 'build date', 'build duration', 'node1', 'node2', 'job', + 'schedule message'] query = """ SELECT id, version, suite, architecture, status, build_date, - build_duration, node1, node2, job + build_duration, node1, node2, job, schedule_message FROM stats_build WHERE name='{}' ORDER BY build_date DESC """.format(self.name) results = query_db(query) diff --git a/bin/reproducible_db_maintenance.py b/bin/reproducible_db_maintenance.py index 9bed6591..3eb87192 100755 --- a/bin/reproducible_db_maintenance.py +++ b/bin/reproducible_db_maintenance.py @@ -546,6 +546,10 @@ schema_updates = { 'DROP TABLE schedule', 'ALTER TABLE schedule_tmp RENAME TO schedule', 'INSERT INTO rb_schema VALUES ("25", "' + now + '")'], + 26: [ # add a column to the schedule table to save the schedule message + 'ALTER TABLE schedule ADD COLUMN message TEXT', + 'ALTER TABLE stats_build ADD COLUMN schedule_message TEXT NOT NULL DEFAULT ""', + 'INSERT INTO rb_schema VALUES ("26", "' + now + '")'], } diff --git a/bin/reproducible_html_packages.py b/bin/reproducible_html_packages.py index ee35072c..52aca925 100755 --- a/bin/reproducible_html_packages.py +++ b/bin/reproducible_html_packages.py @@ -211,7 +211,7 @@ def gen_suites_links(package, current_suite, current_arch): def gen_history_page(package): keys = ('build date', 'version', 'suite', 'architecture', 'result', - 'build duration', 'node1', 'node2', 'job') + 'build duration', 'node1', 'node2', 'job', 'schedule message') try: head = package.history[0] except IndexError: diff --git a/bin/reproducible_remote_scheduler.py b/bin/reproducible_remote_scheduler.py index 39befb23..4181ac5f 100755 --- a/bin/reproducible_remote_scheduler.py +++ b/bin/reproducible_remote_scheduler.py @@ -235,14 +235,16 @@ save_schedule = [] notify = 1 if notify else 0 notify = 2 if notify_on_start else 0 artifacts_value = 1 if artifacts else 0 +reason = reason if reason else None for id in ids: - to_schedule.append((id, date, artifacts_value, str(notify), requester)) + to_schedule.append((id, date, artifacts_value, str(notify), requester, + reason)) save_schedule.append((id, requester, epoch)) log.debug('Packages about to be scheduled: ' + str(to_schedule)) query1 = '''REPLACE INTO schedule - (package_id, date_scheduled, save_artifacts, notify, scheduler) - VALUES (?, ?, ?, ?, ?)''' + (package_id, date_scheduled, save_artifacts, notify, scheduler, message) + VALUES (?, ?, ?, ?, ?, ?)''' query2 = '''INSERT INTO manual_scheduler (package_id, requester, date_request) VALUES (?, ?, ?)''' -- cgit v1.2.3-70-g09d2