Skip to content

Conversation

@vakalapa
Copy link
Contributor

@vakalapa vakalapa commented Jan 8, 2022

Reason for Change:

  1. Adding new GoalState processor as an entry point for Daemon pod events in Fan out design
  2. Utils for encoding sets and policies for grpc.

Issue Fixed:

Requirements:

Notes:

@vakalapa vakalapa added enhancement npm Related to NPM. labels Jan 8, 2022
dp.DeleteIPSet(ipsets.TestKVPodSet.Metadata)
panicOnError(dp.ApplyDataPlane())

panicOnError(dp.AddToLists([]*ipsets.IPSetMetadata{ipsets.TestNestedLabelList.Metadata}, []*ipsets.IPSetMetadata{ipsets.TestKVPodSet.Metadata, ipsets.TestNSSet.Metadata}))
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

can you surround this in an if statement (if includeLists or something like other list operations in the file)

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It is a validate test case we should use always right ? Any particular reason for this suggestion ?

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

My machine doesn't support lists, so I introduced includeLists

}

func (set *IPSet) GetSetMetadata() *IPSetMetadata {
return NewIPSetMetadata(set.unPrefixedName, set.Type)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

why do we want the unprefixed name for this?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Metadata of a ipset should always be created with unprefixed name, or else we will end up using double prefixed names.

type GenericDataplane interface {
InitializeDataPlane() error
ResetDataPlane() error
GetIPSet(setName string) *ipsets.IPSet
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

As discussed offline, I feel this shouldn't be part of the generic dataplane interface. Perhaps the gsp should use the dataplane struct instead of the GenericDataplane interface

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is a function we will need for DPmocks for UTs and also for GSProcessor. So kept it as a higher level interface method. In future, we can this function for other utilities, like debugging or observability.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

So is this a no-op in production?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

GetIPSet is being used by GSProcessors, DP, to figure out what is existing set goal state and to compute diff. We are also using this in UTs.

Atm, we do not use this function in normal coupled mode.

return
}

err := gsp.processIPSetsApplyEvent(payload[cp.IpsetApply])
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Check if key exists? We don't want to panic if the event payload doesn't contain the key.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I am a little confused by these process blocks. Does every incoming payload have all keys in the map populated?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

For NameSpace resource events:

Add: IPSETAPPLY
Update/Delete: IPSETAPPLY and /(or) IPSETREMOVE

For Pod resource events:

Add: IPSETAPPLY
Update/Delete: IPSETAPPLY and /(or) IPSETREMOVE

For Network Policy resource events:

Add: IPSETAPPLY and PolicyAPPly
Update: IPSETAPPLY and /(or) IPSETREMOVE + PolicyAPPLY
Delete: IPSETREMOVE + PolicyRemove

This is how the keys will match to respective resource events ... @huntergregory FYI

type GenericDataplane interface {
InitializeDataPlane() error
ResetDataPlane() error
GetIPSet(setName string) *ipsets.IPSet
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

So is this a no-op in production?

outChannel chan *protos.Events
}

func NewDPSim(outChannel chan *protos.Events) *DPShim {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

nit: typo

Copy link
Contributor

@nitishm nitishm left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Good stuff - LGTM

@vakalapa vakalapa merged commit da719d7 into master Jan 14, 2022
@vakalapa vakalapa deleted the vakr/gsprocessor branch January 14, 2022 21:54
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

enhancement npm Related to NPM.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants