emissary-ingress / emissary

open source Kubernetes-native API gateway for microservices built on the Envoy Proxy
https://www.getambassador.io
Apache License 2.0
4.34k stars 680 forks source link

Gracefully handle deprecated mappings #4783

Open Andrei-Predoiu opened 1 year ago

Andrei-Predoiu commented 1 year ago

Describe the bug Emissary 2.5.1 crashes if there are deprecated mappings in the cluster

To Reproduce Steps to reproduce the behavior:

  1. Apply a deprecated mapping annotation to a service (getambassador.io/v1) fx:
    apiVersion: v1
    kind: Service
    metadata:
    annotations:
    getambassador.io/config: |
      apiVersion: ambassador/v1
      kind:  Mapping
      name:  deprecated
      prefix: /deprecated
      timeout_ms: 10000
      service: irrelevant
  2. Emissary 2.5.1 will enter crash loop
  3. Following stacktrace will be produced
time="2023-01-06 10:27:39.6843" level=info msg="Started Ambassador (Version 2.5.1)" func=github.com/datawire/ambassador/v2/cmd/entrypoint.Main file="/go/cmd/entrypoint/entrypoint.go:96" CMD=entrypoint PID=1
time="2023-01-06 10:27:39.8438" level=info msg="AMBASSADOR_CLUSTER_ID=ef2314f7-e055-5f26-8379-78b88b02f59b" func=github.com/datawire/ambassador/v2/cmd/entrypoint.Main file="/go/cmd/entrypoint/entrypoint.go:110" CMD=entrypoint PID=1
time="2023-01-06 10:27:39.8478" level=info msg="Ambex 2.5.1 starting, snapdirPath /ambassador/snapshots" func=github.com/datawire/ambassador/v2/pkg/ambex.Main file="/go/pkg/ambex/main.go:767" CMD=entrypoint PID=1 THREAD=/ambex
time="2023-01-06 10:27:39.8482" level=info msg="Wrote PID" func=github.com/datawire/ambassador/v2/pkg/ambex.Main file="/go/pkg/ambex/main.go:813" CMD=entrypoint PID=1 THREAD=/ambex fields.file=ambex.pid file="/go/pkg/ambex/main.go:813" pid=1
time="2023-01-06 10:27:39.8483" level=info msg="started command [\"diagd\" \"/ambassador/snapshots\" \"/ambassador/bootstrap-ads.json\" \"/ambassador/envoy/envoy.json\" \"--notices\" \"/ambassador/notices.json\" \"--port\" \"8004\" \"--kick\" \"kill -HUP 1\"]" func="github.com/datawire/dlib/dexec.(*Cmd).Start" file="/go/vendor/github.com/datawire/dlib/dexec/cmd.go:183" CMD=entrypoint PID=1 THREAD=/diagd dexec.pid=18
time="2023-01-06 10:27:39.8486" level=info msg="not logging input read from file \"/dev/stdin\"" func="github.com/datawire/dlib/dexec.(*Cmd).Start" file="/go/vendor/github.com/datawire/dlib/dexec/cmd.go:185" CMD=entrypoint PID=1 THREAD=/diagd dexec.pid=18 dexec.stream=stdin
time="2023-01-06 10:27:39.8488" level=info msg="not logging output written to file \"/dev/stdout\"" func="github.com/datawire/dlib/dexec.(*Cmd).Start" file="/go/vendor/github.com/datawire/dlib/dexec/cmd.go:188" CMD=entrypoint PID=1 THREAD=/diagd dexec.pid=18 dexec.stream=stdout
time="2023-01-06 10:27:39.8490" level=info msg="not logging output written to file \"/dev/stderr\"" func="github.com/datawire/dlib/dexec.(*Cmd).Start" file="/go/vendor/github.com/datawire/dlib/dexec/cmd.go:191" CMD=entrypoint PID=1 THREAD=/diagd dexec.pid=18 dexec.stream=stderr
time="2023-01-06 10:27:39.8515" level=info msg="Saved snapshot v0" func=github.com/datawire/ambassador/v2/pkg/ambex.csDump file="/go/pkg/ambex/main.go:404" CMD=entrypoint PID=1 THREAD=/ambex/main-loop
time="2023-01-06 10:27:39.8521" level=info msg="Pushing snapshot v0" func=github.com/datawire/ambassador/v2/pkg/ambex.updaterWithTicker file="/go/pkg/ambex/ratelimit.go:159" CMD=entrypoint PID=1 THREAD=/ambex/updater
time="2023-01-06 10:27:39.8538" level=info msg="AMBASSADOR_RECONFIG_MAX_DELAY set to 1" func=github.com/datawire/ambassador/v2/cmd/entrypoint.WatchAllTheThings file="/go/cmd/entrypoint/watcher.go:47" CMD=entrypoint PID=1 THREAD=/watcher
time="2023-01-06 10:27:39.8604" level=info msg="Listening on tcp:127.0.0.1:8003" func=github.com/datawire/ambassador/v2/pkg/ambex.runManagementServer file="/go/pkg/ambex/main.go:259" CMD=entrypoint PID=1 THREAD=/ambex/management-server
time="2023-01-06 10:27:39.8838" level=warning msg="Warning, unable to watch gatewayclasses.v1alpha1.networking.x-k8s.io, unknown kind." func=github.com/datawire/ambassador/v2/cmd/entrypoint.GetInterestingTypes file="/go/cmd/entrypoint/interesting_types.go:160" CMD=entrypoint PID=1 THREAD=/watcher
time="2023-01-06 10:27:39.8839" level=warning msg="Warning, unable to watch httproutes.v1alpha1.networking.x-k8s.io, unknown kind." func=github.com/datawire/ambassador/v2/cmd/entrypoint.GetInterestingTypes file="/go/cmd/entrypoint/interesting_types.go:160" CMD=entrypoint PID=1 THREAD=/watcher
time="2023-01-06 10:27:39.8840" level=warning msg="Warning, unable to watch filters.v3alpha1.getambassador.io, unknown kind." func=github.com/datawire/ambassador/v2/cmd/entrypoint.GetInterestingTypes file="/go/cmd/entrypoint/interesting_types.go:160" CMD=entrypoint PID=1 THREAD=/watcher
time="2023-01-06 10:27:39.8840" level=warning msg="Warning, unable to watch gateways.v1alpha1.networking.x-k8s.io, unknown kind." func=github.com/datawire/ambassador/v2/cmd/entrypoint.GetInterestingTypes file="/go/cmd/entrypoint/interesting_types.go:160" CMD=entrypoint PID=1 THREAD=/watcher
time="2023-01-06 10:27:39.8841" level=warning msg="Warning, unable to watch filterpolicies.v3alpha1.getambassador.io, unknown kind." func=github.com/datawire/ambassador/v2/cmd/entrypoint.GetInterestingTypes file="/go/cmd/entrypoint/interesting_types.go:160" CMD=entrypoint PID=1 THREAD=/watcher
I0106 10:27:41.555767       1 request.go:668] Waited for 1.046198794s due to client-side throttling, not priority and fairness, request: GET:https://172.29.96.1:443/apis/getambassador.io/v3alpha1/consulresolvers?limit=500&resourceVersion=0
2023-01-06 10:27:45 diagd 2.5.1 [P18TMainThread] INFO: AMBASSADOR_FAST_RECONFIGURE enabled, initializing cache
2023-01-06 10:27:45 diagd 2.5.1 [P18TMainThread] INFO: WILL NOT update Mapping status
2023-01-06 10:27:45 diagd 2.5.1 [P18TMainThread] INFO: thread count 9, listening on 127.0.0.1:8004
time="2023-01-06 10:27:45.3057" level=error msg="goroutine \"/watcher/loop\" exited with error: PANIC: reflect: reflect.Value.Set using value obtained using unexported field\ngithub.com/datawire/dlib/dgroup.(*Group).goWorkerCtx.func1.1\n\t/go/vendor/github.com/datawire/dlib/dgroup/group.go:369\nruntime.gopanic\n\t/usr/local/go/src/runtime/panic.go:884\nreflect.flag.mustBeAssignableSlow\n\t/usr/local/go/src/reflect/value.go:257\nreflect.flag.mustBeAssignable\n\t/usr/local/go/src/reflect/value.go:247\nreflect.Value.Set\n\t/usr/local/go/src/reflect/value.go:2154\nk8s.io/apimachinery/pkg/runtime.structFromUnstructured\n\t/go/vendor/k8s.io/apimachinery/pkg/runtime/converter.go:389\nk8s.io/apimachinery/pkg/runtime.fromUnstructured\n\t/go/vendor/k8s.io/apimachinery/pkg/runtime/converter.go:222\nk8s.io/apimachinery/pkg/runtime.(*unstructuredConverter).FromUnstructured\n\t/go/vendor/k8s.io/apimachinery/pkg/runtime/converter.go:126\nk8s.io/apimachinery/pkg/runtime.(*Scheme).unstructuredToTyped\n\t/go/vendor/k8s.io/apimachinery/pkg/runtime/scheme.go:561\nk8s.io/apimachinery/pkg/runtime.(*Scheme).convertToVersion\n\t/go/vendor/k8s.io/apimachinery/pkg/runtime/scheme.go:475\nk8s.io/apimachinery/pkg/runtime.(*Scheme).ConvertToVersion\n\t/go/vendor/k8s.io/apimachinery/pkg/runtime/scheme.go:460\ngithub.com/datawire/ambassador/v2/pkg/snapshot/v1.convertAnnotationObject\n\t/go/pkg/snapshot/v1/annotations.go:102\ngithub.com/datawire/ambassador/v2/pkg/snapshot/v1.ValidateAndConvertObject\n\t/go/pkg/snapshot/v1/annotations.go:84\ngithub.com/datawire/ambassador/v2/pkg/snapshot/v1.(*KubernetesSnapshot).PopulateAnnotations\n\t/go/pkg/snapshot/v1/annotations.go:46\ngithub.com/datawire/ambassador/v2/cmd/entrypoint.(*SnapshotHolder).K8sUpdate.func1.2\n\t/go/cmd/entrypoint/watcher.go:447\ngithub.com/datawire/ambassador/v2/pkg/debug.(*Timer).Time\n\t/go/pkg/debug/timer.go:164\ngithub.com/datawire/ambassador/v2/cmd/entrypoint.(*SnapshotHolder).K8sUpdate.func1\n\t/go/cmd/entrypoint/watcher.go:446\ngithub.com/datawire/ambassador/v2/cmd/entrypoint.(*SnapshotHolder).K8sUpdate\n\t/go/cmd/entrypoint/watcher.go:530\ngithub.com/datawire/ambassador/v2/cmd/entrypoint.watchAllTheThingsInternal.func2\n\t/go/cmd/entrypoint/watcher.go:278\ngithub.com/datawire/dlib/dgroup.(*Group).goWorkerCtx.func1\n\t/go/vendor/github.com/datawire/dlib/dgroup/group.go:385\ngithub.com/datawire/dlib/derrgroup.(*Group).Go.func2\n\t/go/vendor/github.com/datawire/dlib/derrgroup/errgroup.go:132\nruntime.goexit\n\t/usr/local/go/src/runtime/asm_amd64.s:1594" func="github.com/datawire/dlib/dgroup.(*Group).goWorkerCtx.func1.1" file="/go/vendor/github.com/datawire/dlib/dgroup/group.go:380" CMD=entrypoint PID=1 THREAD=/watcher/loop
time="2023-01-06 10:27:45.3059" level=info msg="shutting down (gracefully)..." func="github.com/datawire/dlib/dgroup.(*Group).launchSupervisors.func1" file="/go/vendor/github.com/datawire/dlib/dgroup/group.go:238" CMD=entrypoint PID=1 THREAD="/watcher:shutdown_logger"
time="2023-01-06 10:27:45.3060" level=info msg="  final goroutine statuses:" func=github.com/datawire/dlib/dgroup.logGoroutineStatuses file="/go/vendor/github.com/datawire/dlib/dgroup/group.go:84" CMD=entrypoint PID=1 THREAD="/watcher:shutdown_status"
time="2023-01-06 10:27:45.3061" level=info msg="    /watcher/consul  : exited without error" func=github.com/datawire/dlib/dgroup.logGoroutineStatuses file="/go/vendor/github.com/datawire/dlib/dgroup/group.go:95" CMD=entrypoint PID=1 THREAD="/watcher:shutdown_status"
time="2023-01-06 10:27:45.3061" level=info msg="    /watcher/loop    : exited with error" func=github.com/datawire/dlib/dgroup.logGoroutineStatuses file="/go/vendor/github.com/datawire/dlib/dgroup/group.go:95" CMD=entrypoint PID=1 THREAD="/watcher:shutdown_status"
time="2023-01-06 10:27:45.3062" level=info msg="    /watcher/notifyCh: exited without error" func=github.com/datawire/dlib/dgroup.logGoroutineStatuses file="/go/vendor/github.com/datawire/dlib/dgroup/group.go:95" CMD=entrypoint PID=1 THREAD="/watcher:shutdown_status"
time="2023-01-06 10:27:45.3063" level=error msg="goroutine \"/watcher\" exited with error: PANIC: reflect: reflect.Value.Set using value obtained using unexported field\ngithub.com/datawire/dlib/dgroup.(*Group).goWorkerCtx.func1.1\n\t/go/vendor/github.com/datawire/dlib/dgroup/group.go:369\nruntime.gopanic\n\t/usr/local/go/src/runtime/panic.go:884\nreflect.flag.mustBeAssignableSlow\n\t/usr/local/go/src/reflect/value.go:257\nreflect.flag.mustBeAssignable\n\t/usr/local/go/src/reflect/value.go:247\nreflect.Value.Set\n\t/usr/local/go/src/reflect/value.go:2154\nk8s.io/apimachinery/pkg/runtime.structFromUnstructured\n\t/go/vendor/k8s.io/apimachinery/pkg/runtime/converter.go:389\nk8s.io/apimachinery/pkg/runtime.fromUnstructured\n\t/go/vendor/k8s.io/apimachinery/pkg/runtime/converter.go:222\nk8s.io/apimachinery/pkg/runtime.(*unstructuredConverter).FromUnstructured\n\t/go/vendor/k8s.io/apimachinery/pkg/runtime/converter.go:126\nk8s.io/apimachinery/pkg/runtime.(*Scheme).unstructuredToTyped\n\t/go/vendor/k8s.io/apimachinery/pkg/runtime/scheme.go:561\nk8s.io/apimachinery/pkg/runtime.(*Scheme).convertToVersion\n\t/go/vendor/k8s.io/apimachinery/pkg/runtime/scheme.go:475\nk8s.io/apimachinery/pkg/runtime.(*Scheme).ConvertToVersion\n\t/go/vendor/k8s.io/apimachinery/pkg/runtime/scheme.go:460\ngithub.com/datawire/ambassador/v2/pkg/snapshot/v1.convertAnnotationObject\n\t/go/pkg/snapshot/v1/annotations.go:102\ngithub.com/datawire/ambassador/v2/pkg/snapshot/v1.ValidateAndConvertObject\n\t/go/pkg/snapshot/v1/annotations.go:84\ngithub.com/datawire/ambassador/v2/pkg/snapshot/v1.(*KubernetesSnapshot).PopulateAnnotations\n\t/go/pkg/snapshot/v1/annotations.go:46\ngithub.com/datawire/ambassador/v2/cmd/entrypoint.(*SnapshotHolder).K8sUpdate.func1.2\n\t/go/cmd/entrypoint/watcher.go:447\ngithub.com/datawire/ambassador/v2/pkg/debug.(*Timer).Time\n\t/go/pkg/debug/timer.go:164\ngithub.com/datawire/ambassador/v2/cmd/entrypoint.(*SnapshotHolder).K8sUpdate.func1\n\t/go/cmd/entrypoint/watcher.go:446\ngithub.com/datawire/ambassador/v2/cmd/entrypoint.(*SnapshotHolder).K8sUpdate\n\t/go/cmd/entrypoint/watcher.go:530\ngithub.com/datawire/ambassador/v2/cmd/entrypoint.watchAllTheThingsInternal.func2\n\t/go/cmd/entrypoint/watcher.go:278\ngithub.com/datawire/dlib/dgroup.(*Group).goWorkerCtx.func1\n\t/go/vendor/github.com/datawire/dlib/dgroup/group.go:385\ngithub.com/datawire/dlib/derrgroup.(*Group).Go.func2\n\t/go/vendor/github.com/datawire/dlib/derrgroup/errgroup.go:132\nruntime.goexit\n\t/usr/local/go/src/runtime/asm_amd64.s:1594" func="github.com/datawire/dlib/dgroup.(*Group).goWorkerCtx.func1.1" file="/go/vendor/github.com/datawire/dlib/dgroup/group.go:380" CMD=entrypoint PID=1 THREAD=/watcher
time="2023-01-06 10:27:45.3070" level=info msg="sending SIGINT" func="github.com/datawire/dlib/dexec.(*Cmd).Start.func1" file="/go/vendor/github.com/datawire/dlib/dexec/cmd.go:211" CMD=entrypoint PID=1 THREAD=/diagd
time="2023-01-06 10:27:45.3076" level=info msg="shutting down (gracefully)..." func="github.com/datawire/dlib/dgroup.(*Group).launchSupervisors.func1" file="/go/vendor/github.com/datawire/dlib/dgroup/group.go:238" CMD=entrypoint PID=1 THREAD="/ambex:shutdown_logger"
time="2023-01-06 10:27:45.3071" level=info msg="shutting down (gracefully)..." func="github.com/datawire/dlib/dgroup.(*Group).launchSupervisors.func1" file="/go/vendor/github.com/datawire/dlib/dgroup/group.go:238" CMD=entrypoint PID=1 THREAD=":shutdown_logger"

Aborted!
time="2023-01-06 10:27:45.3185" level=info msg="Memory Usage 0.13Gi (22%)\n    PID 1, 0.13Gi: busyambassador entrypoint \n    PID 18, 0.05Gi: /usr/bin/python /usr/bin/diagd /ambassador/snapshots /ambassador/bootstrap-ads.json /ambassador/envoy/envoy.json --notices /ambassador/notices.json --port 8004 --kick kill -HUP 1 " func="github.com/datawire/ambassador/v2/pkg/memory.(*MemoryUsage).Watch" file="/go/pkg/memory/memory.go:43" CMD=entrypoint PID=1 THREAD=/memory
time="2023-01-06 10:27:45.5794" level=info msg="finished with error: exit status 1" func="github.com/datawire/dlib/dexec.(*Cmd).Wait" file="/go/vendor/github.com/datawire/dlib/dexec/cmd.go:257" CMD=entrypoint PID=1 THREAD=/diagd dexec.pid=18
time="2023-01-06 10:27:45.5800" level=error msg="goroutine \"/diagd\" exited with error: exit status 1" func="github.com/datawire/dlib/dgroup.(*Group).goWorkerCtx.func1.1" file="/go/vendor/github.com/datawire/dlib/dgroup/group.go:380" CMD=entrypoint PID=1 THREAD=/diagd
time="2023-01-06 10:27:45.5803" level=info msg="  final goroutine statuses:" func=github.com/datawire/dlib/dgroup.logGoroutineStatuses file="/go/vendor/github.com/datawire/dlib/dgroup/group.go:84" CMD=entrypoint PID=1 THREAD=":shutdown_status"
time="2023-01-06 10:27:45.5806" level=info msg="    /ambex                   : exited without error" func=github.com/datawire/dlib/dgroup.logGoroutineStatuses file="/go/vendor/github.com/datawire/dlib/dgroup/group.go:95" CMD=entrypoint PID=1 THREAD=":shutdown_status"
time="2023-01-06 10:27:45.5808" level=info msg="    /diagd                   : exited with error" func=github.com/datawire/dlib/dgroup.logGoroutineStatuses file="/go/vendor/github.com/datawire/dlib/dgroup/group.go:95" CMD=entrypoint PID=1 THREAD=":shutdown_status"
time="2023-01-06 10:27:45.5810" level=info msg="    /envoy                   : exited without error" func=github.com/datawire/dlib/dgroup.logGoroutineStatuses file="/go/vendor/github.com/datawire/dlib/dgroup/group.go:95" CMD=entrypoint PID=1 THREAD=":shutdown_status"
time="2023-01-06 10:27:45.5812" level=info msg="    /external_snapshot_server: exited without error" func=github.com/datawire/dlib/dgroup.logGoroutineStatuses file="/go/vendor/github.com/datawire/dlib/dgroup/group.go:95" CMD=entrypoint PID=1 THREAD=":shutdown_status"
time="2023-01-06 10:27:45.5814" level=info msg="    /healthchecks            : exited without error" func=github.com/datawire/dlib/dgroup.logGoroutineStatuses file="/go/vendor/github.com/datawire/dlib/dgroup/group.go:95" CMD=entrypoint PID=1 THREAD=":shutdown_status"
time="2023-01-06 10:27:45.5842" level=info msg="    /memory                  : exited without error" func=github.com/datawire/dlib/dgroup.logGoroutineStatuses file="/go/vendor/github.com/datawire/dlib/dgroup/group.go:95" CMD=entrypoint PID=1 THREAD=":shutdown_status"
time="2023-01-06 10:27:45.5844" level=info msg="    /snapshot_server         : exited without error" func=github.com/datawire/dlib/dgroup.logGoroutineStatuses file="/go/vendor/github.com/datawire/dlib/dgroup/group.go:95" CMD=entrypoint PID=1 THREAD=":shutdown_status"
time="2023-01-06 10:27:45.5846" level=info msg="    /watcher                 : exited with error" func=github.com/datawire/dlib/dgroup.logGoroutineStatuses file="/go/vendor/github.com/datawire/dlib/dgroup/group.go:95" CMD=entrypoint PID=1 THREAD=":shutdown_status"
time="2023-01-06 10:27:45.5848" level=error msg="shut down with error error: PANIC: reflect: reflect.Value.Set using value obtained using unexported field" func=github.com/datawire/ambassador/v2/pkg/busy.Main file="/go/pkg/busy/busy.go:87" CMD=entrypoint PID=1

Expected behavior A clear error is displayed on the ambassador diag page or the deprecated mappings are ignored.

Versions (please complete the following information):

Additional context Example mapping:

apiVersion: v1
kind: Service
metadata:
  annotations:
    getambassador.io/config: |
      ---
      apiVersion: ambassador/v1
      kind: Mapping
      name: api-svc
      prefix: /cmi/
      service:api-svc:8080
      timeout_ms: 30000
      bypass_auth: true
    kubectl.kubernetes.io/last-applied-configuration: |
      {"apiVersion":"v1","kind":"Service","metadata":{"annotations":{"getambassador.io/config":"---\napiVersion: ambassador/v1\nkind: Mapping\nname: api-svc\nprefix: /cmi/\nservice: api-svc:8080\ntimeout_ms: 30000\nbypass_auth: true\n"},"name":"api-svc-ambmap","namespace":"default"},"spec":{"ports":[{"name":"api-svc-ambmap","port":80}]}}
  creationTimestamp: "2021-12-16T09:52:55Z"
  name: api-svc-ambmap
  namespace: default
  resourceVersion: "225264235"
  uid: 8549b527-564a-4f30-8544-2af6a999d225
spec:
  clusterIP: 172.29.52.81
  clusterIPs:
  - 172.29.52.81
  internalTrafficPolicy: Cluster
  ipFamilies:
  - IPv4
  ipFamilyPolicy: SingleStack
  ports:
  - name: api-svc-ambmap
    port: 80
    protocol: TCP
    targetPort: 80
  sessionAffinity: None
  type: ClusterIP
status:
  loadBalancer: {}
bilcus commented 1 year ago

We are having the same issue when upgrading Ambassador from 3.3.1 to 3.4.0.

bluehawk27 commented 1 year ago

I updated my service annotations to ambassador/v2 and that got it working for me. Ideally this doesn't even cause a shutdown. It would be a shame for a single misconfigured application to bring down all of the services that depend on ambassador as an ingress controller.

lorenzo-biava commented 1 year ago

Given all the issues the v1 to v2 upgrade brought, it's a bit of a shame there are no regression tests in the codebase for misconfigured resources that could still use v1 APIs. Especially annotations, it's very hard to reject those faulty objects when they are deployed to the cluster. And if you run a multi-tenant environment, you're absolutely sure to incur in this issue.

pie-r commented 1 year ago

If you need to identify the problematic resources:

k get svc -A -o yaml > svc-list.yaml  && \
yq '.items[].metadata | select(.annotations."getambassador.io/config" | test(".*(getambassador.io|ambassador.io|ambassador)/v1.*") ) | [{"name": .name, "creationTimestamp": .creationTimestamp, "namespace": .namespace, "annotationsWithBadContent": .annotations."getambassador.io/config" }]' svc-list.yaml > bad_service.yaml \
| tee bad_service.yaml 
cindymullins-dw commented 1 year ago

We try to highlight the need to identify and upgrade v1 resources beforehand in the Migration Steps but I see your point about more graceful handling in the event that they still exist.

akundrock commented 1 year ago

I had this issue today. The docs for upgrading via helm charts have no link to the precautions available in the yaml upgrade path

dgaffuri commented 1 year ago

Hi, as stated before the same happens with 3.4.0, but in change log for 3.4.0 I read "Support for the getambassador.io/v1 apiVersion has been re-introduced". This means that custom resources in that namespace are accepted (I've not tried to be honest) but annotations with "ambassador/v1" cause emissary-ingress to panic?

dgaffuri commented 1 year ago

The problem is due to the following private field, present in all resources defined in pkg/api/getambassador.io/v1 package, that breaks conversion of annotations by reflection in pkg/snapshot/v1.convertAnnotationObject (annotations.go). There's a test for conversion (annotations_test.go) but no test case involve a v1 (or v2) namespace.

// dumbWorkaround is a dumb workaround for a bug in conversion-gen that it doesn't pay
// attention to +k8s:conversion-fn=drop or +k8s:conversion-gen=false when checking if it can
// do the direct-assignment or direct-conversion optimizations, and therefore might disobey
// the +k8s:conversion-fn=drop on metav1.TypeMeta.
//
// +k8s:conversion-gen=false
dumbWorkaround byte `json:"-"` //nolint:unused // dumb workaround

Since I've not well understood the purpose of the workaround I'm not able to propose a patch.

dgaffuri commented 1 year ago

@LukeShu Hi, I've seen you're the author of the commit that reintroduced v1 resources (b8c6a24), do you think there's some different solution that don't break v1 annotations? Our problem is that that we cannot update a non single namespaced instance because of old annotations in the cluster used by 1.x deployments not under our control. Thank you very much for your attention