jupyterhub / binderhub

Run your code in the cloud, with technology so advanced, it feels like magic!
https://binderhub.readthedocs.io
BSD 3-Clause "New" or "Revised" License
2.54k stars 388 forks source link

ci: indentation failure - why!? #1701

Closed consideRatio closed 1 year ago

consideRatio commented 1 year ago

We error in the k8s 1.26 / main test, because the built pod can fail to startup because of an indentation error in singleuser.cmd.

image

But we don't have an indentation error in the provided config:

https://github.com/jupyterhub/binderhub/blob/9cdae11b6671d87b4355534d3edeedfac0a26774/helm-chart/binderhub/values.yaml#L213-L231

Yet we have it in the pod based on k8s namespace report: image


Is the singleuser.cmd processed in any way by us or helm making this happen? Is variable expansion involved adding a space or similar?

manics commented 1 year ago

It's fine on main https://github.com/jupyterhub/binderhub/actions/runs/5045025696/jobs/9048789662 Does it happen everytime on https://github.com/jupyterhub/binderhub/pull/1697 ?

consideRatio commented 1 year ago

I think so, it mayyyyyy be related to rebuilding the image if its failing there, which makes chartpress do things it otherwise may not do.

consideRatio commented 1 year ago

Okay this is what goes wrong:

https://github.com/jupyterhub/binderhub/blob/2b824a55f4193f5a47c4d150dbe7bb89277a3b68/testing/local-binder-k8s-hub/install-jupyterhub-chart#L38-L39

Apparently this file dump doesn't represent the original YAML content.

consideRatio commented 1 year ago

From the binderhub repo's folder, this returns correct indentation (with non-critical indentation mistakes in the original python code) - so reading data is fine.

    import os
    from ruamel import yaml

    with open(os.path.join("helm-chart", "binderhub", "values.yaml")) as values_in:
        read_values = yaml.safe_load(values_in)

    print(read_values["jupyterhub"]["singleuser"]["cmd"][2])
import os
import sys

try:
    import jupyterlab
    import jupyterlab.labapp
    major = int(jupyterlab.__version__.split(".", 1)[0])
except Exception as e:
    print("Failed to import jupyterlab: {e}", file=sys.stderr)
    have_lab = False
else:
    have_lab = major >= 3

if have_lab:
  # technically, we could accept another jupyter-server-based frontend
  print("Launching jupyter-lab", file=sys.stderr)
  exe = "jupyter-lab"
else:
  print("jupyter-lab not found, launching jupyter-notebook", file=sys.stderr)
  exe = "jupyter-notebook"

# launch the notebook server
os.execvp(exe, sys.argv)
consideRatio commented 1 year ago

Reading, writing, and then makes it reproduce the issue. Since helm is reading it later, I presume that the writing is to blame.

import os
from ruamel import yaml

with open(os.path.join("helm-chart", "binderhub", "values.yaml")) as values_in:
    read_values = yaml.safe_load(values_in)
print(read_values["jupyterhub"]["singleuser"]["cmd"][2])

with open("dump.yaml", "w") as values_out:
    yaml.safe_dump(read_values["jupyterhub"], values_out)

with open("dump.yaml") as values_in_again:
    read_values = yaml.safe_load(values_in_again)
print(read_values["singleuser"]["cmd"][2])