- 
                Notifications
    You must be signed in to change notification settings 
- Fork 8.5k
Template: Fix faulty CORS headers handling. #12424
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
base: main
Are you sure you want to change the base?
Conversation
| Hi @elizabeth-dev. Thanks for your PR. I'm waiting for a kubernetes member to verify that this patch is reasonable to test. If it is, they should reply with  Once the patch is verified, the new status will be reflected by the  I understand the commands that are listed here. Instructions for interacting with me using PR comments are available here. If you have questions or suggestions related to my behavior, please file an issue against the kubernetes-sigs/prow repository. | 
| ✅ Deploy Preview for kubernetes-ingress-nginx canceled.
 | 
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'd not call it a fix if we need to introduce NJS for it. We also already have a different PR for introducing NJS but as this needs a working NGINX base image build, we first need to fix this, introduce NJS and then can rebase this PR on top.
| @Gacko in that case we can prioritize and merge the NJS PR first, and then add this on top of it as just a fix | 
| Yes, makes sense! Sadly we can first release it in v1.13. Also I wouldn't word it as a fix then. Does this make sense? | 
| @Gacko hmm, not sure if I understand. you wouldn't tag the other PR (adding NJS + some migrations) as a fix, I agree with that, but once that is merged whenever, we can put this change on top, then it'd just be the scripting part, and that would pass as "just a fix" for me, since no new modules would be added and the logic would stay the same (but working as expected) or do you prefer to pass both changes as new features? | 
| Hm, yeah, you're right. We can consider this a fix. It's just a bit complex as we are also changing the whole framework the implementation is based on. | 
| well, that's settled then. we'll see if we can fix the build issues soon /hold | 
c291656    to
    49ab05e      
    Compare
  
    0ce9f18    to
    d0aec06      
    Compare
  
    d0aec06    to
    d18e357      
    Compare
  
    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.
/triage accepted
/kind bug
/priority backlog
/hold
Sadly we cannot back-port this as it requires the NGINX NJS module in the NGINX base image. Therefore I'll first build and promote a new NGINX base image including NJS, include it on main and LGTM this PR afterwards.
| [APPROVALNOTIFIER] This PR is APPROVED This pull-request has been approved by: elizabeth-dev, Gacko The full list of commands accepted by this bot can be found here. The pull request process is described here 
Needs approval from an approver in each of these files:
 
 Approvers can indicate their approval by writing  | 
e8cfd6d    to
    4739a6b      
    Compare
  
    | @elizabeth-dev We added NJS to the NGINX base image and included it on  | 
| /uncc | 
| /uncc | 
| I recently ran into this issue and decided to see if I can help unstuck this PR. The logs from the CI run are old and expired, but running locally I see the same error as mentioned in #13135. A comment there mentions that the move to NJS was dropped, which I think obsoletes the approach taken in this PR? That got me wondering why JS is used here instead of  | 
c81f6d7    to
    1fe7fe4      
    Compare
  
    
What this PR does / why we need it:
CORS headers handling implementation has been producing inconsistent results for a bit due to the unusual way Nginx handles
ifdirectives (essentially, they are to includereturnandrewritedirectives only inside them). This change recreates the exact same logic we were trying to apply whe handling CORS, but using NJS scripting.This also includes the NJS module into our custom build of Nginx, since it was going to be necessary for #12383 anyway.
Types of changes
Which issue/s this PR fixes
fixes #10267
How Has This Been Tested?
Test cases including multiple origin, headers, and methods have been run using curl, in order to ensure all the different CORS headers behave accordingly to the different annotation values we allow. This also included the specific configuration a user reported failing in the linked issue.
Additionally, most of the CORS e2e test suite has been revised and improved, relying more on actually checking the result of HTTP requests rather than just checking the contents of the nginx.conf file.
Checklist: