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 NetworkPolicy resources dump for Agent's supportbundle #3083
Fix NetworkPolicy resources dump for Agent's supportbundle #3083
Conversation
There was an obvious bug where all NetworkPolicy resources
(NetworkPolicies, AddressGroups, AppliedToGroups) were dumped to the
same file, and the file itself ("agentinfo") was subsequently
overwritten with a dump of the appropriate AgentInfo CRD as expected.
This is fixed by dumping these resources to their respective appropriate
files: networkpolicies, addressgroups, appliedtogroups.
In addition, we:
* switch from JSON to YAML for these resources (along with the AgentInfo
CRD) for consistency with the files included in the Controller's
supportbundle.
* define a custom MarshalYAML function for the IPAddress type. IPAddress
is typedef'ed to a byte slice, which means that by default it is
marshalled as an array of individual byte values, making the files
difficult to read.
Fixes antrea-io#3082
Signed-off-by: Antonin Bas <abas@vmware.com>
Codecov Report
@@ Coverage Diff @@
## main #3083 +/- ##
==========================================
- Coverage 59.79% 52.05% -7.75%
==========================================
Files 292 454 +162
Lines 24732 51687 +26955
==========================================
+ Hits 14788 26904 +12116
- Misses 8317 22494 +14177
- Partials 1627 2289 +662
Flags with carried forward coverage won't be shown. Click here to find out 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.
LGTM
| ) | ||
|
|
||
| func (a IPAddress) MarshalYAML() (interface{}, error) { | ||
| return net.IP(a).String(), 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.
Not related to this PR, I'm wondering if we should change IP field to string like K8s objects, to make the response readable even when troubleshooting with curl or kubectl get addressgroup directly.
We wanted to save some space when making it []byte, however, it seems we forgot to call To4 for IPv4 address so it actually uses more space (16bytes vs 15bytes) since the very begining.
@jianjuns @antoninbas
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.
If we have clues string or (4) bytes wont make big difference we can switch to string. I feel typically network control plane will optimize though.
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.
either way works for me. If we switch to strings, it could maybe get a bit long for some IPv6 addresses?
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.
Yes, 39 bytes at most. We don't need to make a decision right now as it needs a new API version. We could consider this when it's necessary to have a new version.
|
/test-all |
|
/test-all |
1 similar comment
|
/test-all |
There was an obvious bug where all NetworkPolicy resources
(NetworkPolicies, AddressGroups, AppliedToGroups) were dumped to the
same file, and the file itself ("agentinfo") was subsequently
overwritten with a dump of the appropriate AgentInfo CRD as expected.
This is fixed by dumping these resources to their respective appropriate
files: networkpolicies, addressgroups, appliedtogroups.
In addition, we:
CRD) for consistency with the files included in the Controller's
supportbundle.
is typedef'ed to a byte slice, which means that by default it is
marshalled as an array of individual byte values, making the files
difficult to read.
Fixes #3082
Signed-off-by: Antonin Bas abas@vmware.com