-
Notifications
You must be signed in to change notification settings - Fork 11
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 frontend crash in Summary page when data is missing #23
Fix frontend crash in Summary page when data is missing #23
Conversation
When Antrea runs in networkPolicyOnly mode, the nodeSubnets field is missing (omitted because empty) from AntreaAgentInfo resources. The frontend needs to handle this case gracefully. Fixes antrea-io#22 Signed-off-by: Antonin Bas <abas@vmware.com>
|
||
function refToString(ref: K8sRef): string { | ||
function refToString(ref: K8sRef | undefined): 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.
function refToString(ref: K8sRef | undefined): string { | |
function refToString(ref?: K8sRef): string { |
if (ref.namespace) return ref.namespace + '/' + ref.name; | ||
return ref.name; | ||
} | ||
|
||
// returns status and last heartbeat time | ||
function getConditionInfo(conditions: Condition[], name: string): [string, string] { | ||
function getConditionInfo(conditions: Condition[] | undefined, name: string): [string, 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.
ditto
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 2 mean different things:
function getConditionInfo(conditions: Condition[] | undefined, name: string)
function getConditionInfo(conditions?: Condition[], name: string)
The second one is not valid because ?:
indicates an optional parameter, and an optional parameter cannot come before a required parameter (name
). Here conditions
is not really an optional parameter, but a required parameter that can be undefined.
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.
LGTM with some nits.
@xliuxu Thanks for the quick review. I'll merge as it is to fix the bug. If you have a better alternative, let me know. I was considering handling the |
When Antrea runs in networkPolicyOnly mode, the nodeSubnets field is missing (omitted because empty) from AntreaAgentInfo resources. The frontend needs to handle this case gracefully. Fixes #22 Signed-off-by: Antonin Bas <abas@vmware.com>
When Antrea runs in networkPolicyOnly mode, the nodeSubnets field is missing (omitted because empty) from AntreaAgentInfo resources. The frontend needs to handle this case gracefully.
Fixes #22