fix: Condition "Unknown" was shown for the condition without containing the status body#408
Conversation
…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
Summary of ChangesHello @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
Using Gemini Code AssistThe 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
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 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
|
There was a problem hiding this comment.
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.
…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 { |
There was a problem hiding this comment.
Is this change related to the main concern of this PR?
There was a problem hiding this comment.
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.
There was a problem hiding this comment.
Thank you for your explanation, I think we need this fix as well.
Some patch requests can omit its condition status and it was treated as Unknown condition and confusing with the explicit Unknown status