Merge pull request #7108 from fuweid/refactor-cri-api
pkg/cri: use marshal wrapper for version convertor
This commit is contained in:
commit
aee50aeac2
@ -1577,29 +1577,24 @@ func (in *instrumentedAlphaService) ReopenContainerLog(ctx context.Context, r *r
|
|||||||
}
|
}
|
||||||
}()
|
}()
|
||||||
// converts request and response for earlier CRI version to call and get response from the current version
|
// converts request and response for earlier CRI version to call and get response from the current version
|
||||||
p, err := r.Marshal()
|
var v1r runtime.ReopenContainerLogRequest
|
||||||
if err == nil {
|
if err := alphaReqToV1Req(r, &v1r); err != nil {
|
||||||
var v1r runtime.ReopenContainerLogRequest
|
return nil, errdefs.ToGRPC(err)
|
||||||
if err = v1r.Unmarshal(p); err == nil {
|
}
|
||||||
var v1res *runtime.ReopenContainerLogResponse
|
var v1res *runtime.ReopenContainerLogResponse
|
||||||
v1res, err = in.c.ReopenContainerLog(ctrdutil.WithNamespace(ctx), &v1r)
|
v1res, err = in.c.ReopenContainerLog(ctrdutil.WithNamespace(ctx), &v1r)
|
||||||
if v1res != nil {
|
if v1res != nil {
|
||||||
p, perr := v1res.Marshal()
|
resp := &runtime_alpha.ReopenContainerLogResponse{}
|
||||||
if perr == nil {
|
perr := v1RespToAlphaResp(v1res, resp)
|
||||||
resp := &runtime_alpha.ReopenContainerLogResponse{}
|
if perr == nil {
|
||||||
if perr = resp.Unmarshal(p); perr == nil {
|
res = resp
|
||||||
res = resp
|
} else {
|
||||||
}
|
// actual error has precidence on error returned vs parse error issues
|
||||||
}
|
if err == nil {
|
||||||
// actual error has precidence on error returned vs parse error issues
|
err = perr
|
||||||
if perr != nil {
|
} else {
|
||||||
if err == nil {
|
// extra log entry if convert response parse error and request error
|
||||||
err = perr
|
log.G(ctx).WithError(perr).Errorf("ReopenContainerLog for %q failed", r.GetContainerId())
|
||||||
} else {
|
|
||||||
// extra log entry if convert response parse error and request error
|
|
||||||
log.G(ctx).WithError(perr).Errorf("ReopenContainerLog for %q failed", r.GetContainerId())
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user