CMR-10393: Allow only one sqs client queue to subscribe to one collection for NRT (ingest) subscriptions#2216
CMR-10393: Allow only one sqs client queue to subscribe to one collection for NRT (ingest) subscriptions#2216
Conversation
| NOTE: The same SQS endpoint cannot be used for the same collection more than once. | ||
| For example if you, USER 1, create a subscriptioon with an SQS queue: SQS1 endpoint to filter UPDATE granule events from Collection 1, another user, USER 2, cannot create a new subscription with the same SQS1 queue endpoint to filter granules from Collection 1 again. | ||
| Ultimately, only ONE user can perform CRUD operations on the specific SQS endpoint used. | ||
|
|
There was a problem hiding this comment.
I hope this makes sense... please double check during your reviews if this is clear
Codecov ReportAttention: Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## master #2216 +/- ##
==========================================
+ Coverage 58.23% 58.25% +0.01%
==========================================
Files 1056 1056
Lines 71134 71185 +51
Branches 2063 2068 +5
==========================================
+ Hits 41428 41467 +39
- Misses 27780 27784 +4
- Partials 1926 1934 +8 ☔ View full report in Codecov by Sentry. |
| (let [curr-endpoint (:EndPoint subscription-concept)] | ||
| (if (and (= "ingest" (:Method subscription-concept)) | ||
| (or (some? (re-matches #"arn:aws:sqs:.*" curr-endpoint)) | ||
| (some? (re-matches #"http://localhost:9324.*" curr-endpoint)))) |
There was a problem hiding this comment.
Why are we matching this specific URL? I though the issue was only with SQS?
There was a problem hiding this comment.
this is the local dev SQS ARN (which doesn't start with arn:aws:sqs, but I still wanted to capture it and have it act like it was an sqs arn subscription concept endpoint)
There was a problem hiding this comment.
Not directed at this specific PR, but are there/do we need guards against localhost subscription URLs?
There was a problem hiding this comment.
can you explain further? You mean, do we need to distinguish between localhost URL and localhost SQS?
There was a problem hiding this comment.
or are you saying that we might not need line 104 because we don't care about distinguishing between local sqs and local http endpoint?
There was a problem hiding this comment.
Nah, like when someone sends in a subscription with url endpoint, do we block them/do we even need to block them from sending in a subscription that is for localhost (since that would point to our subscription processor). Again, not aimed directly at this PR, just occurred to me while looking at the localhost there
There was a problem hiding this comment.
ooo I see what you are saying. I think we could. It doesn't hurt to just limit them to non-local URLs for http endpoints
There was a problem hiding this comment.
updated with new blocker for this
| (or (some? (re-matches #"arn:aws:sqs:.*" curr-endpoint)) | ||
| (some? (re-matches #"http://localhost:9324.*" curr-endpoint)))) | ||
| (let [collection-concept-id (:CollectionConceptId subscription-concept) | ||
| cache-content (metadata-db2/get-subscription-cache-content context collection-concept-id)] |
There was a problem hiding this comment.
I am wondering why you created an API call into metadata-db, instead of just reading the cache directly?
Not asking you to change anything.
There was a problem hiding this comment.
the cache funcs are in the metadata-db app which is typically accessed from the transmit lib that acts like a middle-man. Which is why I created a metadata-db API
jceaser
left a comment
There was a problem hiding this comment.
I had very minor comments, must fix that one new line where the variable is below the let.
TylerHeald1
left a comment
There was a problem hiding this comment.
Just need to make sure the defconfig value is properly added to each environment
|
Yep. Just checked each env and it has the parameter with the correct env var |
Overview
What is the feature/fix?
Problem: The ingest (NRT) subscriptions has a bug where if User1 creates a subscription to Coll1 and then User2 creates a different subscription to the same Coll1 for the same queue, it will overwrite the first subscription in the backend SNS subscription filter for that queue.
What is the Solution?
Add a verify check to make sure this does not happen
What areas of the application does this impact?
Ingest subscription
Checklist