Skip to content

Conversation

@nddq
Copy link
Member

@nddq nddq commented Oct 17, 2023

Reason for Change:

Same as 2114 but from a branch on the main repo to circumvent ongoing pipeline issues.

  • ipam.go -> requestConfigHandlerHelper releases default ipconfig immediately on failure + more UTs
  • swiftv2.go -> Add routes for node CIDRs + parse MTPNC Primary IP as a CIDR + toggle SkipDefaultRoutes for InfraNIC to true
  • Move CNS RBAC roles for SWIFT v2 to a different file
  • Add loggers

Issue Fixed:

Requirements:

Notes:

nddq and others added 30 commits July 28, 2023 17:25
Signed-off-by: Quang Nguyen <nddangquang@gmail.com>
Signed-off-by: Quang Nguyen <nddangquang@gmail.com>
ErrNoNCs = errors.New("No NCs found in the CNS internal state")
)

// requestIPConfigHandlerHelper validates the request, assigns IPs, and returns a response
Copy link
Member

Choose a reason for hiding this comment

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

Can we keep or enhance the comments?

assert.False(t, podIPInfo[2].SkipDefaultRoutes)
}

func TestIPAMGetSWIFTv2IPFailure(t *testing.T) {
Copy link
Member

Choose a reason for hiding this comment

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

Not sure what we are asserting here and what is failing, can you please explain with some comments at the beginning?

Copy link
Member

@isaac-dasan isaac-dasan left a comment

Choose a reason for hiding this comment

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

What is the ongoing pipelines issue that we are trying to circumvent?

mtpnc := v1alpha1.MultitenantPodNetworkConfig{}
mtpncNamespacedName := k8stypes.NamespacedName{Namespace: podInfo.Namespace(), Name: podInfo.Name()}
if err := m.Cli.Get(ctx, mtpncNamespacedName, &mtpnc); err != nil {
return cns.PodIpInfo{}, fmt.Errorf("failed to get pod's mtpnc from cache : %w", err)
Copy link
Collaborator

Choose a reason for hiding this comment

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

we should use errors.Wrap/Wrapf everywhere, never fmt.Errorf

Copy link
Member Author

Choose a reason for hiding this comment

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

I noticed that the package github.com/pkg/errors have been made obsolete since go 1.13 (see answer here, and also the repo has been archived since 2021. Should we still be using it?

Copy link
Collaborator

Choose a reason for hiding this comment

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

we are still using it.

return nil
}

// parseCIDRs parses the semicolons separated CIDRs string and returns the IPv4 and IPv6 CIDRs.
Copy link
Collaborator

Choose a reason for hiding this comment

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

semicolons

comment needs update

effect: NoSchedule
containers:
- name: cns-container
image: mcr.microsoft.com/containernetworking/azure-cns:v1.4.7
Copy link
Collaborator

Choose a reason for hiding this comment

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

i don't think we need this file at all?

@@ -1,32 +1,4 @@
apiVersion: v1
kind: ServiceAccount
Copy link
Collaborator

Choose a reason for hiding this comment

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

revert this file, why did you change it?

SWIFTv2IP = "192.168.0.1"
SWIFTv2MAC = "00:00:00:00:00:00"
SWIFTv2GatewayIP = "10.0.0.1"
SWIFTv2NCID = "testncid"
Copy link
Collaborator

Choose a reason for hiding this comment

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

the linter will not warn you about unused Exported fields, only private ones. because they could be used by another package which the linter is not scanning

SetRoutes(*PodIpInfo) error
}

type IPConfigsRequestValidator func(context.Context, *IPConfigsRequest) (types.ResponseCode, string)
Copy link
Collaborator

Choose a reason for hiding this comment

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

does this func need to return (types.ResponseCode, string)? If it is just a validator, returning err or nil should be plenty?

Copy link
Collaborator

Choose a reason for hiding this comment

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

I see from the impl that this is not actually a pure function, as -Validator implies.
It also isn't really middleware/decorator - that would require the input to the middleware func to the next func to call in the chain...this is just a dependent object.
Since it mutates the input *IPConfigsRequest, the field in the "Middleware" object should be renamed to something like SetHasSecondaryInterface. I don't have a good idea for what the interface def should be renamed to, but validator it is not.

Copy link
Member Author

Choose a reason for hiding this comment

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

fyi @miguelgoms, we had a discussion regarding this offline. Currently the way I implement the logic behind SWIFTv2Middleware cherry-picked middleware behaviors, but it is not "true middleware". It is a design review so it is not blocking, we can still go ahead with this since everything is working now, but I can go back to this after we got everything merged to revise the design.

@nddq
Copy link
Member Author

nddq commented Oct 27, 2023

What is the ongoing pipelines issue that we are trying to circumvent?

We can't trigger build from forks anymore, so I had to make a PR from a branch directly from the main ACN repo.

Signed-off-by: Quang Nguyen <nguyenquang@microsoft.com>
isaac-dasan

This comment was marked as off-topic.

isaac-dasan
isaac-dasan previously approved these changes Oct 28, 2023
@nddq nddq dismissed stale reviews from miguelgoms and isaac-dasan via 86b9e7d October 28, 2023 17:59
miguelgoms
miguelgoms previously approved these changes Oct 30, 2023
nddq and others added 4 commits October 30, 2023 15:12
Signed-off-by: Quang Nguyen <nguyenquang@microsoft.com>
Signed-off-by: Quang Nguyen <nguyenquang@microsoft.com>
Signed-off-by: Quang Nguyen <nguyenquang@microsoft.com>
Copy link
Collaborator

@rbtr rbtr left a comment

Choose a reason for hiding this comment

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

there's some missed usages of fmt.Error, and util packages are generally discouraged. not blocking

Copy link
Collaborator

Choose a reason for hiding this comment

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

LabelPodSwiftV2 = "kubernetes.azure.com/pod-network"
EnvPodCIDRs = "POD_CIDRs"
EnvServiceCIDRs = "SERVICE_CIDRs"
EnvNodeCIDRs = "NODE_CIDRs"
Copy link
Member

Choose a reason for hiding this comment

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

This will change to infraVnet CIDR in future PR

@nddq nddq merged commit d34c61f into master Oct 31, 2023
@nddq nddq deleted the featSWIFTv2-IPAM-branching branch October 31, 2023 17:45
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

cns Related to CNS. swift-v2

Projects

None yet

Development

Successfully merging this pull request may close these issues.

6 participants