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

fix: Added region and signature for S3 bucket #1928

Conversation

farhaanbukhsh
Copy link
Member

@farhaanbukhsh farhaanbukhsh commented Mar 24, 2023

For a region based bucket boto3 needs to know about region and signature which edx-ora2 doesn't know about.

TL;DR - Currently edx-ora2 doesn't pick up AWS region or aws signature version and because of that boto3 generates a faulty S3 URL. The boto3 documentation for s3 signature v4 also shows the boto3 client need to know the signature version.

JIRA: None

What changed?

  • Config to add AWS configuration for S3

When I was trying to upload the file in S3 bucket in the me-south-1 region, I kept on getting
image

The reason was boto3 client doesn't use S3_SIGNATURE=s3v4 and region value here in edx-ora2 while the same config was working properly on discussions.

Developer Checklist

Testing Instructions

  • None since it just adds configs

Reviewer Checklist

Collectively, these should be completed by reviewers of this PR:

  • I've done a visual code review
  • I've tested the new functionality

@farhaanbukhsh farhaanbukhsh requested a review from a team as a code owner March 24, 2023 07:13
@openedx-webhooks openedx-webhooks added the open-source-contribution PR author is not from Axim or 2U label Mar 24, 2023
@openedx-webhooks
Copy link

Thanks for the pull request, @farhaanbukhsh! Please note that it may take us up to several weeks or months to complete a review and merge your PR.

Feel free to add as much of the following information to the ticket as you can:

  • supporting documentation
  • Open edX discussion forum threads
  • timeline information ("this must be merged by XX date", and why that is)
  • partner information ("this is a course on edx.org")
  • any other information that can help Product understand the context for the PR

All technical communication about the code itself will be done via the GitHub pull request interface. As a reminder, our process documentation is here.

Please let us know once your PR is ready for our review and all tests are green.

@codecov
Copy link

codecov bot commented Mar 24, 2023

Codecov Report

Patch coverage: 100.00% and no project coverage change.

Comparison is base (20626e4) 94.98% compared to head (0318118) 94.98%.

Additional details and impacted files
@@           Coverage Diff           @@
##           master    #1928   +/-   ##
=======================================
  Coverage   94.98%   94.98%           
=======================================
  Files         154      154           
  Lines       17056    17058    +2     
  Branches     1611     1611           
=======================================
+ Hits        16201    16203    +2     
  Misses        641      641           
  Partials      214      214           
Flag Coverage Δ
unittests 94.98% <100.00%> (+<0.01%) ⬆️

Flags with carried forward coverage won't be shown. Click here to find out more.

Impacted Files Coverage Δ
openassessment/__init__.py 100.00% <100.00%> (ø)
openassessment/fileupload/backends/s3.py 100.00% <100.00%> (ø)

☔ View full report in Codecov by Sentry.
📢 Do you have feedback about the report comment? Let us know in this issue.

Copy link

@kaustavb12 kaustavb12 left a comment

Choose a reason for hiding this comment

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

👍

  • I tested this: Tested upload file to S3 works in sandbox
  • I read through the code
  • I checked for accessibility issues
  • Includes documentation
  • I made sure any change in configuration variables is reflected in the corresponding client's configuration-secure repository.

@itsjeyd
Copy link

itsjeyd commented Mar 28, 2023

Thanks @farhaanbukhsh and @kaustavb12!

Looks like this PR is ready for engineering review. I changed its status on the contributions board accordingly.

@itsjeyd
Copy link

itsjeyd commented Apr 5, 2023

Hi @mattcarter, if you could help get this PR lined up for engineering review by the Aurora team, that would be great!

@farhaanbukhsh
Copy link
Member Author

@mattcarter Gentle ping on the PR.

@itsjeyd
Copy link

itsjeyd commented Apr 26, 2023

label: core contributor

@github-actions github-actions bot added the core contributor PR author is a Core Contributor (who may or may not have write access to this repo). label Apr 26, 2023
@itsjeyd
Copy link

itsjeyd commented May 31, 2023

Hi @mattcarter, just checking in to see if you had a chance to line this PR up for engineering review by Aurora?

@Agrendalath
Copy link
Member

@farhaanbukhsh, we may also want to bump the version in openassessment/__init__.py and package.json.

@farhaanbukhsh
Copy link
Member Author

@farhaanbukhsh, we may also want to bump the version in openassessment/init.py and package.json.

Thank you for the review @Agrendalath will make the changes :)

@itsjeyd
Copy link

itsjeyd commented Jun 27, 2023

@farhaanbukhsh It looks like we'll be able to proceed with a CC review here soon (Slack ref). Could you please address @Agrendalath's comments in the coming days to get ready for that?

@itsjeyd itsjeyd added the waiting on author PR author needs to resolve review requests, answer questions, fix tests, etc. label Jun 27, 2023
@farhaanbukhsh farhaanbukhsh force-pushed the farhaan/bb-7224-fix-region-signature-based-url-upstream branch from 2310f09 to b4a0601 Compare June 28, 2023 09:08
@farhaanbukhsh
Copy link
Member Author

@itsjeyd @Agrendalath Thank you for the feedback, I have made the changes and pushed the commit, :) please have a look.

@itsjeyd itsjeyd added waiting for eng review PR is ready for review. Review and merge it, or suggest changes. and removed waiting on author PR author needs to resolve review requests, answer questions, fix tests, etc. labels Jun 28, 2023
Copy link
Member

@Agrendalath Agrendalath left a comment

Choose a reason for hiding this comment

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

The changes look good to me 👍🏻

@itsjeyd
Copy link

itsjeyd commented Jul 5, 2023

@pomegranited Following confirmation from the Aurora team (@mattcarter) that this PR could be merged after CC review I'm assigning this PR to you.

For additional context, a decision was made recently on how to use the assignee field in the context of OSPR management going forward -- see 1b in this section on the Open edX wiki.

Thanks for volunteering! 🙂

CC @mphilbrick211 @hurtstotouchfire @nedbat @farhaanbukhsh @Agrendalath

Copy link
Contributor

@pomegranited pomegranited left a comment

Choose a reason for hiding this comment

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

Thanks for this fix @farhaanbukhsh !

I left a few minor suggestions, but I've tested this in both scenarios below, and it works fine. So I'll approve when the nits are addressed.

  • uploading to bucket in us-east-1 with defaults left at None
  • uploading to bucket in us-east-2 with signature_version = "s3v4", region_name = "us-east-2"

openassessment/fileupload/backends/s3.py Outdated Show resolved Hide resolved
openassessment/fileupload/backends/s3.py Outdated Show resolved Hide resolved
@@ -1,4 +1,4 @@
"""
Initialization Information for Open Assessment Module
"""
__version__ = '5.0.4'
__version__ = '5.0.5'
Copy link
Contributor

Choose a reason for hiding this comment

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

nit: master is currently at '5.1.0', so:

Suggested change
__version__ = '5.0.5'
__version__ = '5.1.1'

package.json Outdated Show resolved Hide resolved
@itsjeyd itsjeyd added waiting on author PR author needs to resolve review requests, answer questions, fix tests, etc. and removed waiting for eng review PR is ready for review. Review and merge it, or suggest changes. labels Jul 11, 2023
@farhaanbukhsh farhaanbukhsh force-pushed the farhaan/bb-7224-fix-region-signature-based-url-upstream branch from b4a0601 to 9330bd3 Compare July 12, 2023 07:15
For a region based bucket boto3 needs to know about region
and signature which edx-ora2 doesn't know about.

Signed-off-by: Farhaan Bukhsh <[email protected]>
@farhaanbukhsh farhaanbukhsh force-pushed the farhaan/bb-7224-fix-region-signature-based-url-upstream branch from 9330bd3 to 0318118 Compare July 12, 2023 07:19
@farhaanbukhsh
Copy link
Member Author

@pomegranited I have updated the code with your suggestions. Thanks a lot for the review :)

@itsjeyd itsjeyd removed the waiting on author PR author needs to resolve review requests, answer questions, fix tests, etc. label Jul 12, 2023
Copy link
Contributor

@pomegranited pomegranited left a comment

Choose a reason for hiding this comment

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

👍 perfect, thank you @farhaanbukhsh !

Since I've got permission from Aurora to merge, I'll do that now, and tag a new release.

  • I tested this on my devstack:
    • left defaults at None, and tested file uploads to a bucket in us-east-1.
    • set signature_version = "s3v4", region_name = "us-east-2" and tested file uploads to a bucket in that region.
  • I read through the code
  • I checked for accessibility issues N/A
  • Includes documentation N/A

@pomegranited pomegranited merged commit 1c79dee into openedx:master Jul 12, 2023
6 checks passed
@openedx-webhooks
Copy link

@farhaanbukhsh 🎉 Your pull request was merged! Please take a moment to answer a two question survey so we can improve your experience in the future.

@pomegranited pomegranited deleted the farhaan/bb-7224-fix-region-signature-based-url-upstream branch July 12, 2023 07:37
BryanttV pushed a commit to eduNEXT/edx-ora2 that referenced this pull request Feb 6, 2024
For a region based bucket boto3 needs to know about region and signature which edx-ora2 doesn't know about.

Signed-off-by: Farhaan Bukhsh <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
core contributor PR author is a Core Contributor (who may or may not have write access to this repo). open-source-contribution PR author is not from Axim or 2U
Projects
Archived in project
Development

Successfully merging this pull request may close these issues.

6 participants