Skip to content
This repository was archived by the owner on Mar 9, 2022. It is now read-only.

Commit 2259b61

Browse files
committed
Add Version, UpdateRuntimeConfig and Status.
Signed-off-by: Lantao Liu <[email protected]>
1 parent b09eaff commit 2259b61

File tree

4 files changed

+40
-9
lines changed

4 files changed

+40
-9
lines changed

pkg/server/service.go

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,7 @@ import (
2727
"github.com/containerd/containerd/api/services/execution"
2828
imagesapi "github.com/containerd/containerd/api/services/images"
2929
rootfsapi "github.com/containerd/containerd/api/services/rootfs"
30+
versionapi "github.com/containerd/containerd/api/services/version"
3031
"github.com/containerd/containerd/content"
3132
"github.com/containerd/containerd/images"
3233
contentservice "github.com/containerd/containerd/services/content"
@@ -86,13 +87,15 @@ type criContainerdService struct {
8687
containerNameIndex *registrar.Registrar
8788
// containerService is containerd container service client.
8889
containerService execution.ContainerServiceClient
89-
// contentStoreService is the containerd content service client..
90+
// contentStoreService is the containerd content service client.
9091
contentStoreService content.Store
9192
// rootfsService is the containerd rootfs service client.
9293
rootfsService rootfsapi.RootFSClient
9394
// imageStoreService is the containerd service to store and track
9495
// image metadata.
9596
imageStoreService images.Store
97+
// versionService is the containerd version service client.
98+
versionService versionapi.VersionClient
9699
// netPlugin is used to setup and teardown network when run/stop pod sandbox.
97100
netPlugin ocicni.CNIPlugin
98101
}
@@ -117,6 +120,7 @@ func NewCRIContainerdService(conn *grpc.ClientConn, rootDir, networkPluginBinDir
117120
imageStoreService: imagesservice.NewStoreFromClient(imagesapi.NewImagesClient(conn)),
118121
contentStoreService: contentservice.NewStoreFromClient(contentapi.NewContentClient(conn)),
119122
rootfsService: rootfsapi.NewRootFSClient(conn),
123+
versionService: versionapi.NewVersionClient(conn),
120124
}
121125

122126
netPlugin, err := ocicni.InitCNI(networkPluginBinDir, networkPluginConfDir)

pkg/server/status.go

Lines changed: 11 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -17,14 +17,22 @@ limitations under the License.
1717
package server
1818

1919
import (
20-
"errors"
21-
2220
"golang.org/x/net/context"
2321

2422
runtime "k8s.io/kubernetes/pkg/kubelet/apis/cri/v1alpha1"
2523
)
2624

2725
// Status returns the status of the runtime.
2826
func (c *criContainerdService) Status(ctx context.Context, r *runtime.StatusRequest) (*runtime.StatusResponse, error) {
29-
return nil, errors.New("not implemented")
27+
runtimeReady := &runtime.RuntimeCondition{
28+
Type: runtime.RuntimeReady,
29+
Status: true,
30+
}
31+
networkReady := &runtime.RuntimeCondition{
32+
Type: runtime.NetworkReady,
33+
Status: true,
34+
}
35+
return &runtime.StatusResponse{
36+
Status: &runtime.RuntimeStatus{Conditions: []*runtime.RuntimeCondition{runtimeReady, networkReady}},
37+
}, nil
3038
}

pkg/server/update_runtime_config.go

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -17,14 +17,12 @@ limitations under the License.
1717
package server
1818

1919
import (
20-
"errors"
21-
2220
"golang.org/x/net/context"
2321

2422
runtime "k8s.io/kubernetes/pkg/kubelet/apis/cri/v1alpha1"
2523
)
2624

2725
// UpdateRuntimeConfig updates the runtime config. Currently only handles podCIDR updates.
2826
func (c *criContainerdService) UpdateRuntimeConfig(ctx context.Context, r *runtime.UpdateRuntimeConfigRequest) (*runtime.UpdateRuntimeConfigResponse, error) {
29-
return nil, errors.New("not implemented")
27+
return &runtime.UpdateRuntimeConfigResponse{}, nil
3028
}

pkg/server/version.go

Lines changed: 23 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -17,14 +17,35 @@ limitations under the License.
1717
package server
1818

1919
import (
20-
"errors"
20+
"fmt"
2121

22+
empty "github.com/golang/protobuf/ptypes/empty"
2223
"golang.org/x/net/context"
2324

2425
runtime "k8s.io/kubernetes/pkg/kubelet/apis/cri/v1alpha1"
2526
)
2627

28+
const (
29+
containerName = "containerd"
30+
containerdAPIVersion = "0.0.0"
31+
containerdVersion = "0.0.0"
32+
// kubeAPIVersion is the api version of kubernetes.
33+
kubeAPIVersion = "0.1.0"
34+
)
35+
2736
// Version returns the runtime name, runtime version and runtime API version.
2837
func (c *criContainerdService) Version(ctx context.Context, r *runtime.VersionRequest) (*runtime.VersionResponse, error) {
29-
return nil, errors.New("not implemented")
38+
_, err := c.versionService.Version(ctx, &empty.Empty{})
39+
if err != nil {
40+
return nil, fmt.Errorf("failed to get containerd version: %v", err)
41+
}
42+
return &runtime.VersionResponse{
43+
Version: kubeAPIVersion,
44+
RuntimeName: containerName,
45+
// Containerd doesn't return semver because of a bug.
46+
// TODO(random-liu): Replace this with version from containerd.
47+
RuntimeVersion: containerdVersion,
48+
// Containerd doesn't have an api version now.
49+
RuntimeApiVersion: containerdAPIVersion,
50+
}, nil
3051
}

0 commit comments

Comments
 (0)