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(lib.cache): apply fallback cache fix, fix tests #656

Merged
merged 2 commits into from
Dec 2, 2024

Conversation

BrennanPaciorek
Copy link
Contributor

@BrennanPaciorek BrennanPaciorek commented Nov 25, 2024

Apply fix for Fallback cache premature file creation.

AAP-36305

@BrennanPaciorek BrennanPaciorek changed the title apply cache fix, fix tests Fix(lib.cache): apply fallback cache fix, fix tests Nov 25, 2024
@art-tapin art-tapin self-requested a review November 26, 2024 14:09
Copy link
Contributor

@art-tapin art-tapin left a comment

Choose a reason for hiding this comment

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

I can confirm they resolve the reported problem.

Testing Process:
I tested both the current devel branch (which exhibits the issue) and your fix branch, following these steps:

Pre-requisites Setup (Just In Case)

# 1. In aap-gateway project root, create services directory if doesn't exist
cd aap-gateway
mkdir -p services

# 2. Clone galaxy_ng repository
cd services
git clone https://github.com/ansible/galaxy_ng.git
cd ..

Phase 1: Test with DAB Devel Branch (Base Case)

OUTSIDE CONTAINER:

# 1. Stop existing services
cd aap-dev
make hub-server-down

# 2. Update Galaxy requirements (all three files)
cd ../services/galaxy_ng/requirements

# In requirements.insights.txt, requirements.common.txt, requirements.standalone.txt:
# Change Django version
Django>=4.2.16,<4.3.0

# Change DAB version to devel
django-ansible-base[jwt-consumer] @ git+https://github.com/ansible/django-ansible-base@devel

# 3. Rebuild Hub
cd ../  # back to galaxy_ng root
sudo LOCK_REQUIREMENTS=0 docker compose -f dev/compose/aap.yaml build --no-cache
cd ../../aap-dev
make hub-server-up

Phase 2: Test with the Fix Branch

OUTSIDE CONTAINER:

# 1. Stop services
cd aap-dev
make hub-server-down

# 2. Update Galaxy requirements files again
cd services/galaxy_ng/requirements

# In all three requirements files, change DAB line to the fork's branch
jango-ansible-base[jwt-consumer] @ git+https://github.com/BrennanPaciorek/django-ansible-base@fix/fallback-cache

# 3. Rebuild and start
cd ../
sudo LOCK_REQUIREMENTS=0 docker compose -f dev/compose/aap.yaml build --no-cache
cd ../../aap-dev
make hub-server-up

INSIDE CONTAINER:

# 1. Connect to container
sudo docker exec -it galaxy_ng-api-1 bash

# 2. Verify branch
pip show django-ansible-base

# 3. Test commands - these should now work differently
pulpcore-manager showmigrations
dynaconf list

Expected Results:

  • With devel branch: We should see the module-level import issue
  • With fix branch: Commands should work without the database connection error

Verification Results:

  1. With DAB devel branch:

    • showmigrations failed with the expected database connection error
    • dynaconf list showed minimal output
    • Version confirmed: 2024.11.26.0.dev38+ga65e8f7
  2. With your fix branch:

    • showmigrations works correctly, showing all migrations
    • dynaconf list shows full configuration
    • Version confirmed: 24.11.25.0.dev574+g6ae3759

Implementation Notes:
The fix properly addresses the root cause by moving the get_setting calls from module-level to class instance context, preventing premature settings access during import.

Testing Challenges:
I want to highlight some significant challenges in testing DAB changes:

  1. Setting up the test environment requires careful coordination between multiple components (Gateway, Hub, DAB)
  2. The current dependency management makes it non-trivial to test specific DAB versions:
    • Had to modify multiple requirements files (insights.txt, common.txt, standalone.txt)
    • Required Django version upgrade (to >=4.2.16) to work with current DAB devel
    • Complex container build process with multiple layers makes dependency injection challenging

Suggestions for Future:

  1. Consider improving the development setup to make testing DAB changes more straightforward
  2. Document the proper way to test DAB changes in the context of Hub/Gateway

Conclusion:
The fix works as intended and resolves the issue. However, the testing process revealed some areas where we could improve our development workflow, particularly around testing DAB changes in downstream components.

👍 for the fix itself.

@BrennanPaciorek
Copy link
Contributor Author

BrennanPaciorek commented Nov 28, 2024

Thank you for handling this @art-tapin.

Very thorough testing and reporting; can really see the legwork put into verifying this patch. I'll look into merging this Monday now that we've got some fix verification.

Thank you for discovering the root cause of the issue and creating the initial fix @jctanner.

@BrennanPaciorek BrennanPaciorek marked this pull request as ready for review November 29, 2024 23:51
@BrennanPaciorek BrennanPaciorek merged commit 9ad6942 into ansible:devel Dec 2, 2024
13 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants