Skip to content
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

feat: Add codejail_service app for transition to containerized codejail #530

Merged
merged 10 commits into from
Jan 11, 2024

Conversation

timmc-edx
Copy link
Member

@timmc-edx timmc-edx commented Jan 9, 2024

Merge checklist:
Check off if complete or not applicable:

  • Version bumped
  • Changelog record added
  • Documentation updated (not only docstrings)
  • Fixup commits are squashed away
  • Unit tests added/updated
  • Manual testing instructions provided
  • Noted any: Concerns, dependencies, migration issues, deadlines, tickets

@timmc-edx timmc-edx marked this pull request as draft January 9, 2024 00:35
@timmc-edx timmc-edx force-pushed the timmc/codejail-service branch 2 times, most recently from 934e7ee to 449b6e1 Compare January 9, 2024 16:47
@timmc-edx timmc-edx force-pushed the timmc/codejail-service branch from 449b6e1 to ecc21eb Compare January 9, 2024 18:53
@timmc-edx timmc-edx marked this pull request as ready for review January 9, 2024 21:46
Copy link
Contributor

@rgraber rgraber left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Generally looks good, some small questions

jsonschema.validate(params, payload_schema)

complete_code = params['code'] # includes standard prolog
input_globals_dict = params.get('globals_dict') or {}
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Do we have to use or here because params.get('globals_dict', {}) will return None if None is the actual value of the key?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Oh, hmm. That was the idea, but looking again at safe_exec.py in edx-platform (and the calling code in ../capa_problem.py) I see that I had misread; globals_dict is not defaulted to None, and will always be a dictionary (because it's functionally a return argument, and is updated in-place).

I've also set the schema to disallow an explicit None for globals_dict, so this line can already be safely changed to params['globals_dict']. I'll make that change and I'll add globals_dict to the required-fields list in the schema.

# There's no good reason to have a chain of >2 services passing
# codejail requests along, so only allow execution here if we
# aren't going to pass it along to someone else.
if getattr(settings, 'ENABLE_CODEJAIL_REST_SERVICE', False):
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If we move this up a few lines we can avoid doing unnecessary work

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nice, will do.

I should probably also change it to log + return a 500 rather than throwing an exception.

@timmc-edx
Copy link
Member Author

Ready for re-review. I added a bunch of unit tests and made a few fixes (see individual commits), and have manually restested.

Copy link
Contributor

@rgraber rgraber left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

One nit, otherwise LGTM

Arguments:
user: User to authenticate as when calling view (None for unauthenticated)
exp_status: Assert that the response HTTP status code is this value
exp_body: Assert that the response body JSON is this value
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

missing a few arguments here

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks, fixed. And one of the lines was a lie, too.

- Move `files` kwarg to later in list to match usage
- Correct the `user` arg documentation (None does not mean unauthenticated)
- Update changelog date
@timmc-edx timmc-edx merged commit 3ca34a6 into main Jan 11, 2024
5 checks passed
@timmc-edx timmc-edx deleted the timmc/codejail-service branch January 11, 2024 21:19
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants