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

pkg/timezone: add helper function to configure timezone for pod/containers #1775

Merged

Conversation

sohankunkerkar
Copy link
Member

This PR consolidates common functionality used by CRI-O and Podman in one central location. I aimed to keep this change more generic, considering that CRI-O and Podman have different ways for the file mounting and applying security labels.

Related to containers/podman#21063 (comment)

@sohankunkerkar
Copy link
Member Author

cc @saschagrunert

pkg/util/util.go Outdated Show resolved Hide resolved
pkg/util/util.go Outdated Show resolved Hide resolved
@rhatdan
Copy link
Member

rhatdan commented Dec 21, 2023

I agree lets not further polute util, create a new package.

@sohankunkerkar
Copy link
Member Author

Does it make sense to include this under pkg/timetype?

@rhatdan
Copy link
Member

rhatdan commented Dec 21, 2023

Perhaps if you rename the pkg to pkg/time

@haircommander
Copy link
Contributor

I would suggest pkg/timezone personally to make it abundantly clear what's happening

@sohankunkerkar sohankunkerkar changed the title pkg/util: add helper function to configure timezone for pod/containers pkg/time: add helper function to configure timezone for pod/containers Dec 21, 2023
@sohankunkerkar sohankunkerkar changed the title pkg/time: add helper function to configure timezone for pod/containers pkg/timezone: add helper function to configure timezone for pod/containers Dec 22, 2023
pkg/timezone/timezone_linux.go Show resolved Hide resolved
pkg/timezone/timezone_linux.go Outdated Show resolved Hide resolved

// ConfigureContainerTimeZone configure the time zone for a container.
// It returns the path of the created /etc/localtime file if needed.
func ConfigureContainerTimeZone(timezone, containerRunDir, mountPoint, etcPath, mountLabel, containerID string) (string, error) {
Copy link
Member

Choose a reason for hiding this comment

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

Can we add tests for it or make it testable?

Copy link
Member Author

Choose a reason for hiding this comment

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

Due to the nature of the ConfigureContainerTimeZone function, it's challenging to write unit tests without proper isolation or mocking of the system calls involved. Specifically, the unix.Unlinkat and unix.Symlinkat functions interact directly with the file system, which makes it difficult to predict their behavior in a controlled test environment.

@rhatdan
Copy link
Member

rhatdan commented Dec 22, 2023

LGTM
/approve

Copy link
Contributor

openshift-ci bot commented Dec 22, 2023

[APPROVALNOTIFIER] This PR is APPROVED

This pull-request has been approved by: rhatdan, sohankunkerkar

The full list of commands accepted by this bot can be found here.

The pull request process is described here

Needs approval from an approver in each of these files:

Approvers can indicate their approval by writing /approve in a comment
Approvers can cancel approval by writing /approve cancel in a comment

…ainers

This PR consolidates common functionality used by CRI-O and Podman
in one central location. I aimed to keep this change more generic,
considering that CRI-O and Podman have different ways for the file
mounting and applying security labels.

Signed-off-by: Sohan Kunkerkar <[email protected]>
@haircommander
Copy link
Contributor

LGTM, @saschagrunert WDYT?

@rhatdan
Copy link
Member

rhatdan commented Jan 3, 2024

/lgtm

@openshift-ci openshift-ci bot added the lgtm label Jan 3, 2024
@openshift-merge-bot openshift-merge-bot bot merged commit a1e8e8c into containers:main Jan 3, 2024
7 checks passed
@sohankunkerkar sohankunkerkar deleted the add-timezone-helper-fns branch January 3, 2024 16:17
@sohankunkerkar
Copy link
Member Author

@rhatdan is it possible to get a minor version release for this change?

@rhatdan
Copy link
Member

rhatdan commented Jan 4, 2024

podman 5.0 will be released in February. Rolling this through to a podman minor release is not likely.

@sohankunkerkar
Copy link
Member Author

@rhatdan Thanks for the information. Actually, we need this release for CRI-O. I attempted to vendor the main changes from c/common in CRI-O, but as soon as I did that, it somehow reverted the Podman version to v4.8.1.

openshift-merge-bot bot added a commit that referenced this pull request Feb 1, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

4 participants