Skip to content

Conversation

@matmerr
Copy link
Member

@matmerr matmerr commented Apr 7, 2022

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:

@matmerr matmerr force-pushed the npmcliv2 branch 2 times, most recently from d7e393c to 39e7fc9 Compare April 12, 2022 18:52
@matmerr matmerr marked this pull request as ready for review April 13, 2022 16:19
@matmerr matmerr requested a review from a team as a code owner April 13, 2022 16:19
@matmerr matmerr requested review from rbtr and removed request for a team April 13, 2022 16:19
@rbtr
Copy link
Collaborator

rbtr commented Apr 13, 2022

@vakalapa you might want to update the reviewers team 🙂

@rbtr rbtr requested review from a team and removed request for rbtr April 13, 2022 17:51
@huntergregory huntergregory added the npm Related to NPM. label Apr 13, 2022
}

if appendedIPSets == nil {
toDeleteIPSets = cachedIPSetNames
Copy link
Contributor

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)
Copy link
Contributor

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

Copy link
Collaborator

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
Copy link
Contributor

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
Copy link
Contributor

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 {
Copy link
Contributor

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?

Copy link
Contributor

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

err := viper.Unmarshal(config)
if err != nil {
return fmt.Errorf("%w", err)
log.Printf("failed to load config with err ")
Copy link
Contributor

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,
Copy link
Contributor

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()
Copy link
Contributor

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


if c.EnableV2NPM {
setInfo.Name = c.SetMap[ipsetHashedName]
setInfo.Type, _ = c.getSetTypeV2(setInfo.Name)
Copy link
Contributor

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?

@matmerr matmerr requested a review from a team as a code owner May 26, 2022 23:58
@matmerr matmerr requested review from rsagasthya and removed request for a team May 26, 2022 23:58
Copy link
Contributor

@huntergregory huntergregory left a 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
Copy link
Contributor

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
Copy link
Contributor

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
Copy link
Contributor

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)
Copy link
Contributor

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

@matmerr matmerr enabled auto-merge (squash) June 10, 2022 20:47
@huntergregory huntergregory dismissed vakalapa’s stale review June 14, 2022 17:14

the only remaining item from the requested changes seems to be a whitespace nit

@matmerr matmerr merged commit 1b57030 into Azure:master Jun 14, 2022
matmerr added a commit to matmerr/azure-container-networking that referenced this pull request Jun 29, 2022
* cache interface

* retrieve cache common interface
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

npm Related to NPM.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants