Skip to content
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

nv-ipam CNI plugin #3

Merged
merged 11 commits into from
May 4, 2023
Merged

nv-ipam CNI plugin #3

merged 11 commits into from
May 4, 2023

Conversation

adrianchiris
Copy link
Collaborator

@adrianchiris adrianchiris commented May 1, 2023

This PR adds nv-ipam CNI plugin.

Note: this is still WIP, additional commits will be added

Dockerfile Show resolved Hide resolved
pkg/cni/types/types.go Outdated Show resolved Hide resolved
pkg/cni/types/types.go Show resolved Hide resolved
pkg/cni/k8sclient/k8sclient.go Show resolved Hide resolved
pkg/cni/pool/pool.go Show resolved Hide resolved
pkg/cni/pool/pool.go Show resolved Hide resolved
@adrianchiris adrianchiris force-pushed the nv-ipam branch 2 times, most recently from 5dc9a3a to 1580524 Compare May 3, 2023 10:43
@adrianchiris adrianchiris changed the title [WIP] nv-ipam CNI plugin nv-ipam CNI plugin May 3, 2023
@adrianchiris
Copy link
Collaborator Author

Unit-tests and possible refactoring for them will be added as a followup PR.

@moshe010 @ykulazhenkov PTAL

pkg/cni/plugin/plugin.go Outdated Show resolved Hide resolved
func (p *Plugin) CmdDel(args *skel.CmdArgs) error {
conf, err := types.LoadConf(args.StdinData)
if err != nil {
return fmt.Errorf("failed to load config: %w", err)
Copy link
Contributor

Choose a reason for hiding this comment

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

you log print is inconsistent is it
: %w or . %w ?

pkg/cni/plugin/plugin.go Outdated Show resolved Hide resolved
if err != nil {
return fmt.Errorf("failed to marshal host-local net conf. %w", err)
}
log.Debugf("host-local stdin data:%q", string(data))
Copy link
Contributor

Choose a reason for hiding this comment

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

same as above

DefaultKubeConfigFileName = "nv-ipam.kubeconfig"
// ConfFileName is the name of CNI configuration file found in conf dir
ConfFileName = "nv-ipam.conf"
)
Copy link
Contributor

Choose a reason for hiding this comment

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

comment to self refactor code to use constant once this PR is merged

if err != nil {
return nil, fmt.Errorf("failed to read k8s node name from path: %s. %w", p, err)
}
n.IPAM.NodeName = strings.TrimSpace(string(data))
Copy link
Contributor

Choose a reason for hiding this comment

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

the trim is unnecessary but it not hurt to do it

func LoadFromConfFile(filePath string) (*IPAMConf, error) {
data, err := os.ReadFile(filePath)
if err != nil {
return nil, err
Copy link
Contributor

Choose a reason for hiding this comment

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

maybe change err to fmt.Errorf("Failed to ReadFile %s: %v", filePath, err)

confFromFile := &IPAMConf{}
err = json.Unmarshal(data, confFromFile)
if err != nil {
return nil, err
Copy link
Contributor

Choose a reason for hiding this comment

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

same as above

Signed-off-by: adrianc <adrianc@nvidia.com>
types package contains CNI types
for nv-ipam and host-local

Signed-off-by: adrianc <adrianc@nvidia.com>
k8sclient package is used to create a kubernetes
client from kubeconfig file provided by path in filesystem

Signed-off-by: adrianc <adrianc@nvidia.com>
pool package is used to manage pool configuration
as defined in node annotation

Signed-off-by: adrianc <adrianc@nvidia.com>
cmd add flow updated

Signed-off-by: adrianc <adrianc@nvidia.com>
- use network name as pool name if pool name
  not provided
- use kubeconfig from ConfDir if not provided
  instead of DefaultConfDir

Signed-off-by: adrianc <adrianc@nvidia.com>
- Rename PoolConfig to just Pool
- Add pool name to pool

Signed-off-by: adrianc <adrianc@nvidia.com>
Signed-off-by: adrianc <adrianc@nvidia.com>
This allows to provide per node default
configuraiton for nv-ipam cni plugin

Signed-off-by: adrianc <adrianc@nvidia.com>
Signed-off-by: adrianc <adrianc@nvidia.com>
Signed-off-by: adrianc <adrianc@nvidia.com>
Copy link
Contributor

@moshe010 moshe010 left a comment

Choose a reason for hiding this comment

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

LGTM wait for CI to pass

@moshe010 moshe010 merged commit e65d305 into Mellanox:main May 4, 2023
7 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants