Skip to content

BuildGrid doesn't exit at all when it can't bind to its port

Context

Expected behavior

BuildGrid should exit non-zero when it cannot bind to its port.

Current behavior

BuildGrid keeps "running" when it cannot bind to a port due to:

  1. a permissions issue
  2. port already in use

Steps to reproduce

  1. Use a port that requires elevated permissions to bind to (e.g. <1024) and try to run buildgrid.
  2. Run buildgrid on a port that it can bind to. Then try to run buildgrid again with the same config file.

Relevant Logs

1. No permissions to bind port (88, here)
Click to expand
bgd server start config.yml
INFO:buildgrid.server.instance:Adding insecure connection on [[::]:88]
2018-11-13 14:48:50,604 - buildgrid.server.instance - INFO - Adding insecure connection on [[::]:88]
E1113 14:48:50.604842429   32128 server_chttp2.cc:40]

(beautified output JSON)

{
  "created": "@1542138530.604789678",
  "description": "No address added out of total 1 resolved",
  "file": "src/core/ext/transport/chttp2/server/chttp2_server.cc",
  "file_line": 307,
  "referenced_errors": [
    {
      "created": "@1542138530.604786184",
      "description": "Failed to add any wildcard listeners",
      "file": "src/core/lib/iomgr/tcp_server_posix.cc",
      "file_line": 324,
      "referenced_errors": [
        {
          "created": "@1542138530.604737500",
          "description": "Unable to configure socket",
          "fd": 5,
          "file": "src/core/lib/iomgr/tcp_server_utils_posix_common.cc",
          "file_line": 217,
          "referenced_errors": [
            {
              "created": "@1542138530.604731168",
              "description": "OS Error",
              "errno": 13,
              "file": "src/core/lib/iomgr/tcp_server_utils_posix_common.cc",
              "file_line": 190,
              "os_error": "Permission denied",
              "syscall": "bind"
            }
          ]
        },
        {
          "created": "@1542138530.604784581",
          "description": "Unable to configure socket",
          "fd": 5,
          "file": "src/core/lib/iomgr/tcp_server_utils_posix_common.cc",
          "file_line": 217,
          "referenced_errors": [
            {
              "created": "@1542138530.604778541",
              "description": "OS Error",
              "errno": 13,
              "file": "src/core/lib/iomgr/tcp_server_utils_posix_common.cc",
              "file_line": 190,
              "os_error": "Permission denied",
              "syscall": "bind"
            }
          ]
        }
      ]
    }
  ]
}
2. Port already in use (permissions OK, port 8812 here)
Click to expand
bgd server start config.yml
INFO:buildgrid.server.instance:Adding insecure connection on [[::]:8812]
2018-11-13 14:55:52,636 - buildgrid.server.instance - INFO - Adding insecure connection on [[::]:8812]

(beautified output JSON)

{
  "created": "@1542138952.636514878",
  "description": "No address added out of total 1 resolved",
  "file": "src/core/ext/transport/chttp2/server/chttp2_server.cc",
  "file_line": 307,
  "referenced_errors": [
    {
      "created": "@1542138952.636510623",
      "description": "Failed to add any wildcard listeners",
      "file": "src/core/lib/iomgr/tcp_server_posix.cc",
      "file_line": 324,
      "referenced_errors": [
        {
          "created": "@1542138952.636476149",
          "description": "Unable to configure socket",
          "fd": 5,
          "file": "src/core/lib/iomgr/tcp_server_utils_posix_common.cc",
          "file_line": 217,
          "referenced_errors": [
            {
              "created": "@1542138952.636468854",
              "description": "OS Error",
              "errno": 98,
              "file": "src/core/lib/iomgr/tcp_server_utils_posix_common.cc",
              "file_line": 190,
              "os_error": "Address already in use",
              "syscall": "bind"
            }
          ]
        },
        {
          "created": "@1542138952.636509221",
          "description": "Unable to configure socket",
          "fd": 5,
          "file": "src/core/lib/iomgr/tcp_server_utils_posix_common.cc",
          "file_line": 217,
          "referenced_errors": [
            {
              "created": "@1542138952.636503975",
              "description": "OS Error",
              "errno": 98,
              "file": "src/core/lib/iomgr/tcp_server_utils_posix_common.cc",
              "file_line": 190,
              "os_error": "Address already in use",
              "syscall": "bind"
            }
          ]
        }
      ]
    }
  ]
}

Task Description & Acceptance Criteria

BuildGrid exits non-zero when it cannot bind to its port for any reason.

Edited by Marios Hadjimichael