Skip to content

Commit 14962dc

Browse files
committed
add alpha version
Signed-off-by: Mike Brown <[email protected]>
1 parent a5c417a commit 14962dc

2 files changed

Lines changed: 12 additions & 27 deletions

File tree

pkg/cri/server/instrumented_service.go

Lines changed: 1 addition & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -1509,33 +1509,7 @@ func (in *instrumentedAlphaService) Version(ctx context.Context, r *runtime_alph
15091509
log.G(ctx).Tracef("Version returns %+v", res)
15101510
}
15111511
}()
1512-
// converts request and response for earlier CRI version to call and get response from the current version
1513-
p, err := r.Marshal()
1514-
if err == nil {
1515-
var v1r runtime.VersionRequest
1516-
if err = v1r.Unmarshal(p); err == nil {
1517-
var v1res *runtime.VersionResponse
1518-
v1res, err = in.c.Version(ctrdutil.WithNamespace(ctx), &v1r)
1519-
if v1res != nil {
1520-
p, perr := v1res.Marshal()
1521-
if perr == nil {
1522-
resp := &runtime_alpha.VersionResponse{}
1523-
if perr = resp.Unmarshal(p); perr == nil {
1524-
res = resp
1525-
}
1526-
}
1527-
// actual error has precidence on error returned vs parse error issues
1528-
if perr != nil {
1529-
if err == nil {
1530-
err = perr
1531-
} else {
1532-
// extra log entry if convert response parse error and request error
1533-
log.G(ctx).WithError(perr).Error("Version failed")
1534-
}
1535-
}
1536-
}
1537-
}
1538-
}
1512+
res, err = in.c.AlphaVersion(ctrdutil.WithNamespace(ctx), r)
15391513
return res, errdefs.ToGRPC(err)
15401514
}
15411515

pkg/cri/server/version.go

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,7 @@ import (
2020
"github.com/containerd/containerd/version"
2121
"golang.org/x/net/context"
2222
runtime "k8s.io/cri-api/pkg/apis/runtime/v1"
23+
runtime_alpha "k8s.io/cri-api/pkg/apis/runtime/v1alpha2"
2324

2425
"github.com/containerd/containerd/pkg/cri/constants"
2526
)
@@ -40,3 +41,13 @@ func (c *criService) Version(ctx context.Context, r *runtime.VersionRequest) (*r
4041
RuntimeApiVersion: constants.CRIVersion,
4142
}, nil
4243
}
44+
45+
// Version returns the runtime name, runtime version and runtime API version.
46+
func (c *criService) AlphaVersion(ctx context.Context, r *runtime_alpha.VersionRequest) (*runtime_alpha.VersionResponse, error) {
47+
return &runtime_alpha.VersionResponse{
48+
Version: kubeAPIVersion,
49+
RuntimeName: containerName,
50+
RuntimeVersion: version.Version,
51+
RuntimeApiVersion: constants.CRIVersionAlpha,
52+
}, nil
53+
}

0 commit comments

Comments
 (0)