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

implement GC keyword for CNI spec 1.1 #1022

Merged
merged 4 commits into from
Oct 16, 2023
Merged

Conversation

henry118
Copy link
Member

@henry118 henry118 commented Sep 15, 2023

This PR implements the GC keyword in libcni for CNI spec 1.1

Fixes: #974

@coveralls
Copy link

coveralls commented Sep 16, 2023

Coverage Status

coverage: 71.605% (-1.1%) from 72.685% when pulling e86c9ca on henry118:gc into 743a44d on containernetworking:main.

pkg/skel/skel.go Outdated Show resolved Hide resolved
@henry118 henry118 marked this pull request as ready for review September 29, 2023 23:44
@henry118 henry118 changed the title [WIP] implement GC keyword for CNI spec 1.1 implement GC keyword for CNI spec 1.1 Sep 29, 2023
libcni/api_test.go Show resolved Hide resolved
@@ -256,15 +268,15 @@ func (t *dispatcher) pluginMain(cmdAdd, cmdCheck, cmdDel func(_ *CmdArgs) error,
if err != nil {
return types.NewError(types.ErrDecodingFailure, err.Error(), "")
} else if gtet {
if err := t.checkVersionAndCall(cmdArgs, versionInfo, cmdCheck); err != nil {
if err := t.checkVersionAndCall(cmdArgs, versionInfo, funcs.Check); err != nil {
Copy link
Contributor

@s1061123 s1061123 Oct 9, 2023

Choose a reason for hiding this comment

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

This requires func.Check must not be nil (otherwise nil pointer reference happen). Should we add validate all func.{Add,Del,Check,GC} in initiliazation (or support 'nil' to mention unsupported)

Copy link
Member Author

Choose a reason for hiding this comment

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

This patch added the nil reference check here.

Copy link
Member

@squeed squeed left a comment

Choose a reason for hiding this comment

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

Chatted with @dcbw for a bit, and we both agreed we want to see just one more thing: can you somehow expand the debug plugin so we can determine the containerID and ifname that is being passed to the DEL?

After that we can merge this. Thanks!

@s1061123
Copy link
Contributor

s1061123 commented Oct 9, 2023

I'm wondering that plugin's GC might be causes several race conditions:

For example:

  1. plugin A's GC is invoked by container runtime and plugin A starts the GC call
  2. During pluing A's GC call, (unfortunately) container runtime invokes plugin A's GC again (oh god...)

In addition, we also have another example:

  1. plugin A's GC is invoked by container runtime and plugin A starts the GC call
  2. During pluing A's GC call, (unfortunately) container runtime invokes plugin A's Add

To simplify plugin code, both should be blocked (i.e. prevent to invoke), I suppose and it should be implemented common code, in libcni.

What do you think about that?

@henry118
Copy link
Member Author

I'm wondering that plugin's GC might be causes several race conditions:

For example:

1. plugin A's GC is invoked by container runtime and plugin A starts the GC call

2. During pluing A's GC call, (unfortunately) container runtime invokes plugin A's GC again (oh god...)

In addition, we also have another example:

1. plugin A's GC is invoked by container runtime and plugin A starts the GC call

2. During pluing A's GC call, (unfortunately) container runtime invokes plugin A's Add

To simplify plugin code, both should be blocked (i.e. prevent to invoke), I suppose and it should be implemented common code, in libcni.

What do you think about that?

The GC spec explicitly called out those race conditions. The proposed mechanism is letting the runtimes to serialize the operations.

squeed and others added 4 commits October 13, 2023 20:46
Signed-off-by: Casey Callendrello <[email protected]>
Signed-off-by: Casey Callendrello <[email protected]>
Signed-off-by: Casey Callendrello <[email protected]>
@squeed squeed merged commit b15c737 into containernetworking:main Oct 16, 2023
5 checks passed
@henry118 henry118 deleted the gc branch October 16, 2023 16:50
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.

GC Verb for CNI 1.1
4 participants