devspace-sh / devspace

DevSpace - The Fastest Developer Tool for Kubernetes ⚡ Automate your deployment workflow with DevSpace and develop software directly inside Kubernetes.
https://devspace.sh
Apache License 2.0
4.19k stars 351 forks source link

Error `fatal exit status 1` while following quickstart for Go in WSL 2 #2793

Open mattwelke opened 5 months ago

mattwelke commented 5 months ago

What happened?

I followed the quickstart tutorial, beginning at https://www.devspace.sh/docs/getting-started/introduction.

I was able to complete Download DevSpace, Initialize Project (I chose the "Golang" tab), and some of Development. I chose all of the default, suggested options.

During the Development step, when I got down to the part of the tutorial where you run devspace dev, I ran this command but then I got an error. The complete terminal output looks like this:

info Using namespace 'my-namespace'
info Using kube context 'kind-kind'
deploy:app Skipping deployment app
dev:app Waiting for pod to become ready...
dev:app Selected pod app-devspace-77d5787fd7-qmn6x
dev:app open  Opening 'http://localhost:8080' as soon as application will be started
dev:app ports Port forwarding started on: 2345 -> 2345, 8080 -> 8080
dev:app sync  Sync started on: ./ <-> ./
dev:app sync  Waiting for initial sync to complete
dev:app sync  Initial sync completed
start_dev: initial sync: Sync - connection lost to pod my-namespace/app-devspace-77d5787fd7-qmn6x:  Internal error occurred: error executing command in container: failed to exec in container: failed to start exec "73f6f2b1a1ee625eb5aab114398a48df173c6849091a0d0c0ccec3064b5b73d9": OCI runtime exec failed: exec failed: unable to start container process: error adding pid 2215 to cgroups: failed to write 2215: openat2 /sys/fs/cgroup/unified/kubelet.slice/kubelet-kubepods.slice/kubelet-kubepods-besteffort.slice/kubelet-kubepods-besteffort-pode3996f97_63f0_40a0_b9c6_86de954b019c.slice/cri-containerd-2646276dddc66c0bc8f14ccc3ca9ee8484f9da56c005c952ce9ea357d6dd6c66.scope/cgroup.procs: no such file or directory: unknown
fatal exit status 1

At this point in time, there is a container that exists and is in a Running state

> k get po
NAME                            READY   STATUS    RESTARTS   AGE
app-devspace-77d5787fd7-qmn6x   1/1     Running   0          17m

But I'm not sure what to do at this point because my terminal has had control returned to it and based on language used in the quickstart, I don't think this is what's supposed to happen:

Once the terminal to your dev container opens

What did you expect to happen instead?

I expected to be able to complete the quickstart tutorial.

I also expected, based on my experience using DevSpace on my work machine, where it was already set up for me by a colleague, that at some point, I would have a terminal into a dev container open, but this didn't happen.

How can we reproduce the bug? (as minimally and precisely as possible)

Follow the steps I described above to attempt to complete the quickstart tutorial, choosing Go as your programming language. Observe the output from devspace dev.

My devspace.yaml:

version: v2beta1
name: devspace-quickstart-golang

# This is a list of `pipelines` that DevSpace can execute (you can define your own)
pipelines:
  # This is the pipeline for the main command: `devspace dev` (or `devspace run-pipeline dev`)
  dev:
    run: |-
      run_dependencies --all       # 1. Deploy any projects this project needs (see "dependencies")
      ensure_pull_secrets --all    # 2. Ensure pull secrets
      create_deployments --all     # 3. Deploy Helm charts and manifests specfied as "deployments"
      start_dev app                # 4. Start dev mode "app" (see "dev" section)
  # You can run this pipeline via `devspace deploy` (or `devspace run-pipeline deploy`)
  deploy:
    run: |-
      run_dependencies --all                            # 1. Deploy any projects this project needs (see "dependencies")
      ensure_pull_secrets --all                         # 2. Ensure pull secrets
      build_images --all -t $(git describe --always)    # 3. Build, tag (git commit hash) and push all images (see "images")
      create_deployments --all                          # 4. Deploy Helm charts and manifests specfied as "deployments"

# This is a list of `images` that DevSpace can build for this project
# We recommend to skip image building during development (devspace dev) as much as possible
images:
  app:
    image: my-image-registry.tld/username/app
    dockerfile: ./Dockerfile

# This is a list of `deployments` that DevSpace can create for this project
deployments:
  app:
    # This deployment uses `helm` but you can also define `kubectl` deployments or kustomizations
    helm:
      # We are deploying this project with the Helm chart you provided
      chart:
        name: component-chart
        repo: https://charts.devspace.sh
      # Under `values` we can define the values for this Helm chart used during `helm install/upgrade`
      # You may also use `valuesFiles` to load values from files, e.g. valuesFiles: ["values.yaml"]
      values:
        containers:
          - image: my-image-registry.tld/username/app
        service:
          ports:
            - port: 8080

# This is a list of `dev` containers that are based on the containers created by your deployments
dev:
  app:
    # Search for the container that runs this image
    imageSelector: my-image-registry.tld/username/app
    # Replace the container image with this dev-optimized image (allows to skip image building during development)
    devImage: ghcr.io/loft-sh/devspace-containers/go:1.18-alpine
    # Sync files between the local filesystem and the development container
    sync:
      - path: ./
        uploadExcludeFile: .dockerignore
    # Open a terminal and use the following command to start it
    terminal:
      command: ./devspace_start.sh
    # Inject a lightweight SSH server into the container (so your IDE can connect to the remote dev env)
    ssh:
      enabled: true
    # Make the following commands from my local machine available inside the dev container
    proxyCommands:
      - command: devspace
      - command: kubectl
      - command: helm
      - gitCredentials: true
    # Forward the following ports to be able access your application via localhost
    ports:
      - port: "2345"
      - port: "8080"
    # Open the following URLs once they return an HTTP status code other than 502 or 503
    open:
      - url: http://localhost:8080

# Use the `commands` section to define repeatable dev workflows for this project
commands:
  migrate-db:
    command: |-
      echo 'This is a cross-platform, shared command that can be used to codify any kind of dev task.'
      echo 'Anyone using this project can invoke it via "devspace run migrate-db"'

# Define dependencies to other projects with a devspace.yaml
# dependencies:
#   api:
#     git: https://...  # Git-based dependencies
#     tag: v1.0.0
#   ui:
#     path: ./ui        # Path-based dependencies (for monorepos)

Local Environment:

Kubernetes Cluster:

Anything else we need to know?

I suspect that the fact I'm running this with WSL 2 is related to this issue. But I have not yet tested this in a different OS so I have not yet confirmed that WSL 2 is the only way of using Linux that causes this problem.

mattwelke commented 5 months ago

Tested with Ubuntu by itself (no WSL) and found that the issue did not occur then. I was able to launch the pod, get a terminal into the container, and test it out where I made a change to the code, re-ran go run main.go, refresh my browser, and see my changes reflected.

Local Environment:

Kubernetes Cluster: