-
Notifications
You must be signed in to change notification settings - Fork 260
npm: enable debug feature parity for v2 #1324
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
Conversation
d7e393c to
39e7fc9
Compare
|
@vakalapa you might want to update the reviewers team 🙂 |
| } | ||
|
|
||
| if appendedIPSets == nil { | ||
| toDeleteIPSets = cachedIPSetNames |
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.
don't think we'll be using the gsp anytime soon but this used to have prefixed set names and now it has hashed set names
| sameNew = "updated" | ||
| } | ||
| msg := fmt.Sprintf("on try number %d, failed to run command [%s]. Rerunning with %s file. Had error [%s].\nUsed file:\n%s", creator.tryCount, commandString, sameNew, err.Error(), fileString) | ||
| msg := fmt.Sprintf("on try number %d, failed to run command [%s]. Rerunning with %s file. Had error [%s].Used file:%s", creator.tryCount, commandString, sameNew, err.Error(), fileString) |
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.
nit: easier to read the save file if there's a newline after the colon? The save file is multilined anyways
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.
logs shouldn't be multiline. one log per line pls
|
|
||
| func (c *Cache) GetListMap() map[string]string { | ||
| listMap := make(map[string]string, 0) | ||
| // get all lists |
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.
nit: maybe comment that lists are kept in the setmap in v2?
| type Namespace struct { | ||
| name string | ||
| Name string | ||
| LabelsMap map[string]string // Namespace labels |
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.
noticed that you extracted the Pod struct into the common pkg. Not necessary, but should we do that here for Namespace?
| ) | ||
|
|
||
| // Tuple struct | ||
| type Tuple struct { |
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.
nit: maybe Tuple stuff belongs in its own file?
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 can be moved to pkg/dataplane/debug
npm/cmd/gettuples.go
Outdated
| err := viper.Unmarshal(config) | ||
| if err != nil { | ||
| return fmt.Errorf("%w", err) | ||
| log.Printf("failed to load config with err ") |
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.
nit: missing err
| npmMgr := NetworkPolicyManager{ | ||
| config: npmconfig.Config{ | ||
| Toggles: npmconfig.Toggles{ | ||
| EnableV2NPM: true, |
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.
add same test for v1?
|
|
||
| } | ||
|
|
||
| return settype, setmetadata.GetSetKind() |
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.
introducing a getSetKind() method for SetType in my current PR. Would make this a little cleaner than having to use SetMetadata
npm/pkg/dataplane/debug/converter.go
Outdated
|
|
||
| if c.EnableV2NPM { | ||
| setInfo.Name = c.SetMap[ipsetHashedName] | ||
| setInfo.Type, _ = c.getSetTypeV2(setInfo.Name) |
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.
return error if it doesn't exist?
huntergregory
left a comment
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.
converter logic looks good now
| containers: | ||
| - name: azure-npm | ||
| image: mcr.microsoft.com/containernetworking/azure-npm:v1.4.21 | ||
| image: acnpublic.azurecr.io/azure-npm:v1.4.22-24-g0df7a4d7-dirty-v3 |
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.
nit: do we want to have acnpublic here?
| c := &debug.Converter{ | ||
| NPMDebugEndpointHost: "http://localhost", | ||
| NPMDebugEndpointPort: api.DefaultHttpPort, | ||
| EnableV2NPM: config.Toggles.EnableV2NPM, // todo: pass this a different way than param to this |
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.
any plans for the todo?
| // matmerr: todo: really not a fan of sniping the marshaljson and returing different marshalled type, | ||
| // makes very difficult to predict marshalled type when used as a client | ||
| // Dear Time Traveler: | ||
| // This is the server end of the debug dragons den. Several of these properties of the |
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.
😅
| continue | ||
| } | ||
| /*tuple.Tuple.Direction == "EGRESS" { | ||
| fmt.Printf("\tProtocol: %s, Port: %s\n, Chain: %v", tuple.Tuple.Protocol, tuple.Tuple.SrcPort, tuple.Rule.Chain) |
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.
would prefer removing dead code, but that doesn't need to be a blocker
the only remaining item from the requested changes seems to be a whitespace nit
* cache interface * retrieve cache common interface
Reason for Change:
Enables basic debug feature parity with V1 and V2. Followup PR will add bubble up iptables comments along with gettuples.
Issue Fixed:
Requirements:
Notes: