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 issues caused by differences between redis and elasticache (PP-1693) #2045

Merged
merged 5 commits into from
Sep 11, 2024

Conversation

jonathangreen
Copy link
Member

Description

Resolves issues surfaced on Minotaur when running against ElastiCache instead of Redis. These issues were around the escaping of characters in object key names. This seems to be handled differently in Redis vs Elasticache. In order to work around this, I ended up creating a scheme where we escaping the problematic characters.

I don't like this code, or that we are depending on behaviour that is hard to test on CI, but it does fix the issue. If this continues to be an issue, we may either have to rewrite the MARC redis model, so that it doesn't depend on JSON or try to figure out how we can test directly with ElastiCache in CI.

Motivation and Context

Fix issues that surfaced after deployment to Minotaur.

How Has This Been Tested?

  • Tested against ElastiCache and Redis locally
  • Full test with minotaur DB and ElastiCache to make sure we generate marc files

Checklist

  • I have updated the documentation accordingly.
  • All new and existing tests passed.

Copy link

codecov bot commented Sep 10, 2024

Codecov Report

Attention: Patch coverage is 98.63014% with 1 line in your changes missing coverage. Please review.

Project coverage is 90.78%. Comparing base (b136123) to head (d4096e8).
Report is 6 commits behind head on main.

Files with missing lines Patch % Lines
src/palace/manager/service/redis/models/marc.py 94.11% 0 Missing and 1 partial ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##             main    #2045      +/-   ##
==========================================
+ Coverage   90.77%   90.78%   +0.01%     
==========================================
  Files         342      343       +1     
  Lines       40513    40563      +50     
  Branches     8770     8788      +18     
==========================================
+ Hits        36774    36824      +50     
  Misses       2484     2484              
  Partials     1255     1255              

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

@jonathangreen jonathangreen added the bug Something isn't working label Sep 10, 2024
@jonathangreen jonathangreen requested review from a team and removed request for a team September 10, 2024 14:20
@jonathangreen jonathangreen requested a review from a team September 10, 2024 15:42
)
)
Copy link
Member Author

Choose a reason for hiding this comment

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

The changes in src/palace/manager/celery/tasks/marc.py could come in as a separate PR if desired. They fix a concurrency issue I found while doing other testing. Occasionally, since we were re-queuing while holding the lock, another worker would pick up the new task before this one had released the lock. So this updates the order of operations, so we release the lock before calling task.replace.

@jonathangreen jonathangreen requested review from a team and removed request for a team September 10, 2024 17:55
Copy link
Contributor

@tdilauro tdilauro left a comment

Choose a reason for hiding this comment

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

Looks great! 💣🚀

A couple of minor comments below.

This function validates that all the results of the pipeline are successful,
and not a ResponseError.

NOTE: The AWS ElastiCache implementation returns slightly different results then Redis.
Copy link
Contributor

Choose a reason for hiding this comment

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

Minor typo: "... [than] Redis."

Comment on lines 73 to 77
else:
if char == self._ESCAPE_CHAR:
in_escape = True
else:
unescaped.append(char)
Copy link
Contributor

Choose a reason for hiding this comment

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

Minor: If you aren't just aiming for a parallel structure for testing char, this could probably be de-indented to:

    if in_escape:
        ...
    elif char == self._ESCAPE_CHAR:
        in_escape = True
    else:
        unescaped.append(char)

self.mock_upload_key_3 = "test3"
# Some keys with special characters to make sure they are handled correctly.
self.mock_upload_key_1 = "test/test1/?$xyz.abc"
self.mock_upload_key_2 = "t'est💣/tëst2.\"ext`"
Copy link
Contributor

Choose a reason for hiding this comment

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

Love the 💣 here! 🤣

@jonathangreen jonathangreen merged commit 6ce1287 into main Sep 11, 2024
20 checks passed
@jonathangreen jonathangreen deleted the bugfix/marc-integration branch September 11, 2024 12:52
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
None yet
Development

Successfully merging this pull request may close these issues.

2 participants