Skip to content

fix: Condition "Unknown" was shown for the condition without containing the status body#408

Merged
kyasbal merged 3 commits into
GoogleCloudPlatform:mainfrom
kyasbal:fix/none-to-something-condition
Dec 9, 2025
Merged

fix: Condition "Unknown" was shown for the condition without containing the status body#408
kyasbal merged 3 commits into
GoogleCloudPlatform:mainfrom
kyasbal:fix/none-to-something-condition

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

…ng the status body

Some patch requests can omit its condition status but it was treated as Unknown condition and confusing with the explicit Unknown status
@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 issue where Kubernetes condition statuses, when omitted in patch requests, were incorrectly interpreted as 'Unknown'. The change introduces a distinct state for these cases, improving the accuracy of condition reporting and preventing confusion with explicitly set 'Unknown' statuses. The update includes modifications to the condition state conversion logic and comprehensive test coverage to ensure correct behavior.

Highlights

  • Condition Status Handling: Introduced a new RevisionStateConditionNoAvailableInfo enum value to accurately represent Kubernetes conditions where the status body is omitted, differentiating it from an explicit Unknown status.
  • Logic Update: Modified the conditionStateToRevisionState function to correctly map an empty condition status string to the new RevisionStateConditionNoAvailableInfo.
  • Test Enhancements: Refactored the test suite for condition history modification, introducing scenarios to thoroughly validate the new handling of omitted condition statuses and improve test organization.
  • Timeline Sorting Logic: Updated the TimelineBuilder to compare ChangeTime directly for sorting revisions, replacing a previous comparison based on log indices.
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.

@kyasbal kyasbal added the bug Something isn't working label Dec 9, 2025

@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 addresses a bug where a Kubernetes condition without a status field was incorrectly labeled as 'Unknown'. The fix introduces a new state, RevisionStateConditionNoAvailableInfo, for such cases, which is handled in the conditionStateToRevisionState function. The implementation is improved by converting an if-else chain to a switch statement for better readability. Additionally, the associated tests have been significantly refactored to use a scenario-based approach, which provides better testing for stateful logic, and a new test case has been added to cover the fix. A minor refactoring in timeline_builder.go improves consistency and efficiency. My feedback includes suggestions to improve the clarity of test case names for better maintainability.

kyasbal and others added 2 commits December 9, 2025 11:07
…modifier_task_test.go

Co-authored-by: gemini-code-assist[bot] <176961590+gemini-code-assist[bot]@users.noreply.github.com>
Signed-off-by: kyasbal <kyasbal1994@gmail.com>
…modifier_task_test.go

Co-authored-by: gemini-code-assist[bot] <176961590+gemini-code-assist[bot]@users.noreply.github.com>
Signed-off-by: kyasbal <kyasbal1994@gmail.com>
if len(timeline.Revisions) >= 2 {
prev := timeline.Revisions[len(timeline.Revisions)-2]
if b.timeDiffOfLogIndicces(revision.Log, prev.Log) < 0 {
if revision.ChangeTime.Sub(prev.ChangeTime) < 0 {

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.

Is this change related to the main concern of this PR?

@kyasbal kyasbal Dec 9, 2025

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

I could say that is another bug but this is affecting same issue. The implicit "Unknown" condition generated in the previous version will be overwritten by later resource update and there was a bug in this case.

For example,

# manifest reconstructed from PATCH request 1 @ 2025-01-02T00:00:00Z
status:
  conditions:
    - type: Ready
      lastHeartbeatTime: "2025-01-02T00:00:00Z"
# manifest reconstructed from UPDATE request 2 @ 2025-01-03T00:00:00Z
metadata:
  creationTimestamp: "2025-01-01T00:00:00Z"
...(omit)
status:
  conditions:
    - type: Read
      status: "True"
      lastHeartbeatTime: "2025-01-03T00:00:00Z"

Then these creates following conditions revisions:

  • At 2025-01-01T00:00:00Z: No enough information to determine the condition but we can infer the resource existence from the creationTimestamp field found in the 2nd request. (rev-1)
  • At 2025-01-02T00:00:00Z: The condition information is not available because the PATCH request doesn't contain the status field under the condition. (rev-2)
  • At 2025-01-03T00:00:00Z: The condition is changed to "True". (rev-3)

Revisions were sorted with associated log time stamp, it hides the new status written at rev-2 because these were wrongly sorted as rev2, rev1, rev3.
And the 1st revision and 2nd rectangle region becomes [2025-01-02T00:00:00Z, 2025-01-01T00:00:00Z)(rev-2). and [2025-01-01T00:00:00Z,2025-01-03T00:00:00Z)(rev-1). (Note the revision end time is the change time of the next revision element and this hides rev-2 by rendering rev-1 on it )
This bug was not a severe problem for the most of cases because revisions are written in chronological order. But this bug hides the new explicit "Unknown" status.

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.

Thank you for your explanation, I think we need this fix as well.

@kyasbal kyasbal merged commit 6a2a700 into GoogleCloudPlatform:main Dec 9, 2025
8 of 9 checks passed
@kyasbal kyasbal deleted the fix/none-to-something-condition branch December 9, 2025 07:23
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