server: use grpc getters to avoid panics
Signed-off-by: Antonio Murdaca <runcom@redhat.com>
This commit is contained in:
parent
41aaf4e3d8
commit
8c190a683c
2 changed files with 14 additions and 6 deletions
|
@ -562,7 +562,11 @@ func (s *Server) CreateContainer(ctx context.Context, req *pb.CreateContainerReq
|
||||||
return nil, fmt.Errorf("CreateContainerRequest.ContainerConfig is nil")
|
return nil, fmt.Errorf("CreateContainerRequest.ContainerConfig is nil")
|
||||||
}
|
}
|
||||||
|
|
||||||
name := containerConfig.GetMetadata().Name
|
if containerConfig.GetMetadata() == nil {
|
||||||
|
return nil, fmt.Errorf("CreateContainerRequest.ContainerConfig.Metadata is nil")
|
||||||
|
}
|
||||||
|
|
||||||
|
name := containerConfig.GetMetadata().GetName()
|
||||||
if name == "" {
|
if name == "" {
|
||||||
return nil, fmt.Errorf("CreateContainerRequest.ContainerConfig.Name is empty")
|
return nil, fmt.Errorf("CreateContainerRequest.ContainerConfig.Name is empty")
|
||||||
}
|
}
|
||||||
|
|
|
@ -101,16 +101,20 @@ func (s *Server) RunPodSandbox(ctx context.Context, req *pb.RunPodSandboxRequest
|
||||||
s.updateLock.RLock()
|
s.updateLock.RLock()
|
||||||
defer s.updateLock.RUnlock()
|
defer s.updateLock.RUnlock()
|
||||||
|
|
||||||
|
if req.GetConfig().GetMetadata() == nil {
|
||||||
|
return nil, fmt.Errorf("CreateContainerRequest.ContainerConfig.Metadata is nil")
|
||||||
|
}
|
||||||
|
|
||||||
logrus.Debugf("RunPodSandboxRequest %+v", req)
|
logrus.Debugf("RunPodSandboxRequest %+v", req)
|
||||||
var processLabel, mountLabel, resolvPath string
|
var processLabel, mountLabel, resolvPath string
|
||||||
// process req.Name
|
// process req.Name
|
||||||
kubeName := req.GetConfig().GetMetadata().Name
|
kubeName := req.GetConfig().GetMetadata().GetName()
|
||||||
if kubeName == "" {
|
if kubeName == "" {
|
||||||
return nil, fmt.Errorf("PodSandboxConfig.Name should not be empty")
|
return nil, fmt.Errorf("PodSandboxConfig.Name should not be empty")
|
||||||
}
|
}
|
||||||
|
|
||||||
namespace := req.GetConfig().GetMetadata().Namespace
|
namespace := req.GetConfig().GetMetadata().GetNamespace()
|
||||||
attempt := req.GetConfig().GetMetadata().Attempt
|
attempt := req.GetConfig().GetMetadata().GetAttempt()
|
||||||
|
|
||||||
id, name, err := s.generatePodIDandName(req.GetConfig())
|
id, name, err := s.generatePodIDandName(req.GetConfig())
|
||||||
if err != nil {
|
if err != nil {
|
||||||
|
@ -156,8 +160,8 @@ func (s *Server) RunPodSandbox(ctx context.Context, req *pb.RunPodSandboxRequest
|
||||||
name, id,
|
name, id,
|
||||||
s.config.PauseImage, "",
|
s.config.PauseImage, "",
|
||||||
containerName,
|
containerName,
|
||||||
req.GetConfig().GetMetadata().Name,
|
req.GetConfig().GetMetadata().GetName(),
|
||||||
req.GetConfig().GetMetadata().Uid,
|
req.GetConfig().GetMetadata().GetUid(),
|
||||||
namespace,
|
namespace,
|
||||||
attempt,
|
attempt,
|
||||||
nil)
|
nil)
|
||||||
|
|
Loading…
Reference in a new issue