tilt-dev / tilt-extensions

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

helm_remote fails on duplicate CRDs fails on lunix but not mac. #484

Open mikhail-khodorovskiy opened 1 year ago

mikhail-khodorovskiy commented 1 year ago
istio_version = "1.14.0"

load('ext://namespace', 'namespace_create', 'namespace_inject')

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

namespace_create(
    'istio-system',
)

helm_remote("base",
  repo_url="https://istio-release.storage.googleapis.com/charts",
  release_name='istio-base',
  namespace="istio-system",
  version=istio_version,
  allow_duplicates=True
)

Fails on

tilt doctor
Tilt: v0.31.2, built 2023-02-10
System: linux-amd64
---
Docker
- Host: unix:///var/run/docker.sock
- Server Version: 20.10.23
- API Version: 1.41
- Builder: 2
- Compose Version: v2.15.1
---
Kubernetes
- Env: kind
- Context: kind-test-cluster
- Cluster Name: kind-test-cluster
- Namespace: default
- Container Runtime: containerd
- Version: v1.23.10
- Cluster Local Registry: none
---
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: default
- Machine: 38db337aa529cbffe2ff8bde14bedd1b
- Repo: JMtymyVRxdYwFQLXWlNXfw==

with an error

tilt ci
Tilt started on http://localhost:10350/
v0.31.2, built 2023-02-10
Tilt analytics disabled: Environment variable CI=true

Initial Build
Loading Tiltfile at: /home/circleci/project/Tiltfile
local: helm repo list --output yaml 2>/dev/null || true
local: helm repo update
local: helm search repo base/base --output yaml --version 1.14.0
local: grep --include='*.yaml' --include='*.yml' -rEil '\bkind[^\w]+CustomResourceDefinition\s*$' /home/circleci/.local/share/tilt-dev/.helm/base/1.14.0/base || exit 0
ERROR: Traceback (most recent call last):
  /home/circleci/project/Tiltfile:11:12: in <toplevel>
  /home/circleci/.local/share/tilt-dev/tilt_modules/github.com/tilt-dev/tilt-extensions/helm_remote/Tiltfile:176:17: in helm_remote
  /home/circleci/.local/share/tilt-dev/tilt_modules/github.com/tilt-dev/tilt-extensions/helm_remote/Tiltfile:216:17: in install_crds
Error in k8s_yaml: Duplicate YAML: CustomResourceDefinition wasmplugins.extensions.istio.io
Ignore this error with k8s_yaml(..., allow_duplicates=True)
YAML originally registered at: Traceback (most recent call last):
    /home/circleci/project/Tiltfile:11:12: in <toplevel>
    /home/circleci/.local/share/tilt-dev/tilt_modules/github.com/tilt-dev/tilt-extensions/helm_remote/Tiltfile:176:17: in helm_remote
    /home/circleci/.local/share/tilt-dev/tilt_modules/github.com/tilt-dev/tilt-extensions/helm_remote/Tiltfile:216:17: in install_crds
    <builtin>: in k8s_yaml

Error: Traceback (most recent call last):
  /home/circleci/project/Tiltfile:11:12: in <toplevel>
  /home/circleci/.local/share/tilt-dev/tilt_modules/github.com/tilt-dev/tilt-extensions/helm_remote/Tiltfile:176:17: in helm_remote
  /home/circleci/.local/share/tilt-dev/tilt_modules/github.com/tilt-dev/tilt-extensions/helm_remote/Tiltfile:216:17: in install_crds
Error in k8s_yaml: Duplicate YAML: CustomResourceDefinition wasmplugins.extensions.istio.io
Ignore this error with k8s_yaml(..., allow_duplicates=True)
YAML originally registered at: Traceback (most recent call last):
    /home/circleci/project/Tiltfile:11:12: in <toplevel>
    /home/circleci/.local/share/tilt-dev/tilt_modules/github.com/tilt-dev/tilt-extensions/helm_remote/Tiltfile:176:17: in helm_remote
    /home/circleci/.local/share/tilt-dev/tilt_modules/github.com/tilt-dev/tilt-extensions/helm_remote/Tiltfile:216:17: in install_crds
    <builtin>: in k8s_yaml

and the downloaded crds:

grep --include='*.yaml' --include='*.yml' -rEil '\bkind[^\w]+CustomResourceDefinition\s*$' /home/circleci/.local/share/tilt-dev/.helm/base/1.14.0/base
/home/circleci/.local/share/tilt-dev/.helm/base/1.14.0/base/files/gen-istio-cluster.yaml
/home/circleci/.local/share/tilt-dev/.helm/base/1.14.0/base/crds/crd-all.gen.yaml
/home/circleci/.local/share/tilt-dev/.helm/base/1.14.0/base/crds/crd-operator.yaml

while on MacOSx

tilt doctor
Tilt: v0.31.2, built 2023-02-10
System: darwin-amd64
---
Docker
- Host: unix:///var/run/docker.sock
- Server Version: 20.10.23
- API Version: 1.41
- Builder: 2
- Compose Version: v2.15.1
---
Kubernetes
- Env: kind
- Context: kind-example-pipeline-service
- Cluster Name: kind-example-pipeline-service
- Namespace: default
- Container Runtime: containerd
- Version: v1.23.10
- Cluster Local Registry: none
---
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-out
- Machine: 2296e600a1836700aed3452f042131f4
- Repo: ddLh3CAs28QMCeLpP/+reA==
tilt ci 

works as expected with the same downloaded CRDs list:

grep --include='*.yaml' --include='*.yml' -rEil '\bkind[^\w]+CustomResourceDefinition\s*$' 
/Users/r631944/Library/Application Support/tilt-dev//.helm/base/1.14.0/base/crds/crd-operator.yaml
/Users/r631944/Library/Application Support/tilt-dev//.helm/base/1.14.0/base/crds/crd-all.gen.yaml
/Users/r631944/Library/Application Support/tilt-dev//.helm/base/1.14.0/base/files/gen-istio-cluster.yaml
mikhail-khodorovskiy commented 1 year ago
  if len(files) != 0:
        local_resource(name+'-install', cmd='kubectl apply -f %s' % " -f ".join(files), deps=files)  # we can wait/depend on this, but it won't cause a proper uninstall
        k8s_yaml(files)  # this will cause a proper uninstall, but we can't wait/depend on it

        # TODO: Figure out how to avoid another named resource showing up in the tilt HUD for this waiter
        local_resource(name+'-ready', resource_deps=[name+'-install'], cmd='kubectl wait --for=condition=Established crd --all')  # now we can wait for those crds to finish establishing

Allow duplicates may have to be propagated to the place where CRDs are installed: https://github.com/tilt-dev/tilt-extensions/blob/master/helm_remote/Tiltfile#L216 - still not clear why this works on MacOSx though.

nicks commented 1 year ago

ya, we'd accept a pr to propagate allow duplicates to install_crds

as for why it works on macos -- my guess is that you've got a different version of grep on your macos box, and so the install_crds function isn't properly filtering the CRDs. The grep ecosystem on macos is really fractured. does it fail if you install the coreutils version of grep (brew install coreutils)?