tilt-dev / tilt-extensions

Extensions for Tilt
https://tilt.dev/
Apache License 2.0
201 stars 159 forks source link

helm_resource forces update by uninstalling release everytime #512

Closed ck3mp3r closed 9 months ago

ck3mp3r commented 1 year ago

When releasing via helm_resource there should be an option available to not force an uninstall before deploying. Looking at the output logs it is running upgrade --install during the release, hence the chart is always upgraded and if not present will be installed.

Add an option to disable/enable the force delete before deploy.

nicks commented 1 year ago

Can you give some repro steps?

As far as I can tell, helm upgrade --install does not do any force update / force delete. It diffs against what's installed and does a 3-way merge. if nothing has changed, nothing restarts.

I verified this with

git clone git@github.com:tilt-dev/tilt-extensions
cd tilt-extensions/helm_resource/test
tilt ci
kubectl get pods -lapp.kubernetes.io/name=memcached -o yaml | grep -e "resourceVersion"
tilt ci
kubectl get pods -lapp.kubernetes.io/name=memcached -o yaml | grep -e "resourceVersion"

and confirmed the pod didn't change

ck3mp3r commented 1 year ago

That would be the case is this was the only command that was run. The following definition in my Tiltfile:

helm_resource(
  'oam-local',
  'oam/charts/oam-local',
  namespace='vela-system',
  resource_deps=['vela-core'],
  auto_init=False
)

causes the following output:

Web Trigger
STEP 1/2 — Force update
     Beginning force update
     Running cmd: python3 /Users/christian/.local/share/tilt-dev/tilt_modules/github.com/tilt-dev/tilt-extensions/helm_resource/helm-delete-helper.py

STEP 2/2 — Deploying
     Running cmd: python3 /Users/christian/.local/share/tilt-dev/tilt_modules/github.com/tilt-dev/tilt-extensions/helm_resource/helm-apply-helper.py
     Running cmd: ['helm', 'upgrade', '--install', '--namespace', 'vela-system', 'oam-local', 'oam/charts/oam-local']
     Release "oam-local" does not exist. Installing it now.
     NAME: oam-local
     LAST DEPLOYED: Wed Jun 28 17:15:12 2023
     NAMESPACE: vela-system
     STATUS: deployed
     REVISION: 1
     TEST SUITE: None
     Running cmd: ['helm', 'get', 'manifest', '--namespace', 'vela-system', 'oam-local']
     Running cmd: ['kubectl', 'get', '-oyaml', '-f', '-']
     Objects applied to cluster:
       → pulsar-cluster:componentdefinition
       → postgres:traitdefinition
       → pulsar-namespace:traitdefinition
       → pulsar-topic:traitdefinition

     Step 1 - 0.08s (Force update)
     Step 2 - 1.11s (Deploying)
     DONE IN: 1.19s 

My current workaround for another chart that has quite a heavy deployment is just to run it as a local_resource...

ck3mp3r commented 9 months ago

Any progress on this?

nicks commented 9 months ago

nothing in the output above did a force uninstall or force delete. what am i missing?

ck3mp3r commented 9 months ago

What does this script in Step 1 do? Running cmd: python3 /Users/christian/.local/share/tilt-dev/tilt_modules/github.com/tilt-dev/tilt-extensions/helm_resource/helm-delete-helper.py

As I already alluded to above, a normal local_resource call with just helm update --install does the trick.

nicks commented 9 months ago

oops, my bad, i misunderstood your message.

yes, clicking the "force update" button will delete the workload before reinstalling. This happens for all workloads, not just helm.

normal deploys (running tilt up, modifying a file) will update the resource in-place. closing this as working as intended