fix: Update time handling to use TimeUtil for current time retrieval#1199
Merged
alfredyu-cienet merged 1 commit intoGoogleCloudPlatform:masterfrom Mar 2, 2026
Conversation
This change standardizes all time-related operations to use the custom `TimeUtil` utility class and ensures all task sensors use the poke mode for consistency. Problem: The codebase had inconsistent time handling — some places used Python's built-in `datetime.datetime.now()` while others used `TimeUtil`. This made the code harder to maintain and potentially introduced timezone inconsistencies. Additionally, the new uptime validation sensors were using `mode="reschedule"` instead of the team's standard `mode="poke"`.
alfredyu-cienet
approved these changes
Mar 2, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Description
This PR standardizes all time-related operations to use the custom
TimeUtilutility class and ensures all task sensors use the poke mode for consistency.Problem: The codebase had inconsistent time handling — some places used Python's built-in
datetime.datetime.now()while others usedTimeUtil. This made the code harder to maintain and potentially introduced timezone inconsistencies. Additionally, the new uptime validation sensors were usingmode="reschedule"instead of the team's standardmode="poke".Technical Implementation
TimeUtilwithnow()method:TimeUtil.now()class method that returns the current UTC time as aTimeUtilinstancejobset_util.py:import datetimemodule, replaced with directfrom datetime import timedeltadatetime.datetime.now()calls toTimeUtil.now()query_time_seriestolist_time_series(the parameters being passed matchedlist_time_seriessignature, notquery_time_serieswait_for_jobset_uptime_datafrommode="reschedule"tomode="poke"ensure_no_jobset_uptime_datafrommode="reschedule"tomode="poke"jobset_uptime_validation.py:get_current_time()task to useTimeUtil.now()directlyTest
Checklist
Before submitting this PR, please make sure (put X in square brackets):