Skip to content

feat(BA-858): Set Docker container timezone using TZ env #3892

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

Open
wants to merge 1 commit into
base: main
Choose a base branch
from

Conversation

studioego
Copy link
Contributor

Set Docker container timezone using TZ env

  • configure Docker container timezone consistently across any Linux distributions & Mac hosts
  • implement platform-independent solution using environment variables (e.g. ENV TZ=Asia/Seoul )

Ref1: Synchronize timezone from host to container
https://forums.docker.com/t/synchronize-timezone-from-host-to-container/39116/1

resolves #2300 #3841

Checklist: (if applicable)

  • Milestone metadata specifying the target backport version
  • [V] Mention to the original issue
  • Installer updates including:
    • Fixtures for db schema changes
    • New mandatory config options
  • Update of end-to-end CLI integration tests in ai.backend.test
  • API server-client counterparts (e.g., manager API -> client SDK)
  • Test case(s) to:
    • Demonstrate the difference of before/after
    • Demonstrate the flow of abstract/conceptual models with a concrete implementation
  • Documentation
    • Contents in the docs directory
    • docstrings in public interfaces and type annotations

Set Docker container timezone using TZ env
 - configure Docker container timezone consistently across any Linux distributions & Mac hosts
 - implement platform-independent solution using environment variables (e.g. ENV TZ=Asia/Seoul )

Ref1: Synchronize timezone from host to container
https://forums.docker.com/t/synchronize-timezone-from-host-to-container/39116/1
@studioego studioego self-assigned this Mar 5, 2025
@Copilot Copilot AI review requested due to automatic review settings March 5, 2025 07:02
@github-actions github-actions bot added size:M 30~100 LoC comp:agent Related to Agent component effort:easy Need to understand only a specific region of codes (good first issue, easy). labels Mar 5, 2025
Copy link
Contributor

@Copilot Copilot AI left a comment

Choose a reason for hiding this comment

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

PR Overview

This PR implements a platform‐independent solution for setting the Docker container's timezone using the TZ environment variable. The changes include adding a new helper function to extract timezone information from the host's localtime file, and removing the bind mount configuration for /etc/localtime and /etc/timezone in the Docker agent.

Reviewed Changes

File Description
src/ai/backend/agent/agent.py Adds adjust_zoneinfo_string to derive timezone info and injects TZ
src/ai/backend/agent/docker/agent.py Removes bind mount logic for /etc/localtime and /etc/timezone

Copilot reviewed 3 out of 3 changed files in this pull request and generated 1 comment.

Comments suppressed due to low confidence (1)

src/ai/backend/agent/agent.py:209

  • [nitpick] Using a magic index value of -3 can be unclear. Recommend using a named constant or expanding the comment to clarify its purpose.
idx = -3  # /usr/share/zoneinfo.default/Asia/Seoul

except ValueError:
idx = -3 # /usr/share/zoneinfo.default/Asia/Seoul
else:
idx = parts.index("zoneinfo")
Copy link
Preview

Copilot AI Mar 5, 2025

Choose a reason for hiding this comment

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

On non-darwin platforms, if 'zoneinfo' is not present in host_path parts, this code will raise a ValueError. Consider adding error handling or an alternative fallback path.

Suggested change
idx = parts.index("zoneinfo")
try:
idx = parts.index("zoneinfo")
except ValueError:
raise ValueError("The 'zoneinfo' directory is not present in the provided host_path.")

Copilot uses AI. Check for mistakes.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
comp:agent Related to Agent component effort:easy Need to understand only a specific region of codes (good first issue, easy). size:M 30~100 LoC
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Let containers use the host timezone config
1 participant