-
Notifications
You must be signed in to change notification settings - Fork 20
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[CERTTF-303] Introduce support for file attachments #250
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks for your contribution! I’ve left several suggestions to make it more clear
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I really love some of the improvements you made here, great work! I have a few comments below, let me know what you think.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is a welcome feature addition, thanks for working on this! See comments.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This looks reasonable to me. I haven't had a chance to try it end-to-end yet, but I know you did and we will also want to do it in staging as a final sanity check. However I had one other thing that I wanted to ask below about how we ensure the attachments are removed once they are uploaded?
I did see that you have an uploadDate timestamp on it to use for TTL. Would be nice if we could delete-on-use, but I'm ok with the TTL, but didn't see where it was getting set in the index data. Did I just miss it?
Update: Nevermind! I realized about 10 seconds after sending this that we were already using uploadDate as the TTL index, so this should be just fine.
If you are happy with your local testing, then I am ok with this, pending further testing in staging.
…tics - the new name is `attachments_status`, to avoid any confusion with the `attachments` field under each phase. - the `attachments_status` field only exists if the job has attachments (instead of having a value of "none" as before)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
One minor suggestion about a test for the secure_filter() update that you just made, otherwise looks good
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks for adding that! +1
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Also want to approve it since I don’t have questions that can be potential blockers. Good PR, well done c:
Description
This PR introduces functionality that allows a testflinger client (e.g. the testflinger CLI) to submit a job that includes attachments, with these attachments eventually finding their way into the testflinger agent.
Resolved issues
CERTTF-303
test_cmds
field; the configuration files can be attached instead.test_cmds
fieldprovisioning
orfirmware_update
phasesChanges
Server
Job
submission schema so thatattachments
fields are allowed undertest_data
, specifying which local files should be packed into an archive and submitted along with a job. For example:Such fields are also allowed under the provisioning and firmware update data but the current schema doesn't validate against them because too many arbitrary fields are used in these phases, depending on the use case. This validation issue is not relevant to this PR.
In the implementation of the endpoint for submitting a job, a new derived
attachments
status field is stored in the job data, taking the values:none
when there are no attachments to the jobwaiting
when there are attachments but the corresponding archive file hasn't been submitted yet andcomplete
when there are attachments and the corresponding archive file has been submittedOnly the values
none
orcomplete
allow a job to be removed from a queue.Introduce two endpoints for submitting and retrieving an archive file that contains the attachments for a specific job. The submission of an attachments archive sets the value of the
attachments
status field for the job tocomplete
.Move database-related code into a separate
database
module, so that the API implementation is database-agnostic. This has been partly realised: the database interactions that are relevant to this PR have been moved into reusable functions of thedatabase
module. If approved, this change can also be applied to the implementation of all API endpoints, eventually removing all references to MongoDB from the API implementation and making the database an injectable dependency into the app.CLI
The CLI checks if the job submission includes references to attachments in the provisioning, firmware and test phases and, if so, packs the attachments into an archive and follows the job submission with an additional attachments archive submission to the server (using the new endpoint described above)
Agent
The agent checks if the job submission is associated with attachments and, if so, retrieves the attachments archive from the server, unpacks it and optionally moves/renames the attachments. Note that all attachments are placed under an
attachments
folder in the agents "rundir". They are additionally separated into phase-related folders, e.g.attachments/test
for the attachments provided undertest_data
.Points for discussion
Documentation
Currently only inline documentation is provided. If the approach is approved the documentation will be extended under a separate issue/PR.
Tests