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 #1740: Handle OPTIONS in management API #1774

Merged
merged 6 commits into from
Aug 15, 2022
Merged

Fix #1740: Handle OPTIONS in management API #1774

merged 6 commits into from
Aug 15, 2022

Conversation

xyang16
Copy link
Collaborator

@xyang16 xyang16 commented Jul 28, 2022

Description

Please read our CONTRIBUTING.md prior to creating your first pull request.

Please include a summary of the feature or issue being fixed. Please also include relevant motivation and context. List any dependencies that are required for this change.

This is to fix #1740.

The cause is that the browser (tested Firefox, Chrome and Safari) was using OPTIONS to do a preflight check before PUT and DELETE request.

TS code currently doesn't handle OPTIONS for management API and will throw MethodNotAllowedException.

Fixes #1740

Type of change

Please delete options that are not relevant.

  • Bug fix (non-breaking change which fixes an issue)
  • Breaking change (fix or feature that would cause existing functionality to not work as expected)
  • New feature (non-breaking change which adds functionality)
  • This change requires a documentation update

Feature/Issue validation/testing

Please describe the Unit or Integration tests that you ran to verify your changes and relevant result summary. Provide instructions so it can be reproduced.
Please also list any relevant details for your test configuration.

  • Test A
    Logs for Test A

Before the fix the CORS DELETE / PUT requests failed with:

CORS Preflight Did Not Succeed

Screen Shot 2022-07-27 at 4 28 14 PM

After the fix the CORS requests succeeded.

Screen Shot 2022-07-27 at 4 28 30 PM

  • Test B
    Logs for Test B

Checklist:

  • Did you have fun?
  • Have you added tests that prove your fix is effective or that this feature works?
  • Has code been commented, particularly in hard-to-understand areas?
  • Have you made corresponding changes to the documentation?

@xyang16 xyang16 requested review from lxning and maaquib July 28, 2022 23:36
@xyang16 xyang16 self-assigned this Jul 28, 2022
@xyang16 xyang16 added the bug Something isn't working label Jul 28, 2022
@xyang16 xyang16 added this to the v0.6.1 milestone Jul 28, 2022
@codecov
Copy link

codecov bot commented Jul 28, 2022

Codecov Report

❗ No coverage uploaded for pull request base (master@358f97e). Click here to learn what that means.
The diff coverage is n/a.

@@            Coverage Diff            @@
##             master    #1774   +/-   ##
=========================================
  Coverage          ?   45.38%           
=========================================
  Files             ?       64           
  Lines             ?     2591           
  Branches          ?       60           
=========================================
  Hits              ?     1176           
  Misses            ?     1415           
  Partials          ?        0           

📣 We’re building smart automated test selection to slash your CI/CD build times. Learn more

Comment on lines +83 to +85
openApi.addPath("/models/{model_name}", getModelManagerPath(false));
openApi.addPath("/models/{model_name}/{model_version}", getModelManagerPath(true));
openApi.addPath("/models/{model_name}/{model_version}/set-default", getSetDefaultPath());
Copy link
Collaborator

Choose a reason for hiding this comment

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

listManagementApis can be applied here.

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

listManagementApis has 6 paths:

/
/models
/models/{model_name}
/models/{model_name}/{model_version}
/models/{model_name}/{model_version}/set-default
/api-description

Here because it's only listing for specific model, it has only 3 paths:

/models/{model_name}
/models/{model_name}/{model_version}
/models/{model_name}/{model_version}/set-default

Copy link
Collaborator

@maaquib maaquib left a comment

Choose a reason for hiding this comment

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

Please add a unit test case as well

@xyang16
Copy link
Collaborator Author

xyang16 commented Aug 10, 2022

Please add a unit test case as well

Hi Aaqib, I have added unit tests.

@xyang16 xyang16 merged commit a1a0031 into pytorch:master Aug 15, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
v0.6.1 lifecycle
Awaiting triage
Development

Successfully merging this pull request may close these issues.

CORS config not working
3 participants