alcounit / selenosis

Scalable, stateless selenium hub for Kubernetes cluster
Apache License 2.0
81 stars 24 forks source link

Failed to create pod in case DesiredCapabilities.Name not consist of alphanumeric characters, '-', '_' or '.' #22

Closed alcounit closed 3 years ago

alcounit commented 3 years ago

Pod creation will fail if DesiredCapabilities.Name value not consist of alphanumeric characters, '-', '_' or '.'

{
   "desiredCapabilities":{
      "browserName":"chrome",
      "version":"89.0",
      "enableVNC":true,
      "name":"Test Name"
   },
   "capabilities":{
      "alwaysMatch":{
         "browserName":"chrome",
         "browserVersion":"89.0"
      }
   }
}

log output

time="2021-03-10T11:47:27Z" level=error msg="failed to start browser: failed to create pod Pod \"selenoid-vnc-chrome-89-0-5bcf9045-54d5-47d9-820d-00e8cfcbc250\" is invalid: metadata.labels: Invalid value: \"Test Name\": a valid label must be an empty string or consist of alphanumeric characters, '-', '_' or '.', and must start and end with an alphanumeric character (e.g. 'MyValue',  or 'my_value',  or '12345', regex used for validation is '(([A-Za-z0-9][-A-Za-z0-9_.]*)?[A-Za-z0-9])?')" request="POST /wd/hub/session" request_id=f653b640-a56e-4d67-8650-48a0783f09c0 time_elapsed=0.02s

The same error will occur if pass non-alphanumeric characters as a label value from the config file, according to https://kubernetes.io/docs/concepts/overview/working-with-objects/labels/#syntax-and-character-set