This repository was archived by the owner on Mar 9, 2022. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 347
Add container Exec support. #115
Merged
Random-Liu
merged 4 commits into
containerd:master
from
Random-Liu:support-container-streaming
Aug 8, 2017
Merged
Changes from all commits
Commits
Show all changes
4 commits
Select commit
Hold shift + click to select a range
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
The table of contents is too big for display.
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or 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 hidden or 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 hidden or 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 hidden or 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 hidden or 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 hidden or 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 hidden or 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 hidden or 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 |
|---|---|---|
|
|
@@ -28,9 +28,11 @@ import ( | |
| "github.com/containerd/containerd/images" | ||
| diffservice "github.com/containerd/containerd/services/diff" | ||
| "github.com/containerd/containerd/snapshot" | ||
| "github.com/golang/glog" | ||
| "github.com/kubernetes-incubator/cri-o/pkg/ocicni" | ||
| healthapi "google.golang.org/grpc/health/grpc_health_v1" | ||
| "k8s.io/kubernetes/pkg/kubelet/apis/cri/v1alpha1/runtime" | ||
| "k8s.io/kubernetes/pkg/kubelet/server/streaming" | ||
|
|
||
| osinterface "github.com/kubernetes-incubator/cri-containerd/pkg/os" | ||
| "github.com/kubernetes-incubator/cri-containerd/pkg/registrar" | ||
|
|
@@ -84,6 +86,8 @@ type criContainerdService struct { | |
| // imageStoreService is the containerd service to store and track | ||
| // image metadata. | ||
| imageStoreService images.Store | ||
| // eventsService is the containerd task service client | ||
|
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. just curious why this one is better up here?
Member
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Just group containerd services together. No particular reason. :) |
||
| eventService events.EventsClient | ||
| // versionService is the containerd version service client. | ||
| versionService versionapi.VersionClient | ||
| // healthService is the healthcheck service of containerd grpc server. | ||
|
|
@@ -94,12 +98,14 @@ type criContainerdService struct { | |
| agentFactory agents.AgentFactory | ||
| // client is an instance of the containerd client | ||
| client *containerd.Client | ||
| // eventsService is the containerd task service client | ||
| eventService events.EventsClient | ||
| // streamServer is the streaming server serves container streaming request. | ||
| streamServer streaming.Server | ||
| } | ||
|
|
||
| // NewCRIContainerdService returns a new instance of CRIContainerdService | ||
| func NewCRIContainerdService(containerdEndpoint, rootDir, networkPluginBinDir, networkPluginConfDir string) (CRIContainerdService, error) { | ||
| // TODO(random-liu): Add cri-containerd server config to get rid of the long arg list. | ||
| func NewCRIContainerdService(containerdEndpoint, rootDir, networkPluginBinDir, networkPluginConfDir, | ||
| streamAddress, streamPort string) (CRIContainerdService, error) { | ||
| // TODO(random-liu): [P2] Recover from runtime state and checkpoint. | ||
|
|
||
| client, err := containerd.New(containerdEndpoint, containerd.WithDefaultNamespace(k8sContainerdNamespace)) | ||
|
|
@@ -119,6 +125,7 @@ func NewCRIContainerdService(containerdEndpoint, rootDir, networkPluginBinDir, n | |
| containerService: client.ContainerService(), | ||
| taskService: client.TaskService(), | ||
| imageStoreService: client.ImageService(), | ||
| eventService: client.EventService(), | ||
| contentStoreService: client.ContentStore(), | ||
| // Use daemon default snapshotter. | ||
| snapshotService: client.SnapshotService(""), | ||
|
|
@@ -127,7 +134,6 @@ func NewCRIContainerdService(containerdEndpoint, rootDir, networkPluginBinDir, n | |
| healthService: client.HealthService(), | ||
| agentFactory: agents.NewAgentFactory(), | ||
| client: client, | ||
| eventService: client.EventService(), | ||
| } | ||
|
|
||
| netPlugin, err := ocicni.InitCNI(networkPluginBinDir, networkPluginConfDir) | ||
|
|
@@ -136,9 +142,20 @@ func NewCRIContainerdService(containerdEndpoint, rootDir, networkPluginBinDir, n | |
| } | ||
| c.netPlugin = netPlugin | ||
|
|
||
| // prepare streaming server | ||
| c.streamServer, err = newStreamServer(c, streamAddress, streamPort) | ||
| if err != nil { | ||
| return nil, fmt.Errorf("failed to create stream server: %v", err) | ||
| } | ||
|
|
||
| return c, nil | ||
| } | ||
|
|
||
| func (c *criContainerdService) Start() { | ||
| c.startEventMonitor() | ||
| go func() { | ||
| if err := c.streamServer.Start(true); err != nil { | ||
| glog.Errorf("Failed to start streaming server: %v", err) | ||
| } | ||
| }() | ||
| } | ||
Oops, something went wrong.
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.
always throw out the exit code if there is an error? unknownExitCode?
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 we should let
waitContainerExecalso return pointer, so that we don't need theunknownExitStatusfor now.We don't use the exit code when there is an error now.
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.
right.. just trying to figure out if that's on purpose. Seems at least possible to have an exit code and an error. Not a fan of throwing it out unless we need to.
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.
Done.