-
Notifications
You must be signed in to change notification settings - Fork 1.3k
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
🐛 Fix multiline Ready condition in clusterctl describe for v1beta2 #11781
base: main
Are you sure you want to change the base?
🐛 Fix multiline Ready condition in clusterctl describe for v1beta2 #11781
Conversation
"Object/root", | ||
"│ 2", | ||
"├─Object/child1", | ||
"│ 2", | ||
"└─Object/child2", |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Without the fix (where ?
is no prefix)
Object/root Available: False NotAvailable 292y 1
? 2
├─Object/child1 Available: False NotAvailable 292y 1
│ 2
└─Object/child2 Available: False NotAvailable 292y 1
2
"Object/root", | ||
"├─Object/child1", | ||
"└─Object/child2", | ||
" │ 2", | ||
" └─Object/child2.1", |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Without the fix
Object/root Available: True Available 292y
├─Object/child1 Available: True Available 292y
└─Object/child2 Available: False NotAvailable 292y 1
2
└─Object/child2.1
7f71cbc
to
79b13f5
Compare
c8bfa74
to
8c38475
Compare
"Object/root", | ||
"├─Object/child1", | ||
"├─Object/child2", | ||
"│ │ 2", | ||
"│ └─Object/child2.1", | ||
"│ 2", | ||
"└─Object/child3", | ||
" │ 2", | ||
" └─Object/child3.1", | ||
" 2", |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Without the fix
Object/root Available: True Available 292y
├─Object/child1 Available: True Available 292y
├─Object/child2 Available: False NotAvailable 292y 1
│ 2
│ └─Object/child2.1 Available: False NotAvailable 292y 1
│ 2
└─Object/child3 Available: False NotAvailable 292y 1
2
└─Object/child3.1 Available: False NotAvailable 292y 1
2
ac341c5
to
3aa0b3b
Compare
/assign @fabriziopandini |
3aa0b3b
to
eac73ac
Compare
[APPROVALNOTIFIER] This PR is NOT APPROVED This pull-request has been approved by: The full list of commands accepted by this bot can be found here.
Needs approval from an approver in each of these files:
Approvers can indicate their approval by writing |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Made a first quick pass, really appreciated the test with the example of the output before the change
}(), | ||
expectPrefix: []string{ | ||
"Object/root", | ||
"│ 2", |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'm a little bit confused by seeing only the second line of the message (2) and not the first line (1).
Also, why are we not seeing condition status, reason, age?
Is this correct?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It is just like the other/v1beta1 tests, we just check the prefix. We cannot ensure the age, thus we should only verify the prefix here.
tests := []struct { | ||
name string | ||
objectTree *tree.ObjectTree | ||
expectPrefix []string |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Should this be
expectPrefix []string | |
expectOutput []string |
or expectedTable given that it is more than the simple prefix
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Just copied from the v1beta1 test above :) can change it, but I should change it in both cases then
@@ -294,6 +294,154 @@ func Test_TreePrefix(t *testing.T) { | |||
} | |||
} | |||
|
|||
func Test_V1Beta2TreePrefix(t *testing.T) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
might be
func Test_V1Beta2TreePrefix(t *testing.T) { | |
func Test_addObjectRowV1Beta2(t *testing.T) { |
(this is what we are testing)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Same again as for the above comments, I copied it from the v1beta1 test
} | ||
// We just want to indent the multiline message for the Ready condition. | ||
// All ├─ should be replaced by |, so all the existing hierarchic dependencies are carried on | ||
multilinePrefix = strings.ReplaceAll(prefix+childrenPipe+filler, firstElemPrefix, pipe) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'm a little bit confused by having a filler at the end of the prefix given that what comes next goes in a different column (and so it automatically goes in the right position, no need to indent)
Same below for the additional spaces
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is a copy from the code for the conditions
cluster-api/cmd/clusterctl/cmd/describe_cluster.go
Lines 438 to 439 in eac73ac
childPrefix := getChildPrefix(prefix+childrenPipe+filler, i, len(conditions)) | |
c, status, age, reason, message := v1Beta2ConditionInfo(condition, positivePolarity) |
This is necessary as the objects condition might have a multiline message and should be handled exactly as conditions via --show-conditions
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Maybe it makes sense to reference addOtherConditionsV1Beta2()
and getChildPrefix()
in a comment
The multiline feature in clusterctl has a bug in the multiline conditions. If the Ready condition message has multipile lines the multiline prefix is not calculated properly. To fix this we can use the same logic as for the other conditions and verify if the object is the last object in the tree. Signed-off-by: Tobias Giese <[email protected]>
eac73ac
to
3c489c9
Compare
The multiline feature in clusterctl has a bug in the multiline conditions.
If the Ready condition message has multipile lines the multiline prefix is not calculated properly.
To fix this we can use the same logic as for the other conditions and verify if the object is the last object in the tree.
What this PR does / why we need it:
Which issue(s) this PR fixes (optional, in
fixes #<issue number>(, fixes #<issue_number>, ...)
format, will close the issue(s) when PR gets merged):Fixes #11782
/area clusterctl