Skip to content

Fix/partial condition complement#409

Merged
kyasbal merged 3 commits into
GoogleCloudPlatform:mainfrom
kyasbal:fix/partial-condition-complement
Dec 9, 2025
Merged

Fix/partial condition complement#409
kyasbal merged 3 commits into
GoogleCloudPlatform:mainfrom
kyasbal:fix/partial-condition-complement

Conversation

@kyasbal

@kyasbal kyasbal commented Dec 9, 2025

Copy link
Copy Markdown
Member

Some patch requests can omit its condition status and it was treated as Unknown condition and confusing with the explicit Unknown status

@kyasbal kyasbal added bug Something isn't working backend:parser labels Dec 9, 2025
@kyasbal

kyasbal commented Dec 9, 2025

Copy link
Copy Markdown
Member Author

/gemini review

@gemini-code-assist

Copy link
Copy Markdown
Contributor

Summary of Changes

Hello @kyasbal, I'm Gemini Code Assist1! I'm currently reviewing this pull request and will post my feedback shortly. In the meantime, here's a summary to help you and other reviewers quickly get up to speed!

This pull request addresses an ambiguity in how Kubernetes condition statuses are interpreted when they are partially provided in patch requests. Previously, an omitted status was treated as "Unknown," which could be misleading. The changes introduce a new state to represent "No Available Info" for such cases and implement a mechanism to intelligently complement missing condition details from historical data, leading to a more robust and accurate tracking of resource condition timelines.

Highlights

  • Accurate Partial Condition Handling: Introduced a new revision state, RevisionStateConditionNoAvailableInfo, to correctly distinguish between explicitly unknown conditions and conditions where the status is omitted in patch requests, preventing misinterpretation.
  • Condition Data Complementation: Implemented logic to automatically fill in missing Status, LastTransitionTime, Message, and Reason fields for partial condition updates by referencing historical condition states, ensuring a more complete and accurate history.
  • Improved Revision Time Calculation: Corrected a bug in the TimelineBuilder where revision time differences were incorrectly calculated using log indices. The system now uses ChangeTime directly for accurate time difference comparisons, ensuring proper sorting of revisions.
Using Gemini Code Assist

The full guide for Gemini Code Assist can be found on our documentation page, here are some quick tips.

Invoking Gemini

You can request assistance from Gemini at any point by creating a comment using either /gemini <command> or @gemini-code-assist <command>. Below is a summary of the supported commands on the current page.

Feature Command Description
Code Review /gemini review Performs a code review for the current pull request in its current state.
Pull Request Summary /gemini summary Provides a summary of the current pull request in its current state.
Comment @gemini-code-assist Responds in comments when explicitly tagged, both in pull request comments and review comments.
Help /gemini help Displays a list of available commands.

Customization

To customize Gemini Code Assist for GitHub experience, repository maintainers can create a configuration file and/or provide a custom code review style guide (such as PEP-8 for Python) by creating and adding files to a .gemini/ folder in the base of the repository. Detailed instructions can be found here.

Limitations & Feedback

Gemini Code Assist may make mistakes. Please leave feedback on any instances where its feedback is incorrect or counter productive. You can react with 👍 and 👎 on @gemini-code-assist comments. If you're interested in giving your feedback about your experience with Gemini Code Assist for Github and other Google products, sign up here.

You can also get AI-powered code generation, chat, as well as code reviews directly in the IDE at no cost with the Gemini Code Assist IDE Extension.

Footnotes

  1. Review the Privacy Notices, Generative AI Prohibited Use Policy, Terms of Service, and learn how to configure Gemini Code Assist in GitHub here. Gemini can make mistakes, so double check it and use code with caution.

@gemini-code-assist gemini-code-assist Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Code Review

The pull request introduces a valuable feature to complement partial Kubernetes condition status information in audit logs. This is achieved by memorizing past condition states and using them to fill in missing details when a new log entry omits certain fields. The changes involve modifying the conditionHistoryModifierTaskSetting to collect and utilize historical condition data during processing. The test cases have been updated and expanded to cover this new functionality, including scenarios with partial status information.

The code is generally well-structured and the new logic appears sound. One area for improvement is robust error handling when parsing timestamps.

Comment thread pkg/task/inspection/commonlogk8sauditv2/impl/condition_historymodifier_task.go Outdated

@gemini-code-assist gemini-code-assist Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Code Review

This pull request introduces a mechanism to handle partially specified Kubernetes conditions in patch requests by complementing missing information from historical data. The changes involve a two-pass approach: the first pass gathers all known condition states, and the second pass uses this information to fill in missing fields like status when they are omitted.

The implementation is solid, but I've identified a few areas for improvement:

  • A critical bug in the binary search logic for finding the last known condition state, which fails on exact time matches.
  • A high-severity issue where an error from time.Parse is ignored, potentially leading to incorrect behavior with malformed data.
  • A minor redundancy in a conditional check.

I've provided suggestions to address these points. Overall, this is a valuable fix that improves the robustness of condition history tracking.

Comment thread pkg/task/inspection/commonlogk8sauditv2/impl/condition_historymodifier_task.go Outdated
Comment thread pkg/task/inspection/commonlogk8sauditv2/impl/condition_historymodifier_task.go Outdated
@kyasbal kyasbal force-pushed the fix/partial-condition-complement branch from f253c2e to 5416a28 Compare December 9, 2025 08:13
@kyasbal kyasbal force-pushed the fix/partial-condition-complement branch from 5416a28 to a6c5861 Compare December 9, 2025 08:14
@kyasbal kyasbal marked this pull request as ready for review December 9, 2025 08:15

@RyuSA RyuSA left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

we already had conversations about the updates. LGTM.

@kyasbal kyasbal merged commit 0693a74 into GoogleCloudPlatform:main Dec 9, 2025
8 of 9 checks passed
@kyasbal kyasbal deleted the fix/partial-condition-complement branch December 9, 2025 08:53
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

backend:parser bug Something isn't working

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants