Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Enabling persistPaths in devPod spec always replaces devPod even when there has been no config/podSpec changes #2870

Open
marcm-ml opened this issue Jul 4, 2024 · 2 comments
Labels
kind/bug Something isn't working

Comments

@marcm-ml
Copy link

marcm-ml commented Jul 4, 2024

What happened?

My devPod is always replaced by a new "pod" which is identical to the already running pod. This cause some delay between consecutive devspace dev command which is unecessary as it is the same podSpec. When using --debug I can see a log statement:

Update replaced deployment with patch:
<json patches>

which comes from:

ctx.Log().Debugf("Update replaced deployment with patch:\n %s", string(patchBytes))

There I could identify the root cause which boils down to using persistPaths which adds initContainer to the pods spec. Apparently, these always cause a replacement which I find odd since they did not change between consecutive sessions. This is also true for the config-hash annotations of the deployment resource which stays the same between sessions. The podSpec is also identical but the pod-template-hash annotations changes which causes the replacement in the first place, I would assume.

What did you expect to happen instead?

I expect no replacement to happen if the devspace.yaml config stays the same.

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

Any devspace.yaml wich configures as persistPaths option:

dev:
  dev:
    persistPaths:
      - path: /app
        volumePath: app

Removing the persistPaths fixes the issue and no replacement happens between sessions.
Curiously, for my config it still prints the same log messages and shows me some patches (without initContainers) that are applied but these do not cause the deployment to change and thus do not trigger a replacement.

Local Environment:

  • DevSpace Version: 6.3.12 (but has been observed before as well)
  • Operating System: mac
  • ARCH of the OS: ARM64
    Kubernetes Cluster:
  • Cloud Provider: aws
  • Kubernetes Version: v1.29.4-eks-036c24b

Anything else we need to know?

@marcm-ml marcm-ml added the kind/bug Something isn't working label Jul 4, 2024
@marcm-ml marcm-ml changed the title Enabling persistPaths devPod spec always replaces devPod even when there has been no config change Enabling persistPaths in devPod spec always replaces devPod even when there has been no config/podSpec changes Jul 4, 2024
@marcm-ml
Copy link
Author

marcm-ml commented Jul 4, 2024

taken from the logs and prettified:

Json patches causing replacement:

{
 "spec": {
  "template": {
   "spec": {
    "initContainers": [
     {
      "args": [
       "-c",
       "if [ ! -d \"/devspace-persistence/.devspace/\" ] && [ -d \"/app\" ]; then\n echo 'DevSpace is initializing the sync volume...'\n cp -a /app/. /devspace-persistence/ && mkdir /devspace-persistence/.devspace\nfi"
      ],
      "command": [
       "sh"
      ],
      "image": "python:latest",
      "name": "path-0-init",
      "resources": {},
      "volumeMounts": [
       {
        "mountPath": "/devspace-persistence",
        "name": "devspace-persistence",
        "subPath": "app"
       }
      ]
     },
     {
      "args": [
       "-c",
       "if [ ! -d \"/devspace-persistence/.devspace/\" ] && [ -d \"/root\" ]; then\n echo 'DevSpace is initializing the sync volume...'\n cp -a /root/. /devspace-persistence/ && mkdir /devspace-persistence/.devspace\nfi"
      ],
      "command": [
       "sh"
      ],
      "image": "python:latest",
      "name": "path-1-init",
      "resources": {},
      "volumeMounts": [
       {
        "mountPath": "/devspace-persistence",
        "name": "devspace-persistence",
        "subPath": "user_home"
       }
      ]
     }
    ],
    "securityContext": null
   }
  }
 }
}

Json patches causing NO replacement with disabled persistPaths option:

{
    "metadata": {
        "annotations": {
            "deployment.kubernetes.io/revision": "4"
        }
    },
    "spec": {
        "template": {
            "spec": {
                "securityContext": null
            }
        }
    }
}

@marcm-ml
Copy link
Author

@FabianKramm sorry for the ping but when researching this issue and ways around it, I have come across an old commit from yours: fd99ddf#diff-104ea0e9434e5a0a563d2de4dfc8d255b19fbef07cb2b1d4e22be9b68d1d293eL157-L164

do you remember what the issue was with the previous approach (L157-L164) and why you removed it? Also will anyone work on the issue?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
kind/bug Something isn't working
Projects
None yet
Development

No branches or pull requests

1 participant