-
Notifications
You must be signed in to change notification settings - Fork 14
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
validation: fix error string #1176
Conversation
/cc @rshemtov13 |
/lgtm |
/hold
Once we'll change the function name to |
99% of the cases we add |
Then we shall at least call |
/hold |
Instead of pointers display readable string. ``` found multiple pools matches for node group 0xc00467dca0 but expected one. Pools found [0xc00129aa08 0xc00129ac78] ``` To: ``` found multiple pools matches for node group &{&LabelSelector{MatchLabels:map[string]string{test: common,},MatchExpressions:[]LabelSelectorRequirement{},} <nil> <nil> map[]} but expected one. Pools found [test1 test2] ``` Signed-off-by: Shereen Haj <[email protected]>
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.
/approve
/lgtm
thanks, we can improve the string representation of the annotations map later
[APPROVALNOTIFIER] This PR is APPROVED This pull-request has been approved by: ffromani, shajmakh The full list of commands accepted by this bot can be found here. The pull request process is described here
Needs approval from an approver in each of these files:
Approvers can indicate their approval by writing |
/hold cancel |
For empty values of a struct print them out as "nil" string as well as pointers that are nil like PoolName. Signed-off-by: Shereen Haj <[email protected]>
@@ -226,15 +226,25 @@ func init() { | |||
|
|||
func (ngc *NodeGroupConfig) ToString() string { | |||
if ngc == nil { | |||
return "" | |||
return "nil" |
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.
let's see what's the string representation of nil
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.
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 followed the k8s convention as in https://github.com/kubernetes/apimachinery/blob/v0.31.2/pkg/apis/meta/v1/generated.pb.go#L4387 (and other String() methods)
On another hand, I think we can use stringbuilder or similar to construct the string instead of sprintf for such long string presentation.
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.
ok, this is better. No need to change
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.
The reason for this is that when ToString is called with empty values,some of these (like the v1.Labelselector presenting the MCP selector of the node group) is shown as "nil" while the internal ones lie ng.Config empty value is "" which doesn't look good and may confuse the readers (us mostly).
} | ||
ngc.SetDefaults() | ||
return fmt.Sprintf("PodsFingerprinting mode: %s InfoRefreshMode: %s InfoRefreshPeriod: %s InfoRefreshPause: %s Tolerations: %+v", *ngc.PodsFingerprinting, *ngc.InfoRefreshMode, *ngc.InfoRefreshPeriod, *ngc.InfoRefreshPause, ngc.Tolerations) | ||
} | ||
|
||
func (ng *NodeGroup) ToString() string { | ||
if ng == nil { | ||
return "" | ||
return "nil" |
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.
ditto
} | ||
return fmt.Sprintf("PoolName: %s MachineConfigPoolSelector: %s Config: %s", *ng.PoolName, ng.MachineConfigPoolSelector.String(), ng.Config.ToString()) | ||
|
||
pn := "nil" |
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.
ditto
/lgtm |
Instead of pointers display readable string.
To: