Skip to content

Commit 9d924c5

Browse files
authored
Merge pull request #263 from trz42/use_result_files_for_deployment
use result files for deployment
2 parents 2d15e77 + 6beaa22 commit 9d924c5

8 files changed

Lines changed: 287 additions & 339 deletions

File tree

README.md

Lines changed: 18 additions & 53 deletions
Original file line numberDiff line numberDiff line change
@@ -175,7 +175,9 @@ You can exit the virtual environment simply by running `deactivate`.
175175

176176
### <a name="step4.1"></a>Step 4.1: Installing tools to access S3 bucket
177177

178-
The [`scripts/eessi-upload-to-staging`](https://github.com/EESSI/eessi-bot-software-layer/blob/main/scripts/eessi-upload-to-staging) script uploads a tarball and an associated metadata file to an S3 bucket.
178+
The
179+
[`scripts/eessi-upload-to-staging`](https://github.com/EESSI/eessi-bot-software-layer/blob/main/scripts/eessi-upload-to-staging)
180+
script uploads an artefact and an associated metadata file to an S3 bucket.
179181

180182
It needs two tools for this:
181183
* the `aws` command to actually upload the files;
@@ -444,14 +446,17 @@ information about the result of the command that was run (can be empty).
444446

445447
The `[deploycfg]` section defines settings for uploading built artefacts (tarballs).
446448
```
447-
tarball_upload_script = PATH_TO_EESSI_BOT/scripts/eessi-upload-to-staging
449+
artefact_upload_script = PATH_TO_EESSI_BOT/scripts/eessi-upload-to-staging
448450
```
449-
`tarball_upload_script` provides the location for the script used for uploading built software packages to an S3 bucket.
451+
`artefact_upload_script` provides the location for the script used for uploading built software packages to an S3 bucket.
450452

451453
```
452454
endpoint_url = URL_TO_S3_SERVER
453455
```
454-
`endpoint_url` provides an endpoint (URL) to a server hosting an S3 bucket. The server could be hosted by a commercial cloud provider like AWS or Azure, or running in a private environment, for example, using Minio. The bot uploads tarballs to the bucket which will be periodically scanned by the ingestion procedure at the Stratum 0 server.
456+
`endpoint_url` provides an endpoint (URL) to a server hosting an S3 bucket. The
457+
server could be hosted by a commercial cloud provider like AWS or Azure, or
458+
running in a private environment, for example, using Minio. The bot uploads
459+
artefacts to the bucket which will be periodically scanned by the ingestion procedure at the Stratum 0 server.
455460

456461

457462
```ini
@@ -466,7 +471,7 @@ bucket_name = {
466471
}
467472
```
468473

469-
`bucket_name` is the name of the bucket used for uploading of tarballs.
474+
`bucket_name` is the name of the bucket used for uploading of artefacts.
470475
The bucket must be available on the default server (`https://${bucket_name}.s3.amazonaws.com`), or the one provided via `endpoint_url`.
471476

472477
`bucket_name` can be specified as a string value to use the same bucket for all target repos, or it can be mapping from target repo id to bucket name.
@@ -481,7 +486,7 @@ The `upload_policy` defines what policy is used for uploading built artefacts to
481486
|`upload_policy` value|Policy|
482487
|:--------|:--------------------------------|
483488
|`all`|Upload all artefacts (mulitple uploads of the same artefact possible).|
484-
|`latest`|For each build target (prefix in tarball name `eessi-VERSION-{software,init,compat}-OS-ARCH)` only upload the latest built artefact.|
489+
|`latest`|For each build target (prefix in artefact name `eessi-VERSION-{software,init,compat}-OS-ARCH)` only upload the latest built artefact.|
485490
|`once`|Only once upload any built artefact for the build target.|
486491
|`none`|Do not upload any built artefacts.|
487492

@@ -496,30 +501,30 @@ deployment), or a space delimited list of GitHub accounts.
496501
no_deploy_permission_comment = Label `bot:deploy` has been set by user `{deploy_labeler}`, but this person does not have permission to trigger deployments
497502
```
498503
This defines a message that is added to the status table in a PR comment
499-
corresponding to a job whose tarball should have been uploaded (e.g., after
504+
corresponding to a job whose artefact should have been uploaded (e.g., after
500505
setting the `bot:deploy` label).
501506

502507

503508
```
504509
metadata_prefix = LOCATION_WHERE_METADATA_FILE_GETS_DEPOSITED
505-
tarball_prefix = LOCATION_WHERE_TARBALL_GETS_DEPOSITED
510+
artefact_prefix = LOCATION_WHERE_TARBALL_GETS_DEPOSITED
506511
```
507512

508513
These two settings are used to define where (which directory) in the S3 bucket
509-
(see `bucket_name` above) the metadata file and the tarball will be stored. The
514+
(see `bucket_name` above) the metadata file and the artefact will be stored. The
510515
value `LOCATION...` can be a string value to always use the same 'prefix'
511516
regardless of the target CVMFS repository, or can be a mapping of a target
512517
repository id (see also `repo_target_map` below) to a prefix.
513518

514519
The prefix itself can use some (environment) variables that are set within
515-
the upload script (see `tarball_upload_script` above). Currently those are:
520+
the upload script (see `artefact_upload_script` above). Currently those are:
516521
* `'${github_repository}'` (which would be expanded to the full name of the GitHub
517522
repository, e.g., `EESSI/software-layer`),
518523
* `'${legacy_aws_path}'` (which expands to the legacy/old prefix being used for
519-
storing tarballs/metadata files, the old prefix is
524+
storing artefacts/metadata files, the old prefix is
520525
`EESSI_VERSION/TARBALL_TYPE/OS_TYPE/CPU_ARCHITECTURE/TIMESTAMP/`), _and_
521526
* `'${pull_request_number}'` (which would be expanded to the number of the pull
522-
request from which the tarball originates).
527+
request from which the artefact originates).
523528
Note, it's important to single-quote (`'`) the variables as shown above, because
524529
they may likely not be defined when the bot calls the upload script.
525530

@@ -529,7 +534,7 @@ The list of supported variables can be shown by running
529534
**Examples:**
530535
```
531536
metadata_prefix = {"eessi.io-2023.06": "new/${github_repository}/${pull_request_number}"}
532-
tarball_prefix = {
537+
artefact_prefix = {
533538
"eessi-pilot-2023.06": "",
534539
"eessi.io-2023.06": "new/${github_repository}/${pull_request_number}"
535540
}
@@ -656,46 +661,6 @@ running_job = job `{job_id}` is running
656661
#### `[finished_job_comments]` section
657662

658663
The `[finished_job_comments]` section sets templates for messages about finished jobs.
659-
```
660-
success = :grin: SUCCESS tarball `{tarball_name}` ({tarball_size} GiB) in job dir
661-
```
662-
`success` specifies the message for a successful job that produced a tarball.
663-
664-
```
665-
failure = :cry: FAILURE
666-
```
667-
`failure` specifies the message for a failed job.
668-
669-
```
670-
no_slurm_out = No slurm output `{slurm_out}` in job dir
671-
```
672-
`no_slurm_out` specifies the message for missing Slurm output file.
673-
674-
```
675-
slurm_out = Found slurm output `{slurm_out}` in job dir
676-
```
677-
`slurm_out` specifies the message for found Slurm output file.
678-
679-
```
680-
missing_modules = Slurm output lacks message "No missing modules!".
681-
```
682-
`missing_modules` is used to signal the lack of a message that all modules were built.
683-
684-
```
685-
no_tarball_message = Slurm output lacks message about created tarball.
686-
```
687-
`no_tarball_message` is used to signal the lack of a message about a created tarball.
688-
689-
```
690-
no_matching_tarball = No tarball matching `{tarball_pattern}` found in job dir.
691-
```
692-
`no_matching_tarball` is used to signal a missing tarball.
693-
694-
```
695-
multiple_tarballs = Found {num_tarballs} tarballs in job dir - only 1 matching `{tarball_pattern}` expected.
696-
```
697-
`multiple_tarballs` is used to report that multiple tarballs have been found.
698-
699664
```
700665
job_result_unknown_fmt = <details><summary>:shrug: UNKNOWN _(click triangle for details)_</summary><ul><li>Job results file `{filename}` does not exist in job directory, or parsing it failed.</li><li>No artefacts were found/reported.</li></ul></details>
701666
```

app.cfg.example

Lines changed: 7 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -127,7 +127,7 @@ no_build_permission_comment = Label `bot:build` has been set by user `{build_lab
127127

128128
[deploycfg]
129129
# script for uploading built software packages
130-
tarball_upload_script = PATH_TO_EESSI_BOT/scripts/eessi-upload-to-staging
130+
artefact_upload_script = PATH_TO_EESSI_BOT/scripts/eessi-upload-to-staging
131131

132132
# URL to S3/minio bucket
133133
# if attribute is set, bucket_base will be constructed as follows
@@ -160,11 +160,11 @@ upload_policy = once
160160
# value can be a space delimited list of GH accounts
161161
deploy_permission =
162162

163-
# template for comment when user who set a label has no permission to trigger deploying tarballs
163+
# template for comment when user who set a label has no permission to trigger deploying artefacts
164164
no_deploy_permission_comment = Label `bot:deploy` has been set by user `{deploy_labeler}`, but this person does not have permission to trigger deployments
165165

166166
# settings for where (directory) in the S3 bucket to store the metadata file and
167-
# the tarball
167+
# the artefact
168168
# - Can be a string value to always use the same 'prefix' regardless of the target
169169
# CVMFS repository, or can be a mapping of a target repository id (see also
170170
# repo_target_map) to a prefix.
@@ -173,17 +173,17 @@ no_deploy_permission_comment = Label `bot:deploy` has been set by user `{deploy_
173173
# * 'github_repository' (which would be expanded to the full name of the GitHub
174174
# repository, e.g., 'EESSI/software-layer'),
175175
# * 'legacy_aws_path' (which expands to the legacy/old prefix being used for
176-
# storing tarballs/metadata files) and
176+
# storing artefacts/metadata files) and
177177
# * 'pull_request_number' (which would be expanded to the number of the pull
178-
# request from which the tarball originates).
178+
# request from which the artefact originates).
179179
# - The list of supported variables can be shown by running
180180
# `scripts/eessi-upload-to-staging --list-variables`.
181181
# - Examples:
182182
# metadata_prefix = {"eessi.io-2023.06": "new/${github_repository}/${pull_request_number}"}
183-
# tarball_prefix = {"eessi-pilot-2023.06": "", "eessi.io-2023.06": "new/${github_repository}/${pull_request_number}"}
183+
# artefact_prefix = {"eessi-pilot-2023.06": "", "eessi.io-2023.06": "new/${github_repository}/${pull_request_number}"}
184184
# If left empty, the old/legacy prefix is being used.
185185
metadata_prefix =
186-
tarball_prefix =
186+
artefact_prefix =
187187

188188

189189
[architecturetargets]
@@ -247,14 +247,6 @@ running_job = job `{job_id}` is running
247247

248248

249249
[finished_job_comments]
250-
success = :grin: SUCCESS tarball `{tarball_name}` ({tarball_size} GiB) in job dir
251-
failure = :cry: FAILURE
252-
no_slurm_out = No slurm output `{slurm_out}` in job dir
253-
slurm_out = Found slurm output `{slurm_out}` in job dir
254-
missing_modules = Slurm output lacks message "No missing modules!".
255-
no_tarball_message = Slurm output lacks message about created tarball.
256-
no_matching_tarball = No tarball matching `{tarball_pattern}` found in job dir.
257-
multiple_tarballs = Found {num_tarballs} tarballs in job dir - only 1 matching `{tarball_pattern}` expected.
258250
job_result_unknown_fmt = <details><summary>:shrug: UNKNOWN _(click triangle for detailed information)_</summary><ul><li>Job results file `{filename}` does not exist in job directory, or parsing it failed.</li><li>No artefacts were found/reported.</li></ul></details>
259251
job_test_unknown_fmt = <details><summary>:shrug: UNKNOWN _(click triangle for detailed information)_</summary><ul><li>Job test file `{filename}` does not exist in job directory, or parsing it failed.</li></ul></details>
260252

eessi_bot_job_manager.py

Lines changed: 19 additions & 57 deletions
Original file line numberDiff line numberDiff line change
@@ -43,35 +43,23 @@
4343

4444
# Local application imports (anything from EESSI/eessi-bot-software-layer)
4545
from connections import github
46-
from tools import config, run_cmd
46+
from tools import config, job_metadata, run_cmd
4747
from tools.args import job_manager_parse
48-
from tools.job_metadata import read_job_metadata_from_file, read_metadata_file
4948
from tools.pr_comments import get_submitted_job_comment, update_comment
5049

5150

5251
AWAITS_LAUNCH = "awaits_launch"
53-
FAILURE = "failure"
5452
FINISHED_JOB_COMMENTS = "finished_job_comments"
5553
JOB_RESULT_COMMENT_DESCRIPTION = "comment_description"
5654
JOB_RESULT_UNKNOWN_FMT = "job_result_unknown_fmt"
5755
JOB_TEST_COMMENT_DESCRIPTION = "comment_description"
5856
JOB_TEST_UNKNOWN_FMT = "job_test_unknown_fmt"
59-
MISSING_MODULES = "missing_modules"
60-
MULTIPLE_TARBALLS = "multiple_tarballs"
6157
NEW_JOB_COMMENTS = "new_job_comments"
62-
NO_MATCHING_TARBALL = "no_matching_tarball"
63-
NO_SLURM_OUT = "no_slurm_out"
64-
NO_TARBALL_MESSAGE = "no_tarball_message"
6558
RUNNING_JOB = "running_job"
6659
RUNNING_JOB_COMMENTS = "running_job_comments"
67-
SLURM_OUT = "slurm_out"
68-
SUCCESS = "success"
6960

7061
REQUIRED_CONFIG = {
71-
FINISHED_JOB_COMMENTS: [FAILURE, JOB_RESULT_UNKNOWN_FMT, MISSING_MODULES,
72-
MULTIPLE_TARBALLS, NO_MATCHING_TARBALL,
73-
NO_SLURM_OUT, NO_TARBALL_MESSAGE, SLURM_OUT,
74-
SUCCESS],
62+
FINISHED_JOB_COMMENTS: [JOB_RESULT_UNKNOWN_FMT, JOB_TEST_UNKNOWN_FMT],
7563
NEW_JOB_COMMENTS: [AWAITS_LAUNCH],
7664
RUNNING_JOB_COMMENTS: [RUNNING_JOB]
7765
}
@@ -254,42 +242,6 @@ def determine_finished_jobs(self, known_jobs, current_jobs):
254242

255243
return finished_jobs
256244

257-
def read_job_result(self, job_result_file_path):
258-
"""
259-
Read job result file and return the contents of the 'RESULT' section.
260-
261-
Args:
262-
job_result_file_path (string): path to job result file
263-
264-
Returns:
265-
(ConfigParser): instance of ConfigParser corresponding to the
266-
'RESULT' section or None
267-
"""
268-
# reuse function from module tools.job_metadata to read metadata file
269-
result = read_metadata_file(job_result_file_path, self.logfile)
270-
if result and "RESULT" in result:
271-
return result["RESULT"]
272-
else:
273-
return None
274-
275-
def read_job_test(self, job_test_file_path):
276-
"""
277-
Read job test file and return the contents of the 'TEST' section.
278-
279-
Args:
280-
job_test_file_path (string): path to job test file
281-
282-
Returns:
283-
(ConfigParser): instance of ConfigParser corresponding to the
284-
'TEST' section or None
285-
"""
286-
# reuse function from module tools.job_metadata to read metadata file
287-
test = read_metadata_file(job_test_file_path, self.logfile)
288-
if test and "TEST" in test:
289-
return test["TEST"]
290-
else:
291-
return None
292-
293245
def process_new_job(self, new_job):
294246
"""
295247
Process a new job by verifying that it is a bot job and if so
@@ -335,7 +287,9 @@ def process_new_job(self, new_job):
335287

336288
# assuming that a bot job's working directory contains a metadata
337289
# file, its existence is used to check if the job belongs to the bot
338-
metadata_pr = read_job_metadata_from_file(job_metadata_path, self.logfile)
290+
metadata_pr = job_metadata.get_section_from_file(job_metadata_path,
291+
job_metadata.JOB_PR_SECTION,
292+
self.logfile)
339293

340294
if metadata_pr is None:
341295
log(f"No metadata file found at {job_metadata_path} for job {job_id}, so skipping it",
@@ -431,7 +385,9 @@ def process_running_jobs(self, running_job):
431385
job_metadata_path = os.path.join(job_dir, metadata_file)
432386

433387
# check if metadata file exist
434-
metadata_pr = read_job_metadata_from_file(job_metadata_path, self.logfile)
388+
metadata_pr = job_metadata.get_section_from_file(job_metadata_path,
389+
job_metadata.JOB_PR_SECTION,
390+
self.logfile)
435391
if metadata_pr is None:
436392
raise Exception("Unable to find metadata file")
437393

@@ -525,11 +481,13 @@ def process_finished_job(self, finished_job):
525481
# check if _bot_jobJOBID.result exits
526482
job_result_file = f"_bot_job{job_id}.result"
527483
job_result_file_path = os.path.join(new_symlink, job_result_file)
528-
job_results = self.read_job_result(job_result_file_path)
484+
job_results = job_metadata.get_section_from_file(job_result_file_path,
485+
job_metadata.JOB_RESULT_SECTION,
486+
self.logfile)
529487

530488
job_result_unknown_fmt = finished_job_comments_cfg[JOB_RESULT_UNKNOWN_FMT]
531489
# set fallback comment_description in case no result file was found
532-
# (self.read_job_result returned None)
490+
# (job_metadata.get_section_from_file returned None)
533491
comment_description = job_result_unknown_fmt.format(filename=job_result_file)
534492
if job_results:
535493
# get preformatted comment_description or use previously set default for unknown
@@ -552,11 +510,13 @@ def process_finished_job(self, finished_job):
552510
# --> bot/test.sh and bot/check-test.sh scripts are run in job script used by bot for 'build' action
553511
job_test_file = f"_bot_job{job_id}.test"
554512
job_test_file_path = os.path.join(new_symlink, job_test_file)
555-
job_tests = self.read_job_test(job_test_file_path)
513+
job_tests = job_metadata.get_section_from_file(job_test_file_path,
514+
job_metadata.JOB_TEST_SECTION,
515+
self.logfile)
556516

557517
job_test_unknown_fmt = finished_job_comments_cfg[JOB_TEST_UNKNOWN_FMT]
558518
# set fallback comment_description in case no test file was found
559-
# (self.read_job_result returned None)
519+
# (job_metadata.get_section_from_file returned None)
560520
comment_description = job_test_unknown_fmt.format(filename=job_test_file)
561521
if job_tests:
562522
# get preformatted comment_description or use previously set default for unknown
@@ -576,7 +536,9 @@ def process_finished_job(self, finished_job):
576536
# obtain id of PR comment to be updated (from file '_bot_jobID.metadata')
577537
metadata_file = f"_bot_job{job_id}.metadata"
578538
job_metadata_path = os.path.join(new_symlink, metadata_file)
579-
metadata_pr = read_job_metadata_from_file(job_metadata_path, self.logfile)
539+
metadata_pr = job_metadata.get_section_from_file(job_metadata_path,
540+
job_metadata.JOB_PR_SECTION,
541+
self.logfile)
580542
if metadata_pr is None:
581543
raise Exception("Unable to find metadata file ... skip updating PR comment")
582544

0 commit comments

Comments
 (0)