pkg/cri: use marshal wrapper for version convertor
Use wrapper for ReopenContainerLog v1alpha proto. Ref: #5619 Signed-off-by: Wei Fu <fuweid89@gmail.com>
This commit is contained in:
parent
36bd4a5178
commit
c2703c08c9
@ -1577,22 +1577,19 @@ 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
|
||||
p, err := r.Marshal()
|
||||
if err == nil {
|
||||
var v1r runtime.ReopenContainerLogRequest
|
||||
if err = v1r.Unmarshal(p); err == nil {
|
||||
if err := alphaReqToV1Req(r, &v1r); err != nil {
|
||||
return nil, errdefs.ToGRPC(err)
|
||||
}
|
||||
var v1res *runtime.ReopenContainerLogResponse
|
||||
v1res, err = in.c.ReopenContainerLog(ctrdutil.WithNamespace(ctx), &v1r)
|
||||
if v1res != nil {
|
||||
p, perr := v1res.Marshal()
|
||||
if perr == nil {
|
||||
resp := &runtime_alpha.ReopenContainerLogResponse{}
|
||||
if perr = resp.Unmarshal(p); perr == nil {
|
||||
perr := v1RespToAlphaResp(v1res, resp)
|
||||
if perr == nil {
|
||||
res = resp
|
||||
}
|
||||
}
|
||||
} else {
|
||||
// actual error has precidence on error returned vs parse error issues
|
||||
if perr != nil {
|
||||
if err == nil {
|
||||
err = perr
|
||||
} else {
|
||||
@ -1601,8 +1598,6 @@ func (in *instrumentedAlphaService) ReopenContainerLog(ctx context.Context, r *r
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
return res, errdefs.ToGRPC(err)
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user