tilt icon indicating copy to clipboard operation
tilt copied to clipboard

helm() file watches can't be undone with watch_settings

Open bcotton opened this issue 1 year ago • 3 comments

Expected Behavior

After creating a helm settings file on disk from within the Tiltfile, then passing it to helm., the Tiltfile is re-creats the settings file everytime the Tiltfile is changed. The existing filewatch from helm() gets triggered on the settings file, causing the Tilefile to be reloaded in an infinite loop.

To stop this behavior, I tried using watching_setting(ignore=...), but it seems to be ignored.

Current Behavior

In the test case below, changes to the Tiltfile or the settings file causes an infinite reload of the Tiltfile.

Steps to Reproduce

Use this Tiltfile:

load('ext://helm_remote', 'helm_remote')

chart_values = {
    'replicaCount': 2
}

rendered_values = os.path.dirname(os.getenv("TMPDIR")) + '/rendered-values.yaml'
local('cat > %s' % rendered_values,
        stdin=encode_yaml(chart_values),
        echo_off=True,
        quiet=True)

helm_remote('hello', values=rendered_values, repo_name='cloudecho', repo_url='https://cloudecho.github.io/charts/')
watch_settings(ignore=rendered_values)

  1. touch/change either the Tiltfile or the settings file

Context

tilt doctor Output

$ tilt doctor
Tilt: v0.32.4, built 2023-05-24
System: darwin-arm64
---
Docker
- Host: unix:///Users/bcotton/.docker/run/docker.sock
- Server Version: 20.10.21
- API Version: 1.41
- Builder: 2
- Compose Version: v2.12.2
---
Kubernetes
- Env: kind
- Context: kind-kind
- Cluster Name: kind-kind
- Namespace: default
- Container Runtime: containerd
- Version: v1.26.0
- Cluster Local Registry: &RegistryHosting{Host:localhost:49648,HostFromClusterNetwork:ctlptl-registry:5000,HostFromContainerRuntime:,Help:https://github.com/tilt-dev/ctlptl,SingleName:,}
---
Thanks for seeing the Tilt Doctor!
Please send the info above when filing bug reports. 💗

The info below helps us understand how you're using Tilt so we can improve,
but is not required to ask for help.
---
Analytics Settings
--> (These results reflect your personal opt in/out status and may be overridden by an `analytics_settings` call in your Tiltfile)
- User Mode: opt-in
- Machine: 5e9db8c45fdc6566d854189ae97e86bc
- Repo:
...

About Your Use Case

bcotton avatar Aug 17 '23 22:08 bcotton

does it work if you do:

rendered_values = os.path.realpath(os.path.dirname(os.getenv("TMPDIR")) + '/rendered-values.yaml')

?

note the realpath wrapper

my hunch is that this is an artifact of how:

  • macos loves to jam symlinks in tmpdirs
  • macos hates when there are symlinks in fsevents dirs

nicks avatar Aug 17 '23 22:08 nicks

Yes, that does work. the temp file is no longer being watched.

bcotton avatar Aug 18 '23 03:08 bcotton

If you don't ignore the file watch, it will loop. For a generated file that MUST be on disk, I guess that's ok.

bcotton avatar Aug 18 '23 03:08 bcotton