Skip to content

Commit

Permalink
Use containerd version returned by version service.
Browse files Browse the repository at this point in the history
Signed-off-by: Lantao Liu <lantaol@google.com>
  • Loading branch information
Random-Liu committed Jun 7, 2017
1 parent d094968 commit f770d4f
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 12 deletions.
11 changes: 4 additions & 7 deletions pkg/server/version.go
Expand Up @@ -28,23 +28,20 @@ import (
const (
containerName = "containerd"
containerdAPIVersion = "0.0.0"
containerdVersion = "0.0.0"
// kubeAPIVersion is the api version of kubernetes.
kubeAPIVersion = "0.1.0"
)

// Version returns the runtime name, runtime version and runtime API version.
func (c *criContainerdService) Version(ctx context.Context, r *runtime.VersionRequest) (*runtime.VersionResponse, error) {
_, err := c.versionService.Version(ctx, &empty.Empty{})
resp, err := c.versionService.Version(ctx, &empty.Empty{})
if err != nil {
return nil, fmt.Errorf("failed to get containerd version: %v", err)
}
return &runtime.VersionResponse{
Version: kubeAPIVersion,
RuntimeName: containerName,
// Containerd doesn't return semver because of a bug.
// TODO(random-liu): Replace this with version from containerd.
RuntimeVersion: containerdVersion,
Version: kubeAPIVersion,
RuntimeName: containerName,
RuntimeVersion: resp.Version,
// Containerd doesn't have an api version now.
RuntimeApiVersion: containerdAPIVersion,
}, nil
Expand Down
15 changes: 10 additions & 5 deletions pkg/server/version_test.go
Expand Up @@ -35,9 +35,10 @@ func TestVersion(t *testing.T) {
defer ctrl.Finish()
// TODO(random-liu): Check containerd version after containerd fixes its version.
for desc, test := range map[string]struct {
versionRes *versionapi.VersionResponse
versionErr error
expectErr bool
versionRes *versionapi.VersionResponse
versionErr error
expectErr bool
expectedVersion string
}{
"should return error if containerd version returns error": {
versionErr: errors.New("random error"),
Expand All @@ -55,7 +56,11 @@ func TestVersion(t *testing.T) {
mock.EXPECT().Version(ctx, &empty.Empty{}).Return(test.versionRes, test.versionErr)

c.versionService = mock
_, err := c.Version(ctx, &runtime.VersionRequest{})
assert.Equal(t, test.expectErr, err != nil)
v, err := c.Version(ctx, &runtime.VersionRequest{})
if test.expectErr {
assert.Equal(t, test.expectErr, err != nil)
} else {
assert.Equal(t, test.versionRes.Version, v.RuntimeVersion)
}
}
}

0 comments on commit f770d4f

Please sign in to comment.