-
Notifications
You must be signed in to change notification settings - Fork 12
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
Conversation
5dc9a3a
to
1580524
Compare
Unit-tests and possible refactoring for them will be added as a followup PR. @moshe010 @ykulazhenkov PTAL |
pkg/cni/plugin/plugin.go
Outdated
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) |
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.
you log print is inconsistent is it
: %w or . %w ?
pkg/cni/plugin/plugin.go
Outdated
if err != nil { | ||
return fmt.Errorf("failed to marshal host-local net conf. %w", err) | ||
} | ||
log.Debugf("host-local stdin data:%q", string(data)) |
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.
same as above
DefaultKubeConfigFileName = "nv-ipam.kubeconfig" | ||
// ConfFileName is the name of CNI configuration file found in conf dir | ||
ConfFileName = "nv-ipam.conf" | ||
) |
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.
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)) |
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.
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 |
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.
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 |
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.
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>
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.
LGTM wait for CI to pass
This PR adds nv-ipam CNI plugin.
Note: this is still WIP, additional commits will be added