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(non_root-migrations): add env var to indicate schema generation step should be skipped inside non_root-image #9548

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions docker/Dockerfile.non_root
Original file line number Diff line number Diff line change
Expand Up @@ -83,6 +83,11 @@ RUN chmod +x docker/prod_entrypoint.sh
USER nobody

RUN prisma generate

# Set the environment variable to skip Prisma generate in the future
# This is necessary because the migration script will try to run Prisma generate again otherwise
ENV LITELLM_MIGRATION_SKIP_PRISMA_GENERATE=true

### End of Prisma Handling for Non-Root #########################################

EXPOSE 4000/tcp
Expand Down
25 changes: 16 additions & 9 deletions litellm/proxy/prisma_migration.py
Original file line number Diff line number Diff line change
Expand Up @@ -60,15 +60,22 @@
retry_count += 1
verbose_proxy_logger.info(f"Attempt {retry_count}...")

# run prisma generate
verbose_proxy_logger.info("Running 'prisma generate'...")
result = subprocess.run(["prisma", "generate"], capture_output=True, text=True)
verbose_proxy_logger.info(f"'prisma generate' stdout: {result.stdout}") # Log stdout
exit_code = result.returncode

if exit_code != 0:
verbose_proxy_logger.info(f"'prisma generate' failed with exit code {exit_code}.")
verbose_proxy_logger.error(f"'prisma generate' stderr: {result.stderr}") # Log stderr
# Run the Prisma generate command
skip_prisma_generate = os.getenv("LITELLM_MIGRATION_SKIP_PRISMA_GENERATE", "false")
if skip_prisma_generate.lower() == "true":
verbose_proxy_logger.info(
"Skipping 'prisma generate' because LITELLM_MIGRATION_SKIP_PRISMA_GENERATE is set to true."
)
else:
verbose_proxy_logger.info("Running 'prisma generate'...")
result = subprocess.run(["prisma", "generate"], capture_output=True, text=True)
verbose_proxy_logger.info(f"'prisma generate' stdout: {result.stdout}") # Log stdout
exit_code = result.returncode

if exit_code != 0:
verbose_proxy_logger.info(f"'prisma generate' failed with exit code {exit_code}.")
verbose_proxy_logger.error(f"'prisma generate' stderr: {result.stderr}") # Log stderr
continue # Skip to the next iteration to retry

# Run the Prisma db push command
verbose_proxy_logger.info("Running 'prisma db push --accept-data-loss'...")
Expand Down
Loading