Merge pull request #542 from runcom/port-forward-panic

[e2e fix] server: fix PortForward panic
This commit is contained in:
Mrunal Patel 2017-05-28 11:40:17 -07:00 committed by GitHub
commit 988f29fae8
2 changed files with 8 additions and 2 deletions

View file

@ -26,8 +26,8 @@ func (s *Server) PortForward(ctx context.Context, req *pb.PortForwardRequest) (*
return resp, nil return resp, nil
} }
func (ss streamService) PortForward(podInfraContainerID string, port int32, stream io.ReadWriteCloser) error { func (ss streamService) PortForward(podSandboxID string, port int32, stream io.ReadWriteCloser) error {
c := ss.runtimeServer.state.containers.Get(podInfraContainerID) c := ss.runtimeServer.GetSandboxContainer(podSandboxID)
if err := ss.runtimeServer.runtime.UpdateStatus(c); err != nil { if err := ss.runtimeServer.runtime.UpdateStatus(c); err != nil {
return err return err

View file

@ -672,6 +672,12 @@ func (s *Server) getContainer(id string) *oci.Container {
return c return c
} }
// GetSandboxContainer returns the infra container for a given sandbox
func (s *Server) GetSandboxContainer(id string) *oci.Container {
sb := s.getSandbox(id)
return sb.infraContainer
}
func (s *Server) removeContainer(c *oci.Container) { func (s *Server) removeContainer(c *oci.Container) {
s.stateLock.Lock() s.stateLock.Lock()
sandbox := s.state.sandboxes[c.Sandbox()] sandbox := s.state.sandboxes[c.Sandbox()]