-
Notifications
You must be signed in to change notification settings - Fork 603
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
hotplug feature: add pod networks annotation controller #777
Closed
maiqueb
wants to merge
41
commits into
k8snetworkplumbingwg:feature/multus-4.0
from
maiqueb:add-networks-annotation-controller
Closed
Changes from 1 commit
Commits
Show all changes
41 commits
Select commit
Hold shift + click to select a range
71ea3b5
thick-plugin: refactor multus
maiqueb bba9474
react to maintainers review
maiqueb aed83d5
thick, deployment: update the daemonset spec
maiqueb c163cc7
thick, config: validate the cni config passed by the runtime
maiqueb 6e22328
thick: model client / server config
maiqueb 3f31f0d
SQUASH candidate, thick, config: cleanup the configuration
maiqueb 41ce328
multus: use args.args instead of an env variable
maiqueb ddcd865
unit tests: remove weird tests that check an impossible scenario
maiqueb 7fcfe77
docs, thick: document the thick plugin variant
maiqueb 1d228ee
thick, server, multus: re-use common types
maiqueb b800e09
Merge pull request #771 from maiqueb/thick-arch
dougbtv 9a66450
Replace setenv with runtimeConfig set (#785)
s1061123 b652f86
Make binary file and directory name consistent
s1061123 20224de
Simplify e2e scripts (#795)
s1061123 e6e854a
Split multus unit tests into several files
s1061123 efde67b
check version incompatibility (#762) (#798)
s1061123 5b3f05e
Merge pull request #797 from s1061123/dev/refine_multus_ut
dougbtv 107121c
Support CNI 1.0.0
s1061123 c7be533
Merge pull request #800 from s1061123/dev/cni100
dougbtv 0864e88
Fix thick plugin to run kind-e2e test
s1061123 1a0fcf0
only warn when netns can't be opened (#803)
dougbtv d373015
crio: mount /run rslave (#802)
dougbtv 804ab0d
fix the usage of flag "overrideNetworkName" (#805)
cyclinder 4c70e05
Refine unit test in pkg/multus
s1061123 9d9ff18
Merge pull request #806 from s1061123/dev/refine-multus-ut
dougbtv ebb7bdf
Merge pull request #807 from s1061123/dev/fix-thick-e2e
dougbtv 497ddfe
Fix install binary for thick plugin
s1061123 49d49d6
controller: listen to pod network annotation updates
maiqueb 2dbaef1
controller, containerd: add CRI runtime
maiqueb ed66763
controller, cni: invoke cni API add/remove network
maiqueb da7adbe
controller, crio: add new runtime
maiqueb 544418b
yaml templating: remove unnecessary config
maiqueb 1e06a12
e2e, tests: re-write macvlan tests in golang
maiqueb c7e9da6
e2e tests, hotplug: test hotplug interface
maiqueb 1dd0059
ci: only run golang e2e on the thick img variant
maiqueb 9641f7c
config, cri: specify the cri in the multus server config
maiqueb 297d6ed
controller: user informer factories
maiqueb 62f899c
controller: use net-attach-def informer & lister
maiqueb 1728706
controller: use a workqueue, to provide a level trigger controller
maiqueb a6dc413
containerd, unit tests: add unit tests to containerd runtime
maiqueb a8ce32c
crio, unit tests: add unit tests to cri-o runtime
maiqueb File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,61 @@ | ||
package crio | ||
|
||
import ( | ||
"context" | ||
"testing" | ||
|
||
. "github.com/onsi/ginkgo" | ||
. "github.com/onsi/gomega" | ||
|
||
"gopkg.in/k8snetworkplumbingwg/multus-cni.v3/pkg/containerruntimes/crio/fake" | ||
) | ||
|
||
func TestController(t *testing.T) { | ||
RegisterFailHandler(Fail) | ||
RunSpecs(t, "Dynamic network attachment controller suite") | ||
} | ||
|
||
var _ = Describe("CRI-O runtime", func() { | ||
var runtime *CrioRuntime | ||
|
||
When("the runtime *does not* feature any containers", func() { | ||
BeforeEach(func() { | ||
runtime = newDummyCrioRuntime() | ||
}) | ||
|
||
It("cannot extract the network namespace of a container", func() { | ||
_, err := runtime.NetNS("1234") | ||
Expect(err).To(MatchError("failed to get pod sandbox info: container 1234 not found")) | ||
}) | ||
}) | ||
|
||
When("a live container is provisioned in the runtime", func() { | ||
const ( | ||
containerID = "1234" | ||
netnsPath = "bottom-drawer" | ||
) | ||
BeforeEach(func() { | ||
runtime = newDummyCrioRuntime(fake.WithCachedContainer(containerID, netnsPath)) | ||
}) | ||
|
||
It("cannot extract the network namespace of a container", func() { | ||
Expect(runtime.NetNS(containerID)).To(Equal(netnsPath)) | ||
}) | ||
}) | ||
}) | ||
|
||
func newDummyCrioRuntime(opts ...fake.ClientOpt) *CrioRuntime { | ||
runtimeClient := fake.NewFakeClient() | ||
|
||
for _, opt := range opts { | ||
opt(runtimeClient) | ||
} | ||
|
||
ctx := context.TODO() | ||
ctxWithCancel, cancelFunc := context.WithCancel(ctx) | ||
return &CrioRuntime{ | ||
client: runtimeClient, | ||
context: ctxWithCancel, | ||
cancelFunc: cancelFunc, | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,147 @@ | ||
package fake | ||
|
||
import ( | ||
"context" | ||
"encoding/json" | ||
"fmt" | ||
|
||
"google.golang.org/grpc" | ||
|
||
crioruntime "k8s.io/cri-api/pkg/apis/runtime/v1alpha2" | ||
|
||
"gopkg.in/k8snetworkplumbingwg/multus-cni.v3/pkg/containerruntimes/crio/types" | ||
) | ||
|
||
type CrioClient struct { | ||
cache map[string]string | ||
} | ||
|
||
type ClientOpt func(client *CrioClient) | ||
|
||
func NewFakeClient(opts ...ClientOpt) *CrioClient { | ||
client := &CrioClient{cache: map[string]string{}} | ||
for _, opt := range opts { | ||
opt(client) | ||
} | ||
return client | ||
} | ||
|
||
func WithCachedContainer(containerID string, netnsPath string) ClientOpt { | ||
return func(client *CrioClient) { | ||
client.cache[containerID] = netnsPath | ||
} | ||
} | ||
|
||
func (CrioClient) Version(ctx context.Context, in *crioruntime.VersionRequest, opts ...grpc.CallOption) (*crioruntime.VersionResponse, error) { | ||
return nil, nil | ||
} | ||
|
||
func (CrioClient) RunPodSandbox(ctx context.Context, in *crioruntime.RunPodSandboxRequest, opts ...grpc.CallOption) (*crioruntime.RunPodSandboxResponse, error) { | ||
return nil, nil | ||
} | ||
|
||
func (CrioClient) StopPodSandbox(ctx context.Context, in *crioruntime.StopPodSandboxRequest, opts ...grpc.CallOption) (*crioruntime.StopPodSandboxResponse, error) { | ||
return nil, nil | ||
} | ||
|
||
func (CrioClient) RemovePodSandbox(ctx context.Context, in *crioruntime.RemovePodSandboxRequest, opts ...grpc.CallOption) (*crioruntime.RemovePodSandboxResponse, error) { | ||
return nil, nil | ||
} | ||
|
||
func (CrioClient) PodSandboxStatus(ctx context.Context, in *crioruntime.PodSandboxStatusRequest, opts ...grpc.CallOption) (*crioruntime.PodSandboxStatusResponse, error) { | ||
return nil, nil | ||
} | ||
|
||
func (CrioClient) ListPodSandbox(ctx context.Context, in *crioruntime.ListPodSandboxRequest, opts ...grpc.CallOption) (*crioruntime.ListPodSandboxResponse, error) { | ||
return nil, nil | ||
} | ||
|
||
func (CrioClient) CreateContainer(ctx context.Context, in *crioruntime.CreateContainerRequest, opts ...grpc.CallOption) (*crioruntime.CreateContainerResponse, error) { | ||
return nil, nil | ||
} | ||
|
||
func (CrioClient) StartContainer(ctx context.Context, in *crioruntime.StartContainerRequest, opts ...grpc.CallOption) (*crioruntime.StartContainerResponse, error) { | ||
return nil, nil | ||
} | ||
|
||
func (CrioClient) StopContainer(ctx context.Context, in *crioruntime.StopContainerRequest, opts ...grpc.CallOption) (*crioruntime.StopContainerResponse, error) { | ||
return nil, nil | ||
} | ||
|
||
func (CrioClient) RemoveContainer(ctx context.Context, in *crioruntime.RemoveContainerRequest, opts ...grpc.CallOption) (*crioruntime.RemoveContainerResponse, error) { | ||
return nil, nil | ||
} | ||
|
||
func (CrioClient) ListContainers(ctx context.Context, in *crioruntime.ListContainersRequest, opts ...grpc.CallOption) (*crioruntime.ListContainersResponse, error) { | ||
return nil, nil | ||
} | ||
|
||
func (cc CrioClient) ContainerStatus(ctx context.Context, in *crioruntime.ContainerStatusRequest, opts ...grpc.CallOption) (*crioruntime.ContainerStatusResponse, error) { | ||
containerId := in.ContainerId | ||
netnsPath, wasFound := cc.cache[containerId] | ||
if !wasFound { | ||
return nil, fmt.Errorf("container %s not found", containerId) | ||
} | ||
|
||
containerStatus := types.PodStatusResponseInfo{ | ||
RunTimeSpec: types.RunTimeSpecInfo{ | ||
Linux: types.NamespacesInfo{ | ||
Namespaces: []types.NameSpaceInfo{ | ||
{ | ||
Type: "network", | ||
Path: netnsPath, | ||
}, | ||
}, | ||
}, | ||
}, | ||
} | ||
|
||
marshalledContainerStatus, err := json.Marshal(&containerStatus) | ||
if err != nil { | ||
return nil, fmt.Errorf("error marshalling the container status: %v", err) | ||
} | ||
|
||
return &crioruntime.ContainerStatusResponse{ | ||
Info: map[string]string{"info": string(marshalledContainerStatus)}, | ||
}, nil | ||
} | ||
|
||
func (CrioClient) UpdateContainerResources(ctx context.Context, in *crioruntime.UpdateContainerResourcesRequest, opts ...grpc.CallOption) (*crioruntime.UpdateContainerResourcesResponse, error) { | ||
return nil, nil | ||
} | ||
|
||
func (CrioClient) ReopenContainerLog(ctx context.Context, in *crioruntime.ReopenContainerLogRequest, opts ...grpc.CallOption) (*crioruntime.ReopenContainerLogResponse, error) { | ||
return nil, nil | ||
} | ||
|
||
func (CrioClient) ExecSync(ctx context.Context, in *crioruntime.ExecSyncRequest, opts ...grpc.CallOption) (*crioruntime.ExecSyncResponse, error) { | ||
return nil, nil | ||
} | ||
|
||
func (CrioClient) Exec(ctx context.Context, in *crioruntime.ExecRequest, opts ...grpc.CallOption) (*crioruntime.ExecResponse, error) { | ||
return nil, nil | ||
} | ||
|
||
func (CrioClient) Attach(ctx context.Context, in *crioruntime.AttachRequest, opts ...grpc.CallOption) (*crioruntime.AttachResponse, error) { | ||
return nil, nil | ||
} | ||
|
||
func (CrioClient) PortForward(ctx context.Context, in *crioruntime.PortForwardRequest, opts ...grpc.CallOption) (*crioruntime.PortForwardResponse, error) { | ||
return nil, nil | ||
} | ||
|
||
func (CrioClient) ContainerStats(ctx context.Context, in *crioruntime.ContainerStatsRequest, opts ...grpc.CallOption) (*crioruntime.ContainerStatsResponse, error) { | ||
return nil, nil | ||
} | ||
|
||
func (CrioClient) ListContainerStats(ctx context.Context, in *crioruntime.ListContainerStatsRequest, opts ...grpc.CallOption) (*crioruntime.ListContainerStatsResponse, error) { | ||
return nil, nil | ||
} | ||
|
||
func (CrioClient) UpdateRuntimeConfig(ctx context.Context, in *crioruntime.UpdateRuntimeConfigRequest, opts ...grpc.CallOption) (*crioruntime.UpdateRuntimeConfigResponse, error) { | ||
return nil, nil | ||
} | ||
|
||
func (CrioClient) Status(ctx context.Context, in *crioruntime.StatusRequest, opts ...grpc.CallOption) (*crioruntime.StatusResponse, error) { | ||
return nil, nil | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
package types | ||
|
||
// PodStatusResponseInfo represents the container status reply - crictl ps <containerID> | ||
type PodStatusResponseInfo struct { | ||
SandboxID string | ||
RunTimeSpec RunTimeSpecInfo | ||
} | ||
|
||
// RunTimeSpecInfo represents the relevant part of the container status spec | ||
type RunTimeSpecInfo struct { | ||
Linux NamespacesInfo | ||
} | ||
|
||
// NamespacesInfo represents the container status namespaces | ||
type NamespacesInfo struct { | ||
Namespaces []NameSpaceInfo | ||
} | ||
|
||
// NameSpaceInfo represents the ns info | ||
type NameSpaceInfo struct { | ||
Type string | ||
Path string | ||
} |
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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 it clause description is wrong, probably a copy paste error.