add alpha version
Signed-off-by: Mike Brown <brownwm@us.ibm.com>
This commit is contained in:
parent
a5c417ac06
commit
14962dcbd2
@ -1509,33 +1509,7 @@ func (in *instrumentedAlphaService) Version(ctx context.Context, r *runtime_alph
|
||||
log.G(ctx).Tracef("Version returns %+v", res)
|
||||
}
|
||||
}()
|
||||
// converts request and response for earlier CRI version to call and get response from the current version
|
||||
p, err := r.Marshal()
|
||||
if err == nil {
|
||||
var v1r runtime.VersionRequest
|
||||
if err = v1r.Unmarshal(p); err == nil {
|
||||
var v1res *runtime.VersionResponse
|
||||
v1res, err = in.c.Version(ctrdutil.WithNamespace(ctx), &v1r)
|
||||
if v1res != nil {
|
||||
p, perr := v1res.Marshal()
|
||||
if perr == nil {
|
||||
resp := &runtime_alpha.VersionResponse{}
|
||||
if perr = resp.Unmarshal(p); perr == nil {
|
||||
res = resp
|
||||
}
|
||||
}
|
||||
// actual error has precidence on error returned vs parse error issues
|
||||
if perr != nil {
|
||||
if err == nil {
|
||||
err = perr
|
||||
} else {
|
||||
// extra log entry if convert response parse error and request error
|
||||
log.G(ctx).WithError(perr).Error("Version failed")
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
res, err = in.c.AlphaVersion(ctrdutil.WithNamespace(ctx), r)
|
||||
return res, errdefs.ToGRPC(err)
|
||||
}
|
||||
|
||||
|
@ -20,6 +20,7 @@ import (
|
||||
"github.com/containerd/containerd/version"
|
||||
"golang.org/x/net/context"
|
||||
runtime "k8s.io/cri-api/pkg/apis/runtime/v1"
|
||||
runtime_alpha "k8s.io/cri-api/pkg/apis/runtime/v1alpha2"
|
||||
|
||||
"github.com/containerd/containerd/pkg/cri/constants"
|
||||
)
|
||||
@ -40,3 +41,13 @@ func (c *criService) Version(ctx context.Context, r *runtime.VersionRequest) (*r
|
||||
RuntimeApiVersion: constants.CRIVersion,
|
||||
}, nil
|
||||
}
|
||||
|
||||
// Version returns the runtime name, runtime version and runtime API version.
|
||||
func (c *criService) AlphaVersion(ctx context.Context, r *runtime_alpha.VersionRequest) (*runtime_alpha.VersionResponse, error) {
|
||||
return &runtime_alpha.VersionResponse{
|
||||
Version: kubeAPIVersion,
|
||||
RuntimeName: containerName,
|
||||
RuntimeVersion: version.Version,
|
||||
RuntimeApiVersion: constants.CRIVersionAlpha,
|
||||
}, nil
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user