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

Error during expansion of "!!merge <<:" anchor tags #4212

Closed
daraghlowe opened this issue Sep 28, 2021 · 11 comments
Closed

Error during expansion of "!!merge <<:" anchor tags #4212

daraghlowe opened this issue Sep 28, 2021 · 11 comments
Labels
area/anchors related to yaml anchors kind/bug Categorizes issue or PR as related to a bug. triage/accepted Indicates an issue or PR is ready to be actively worked on.

Comments

@daraghlowe
Copy link

daraghlowe commented Sep 28, 2021

This is a follow up issue to #3675 as we still see errors when using the kustomize version 4.4 that has the YAML anchor fix. We're also seeing a similar error ( unsupported type: map[interface {}]interface {} ) for some other YAML in knative that doesn't have a YAML anchor.

We use kustomize v3.8.10 which works fine with knative but we get errors when using the later versions that use kyaml.

$ ./bin/kustomize44 version
{Version:kustomize/v4.4.0 GitCommit:63ec6bdb3d737a7c66901828c5743656c49b60e1 BuildDate:2021-09-27T16:24:12Z GoOs:darwin GoArch:amd64}

kustomization.yaml

apiVersion: kustomize.config.k8s.io/v1beta1
kind: Kustomization

bases:
- https://github.com/knative/serving/releases/download/v0.23.1/serving-core.yaml
- https://github.com/knative-sandbox/net-istio/releases/download/v0.23.1/release.yaml
- https://github.com/knative/serving/releases/download/v0.23.1/serving-domainmapping.yaml

The YAML anchor in serving-domainmapping.yaml and serving-core.yaml looks like this:

          readinessProbe: &probe
            periodSeconds: 1
            httpGet:
              scheme: HTTPS
              port: 8443
              httpHeaders:
                - name: k-kubelet-probe
                  value: "webhook"
          livenessProbe:
            !!merge <<: *probe
            failureThreshold: 6
            initialDelaySeconds: 20

Error during build:

Error: map[string]interface {}{"apiVersion":"apps/v1", "kind":"Deployment", "metadata":map[string]interface {}{"labels":map[string]interface {}{"serving.knative.dev/release":"v0.23.1"}, "name":"domainmapping-webhook", "namespace":"knative-serving"}, "spec":map[string]interface {}{"selector":map[string]interface {}{"matchLabels":map[string]interface {}{"app":"domainmapping-webhook", "role":"domainmapping-webhook"}}, "template":map[string]interface {}{"metadata":map[string]interface {}{"annotations":map[string]interface {}{"cluster-autoscaler.kubernetes.io/safe-to-evict":"false"}, "labels":map[string]interface {}{"app":"domainmapping-webhook", "role":"domainmapping-webhook", "serving.knative.dev/release":"v0.23.1"}}, "spec":map[string]interface {}{"affinity":map[string]interface {}{"podAntiAffinity":map[string]interface {}{"preferredDuringSchedulingIgnoredDuringExecution":[]interface {}{map[string]interface {}{"podAffinityTerm":map[string]interface {}{"labelSelector":map[string]interface {}{"matchLabels":map[string]interface {}{"app":"domainmapping-webhook"}}, "topologyKey":"kubernetes.io/hostname"}, "weight":100}}}}, "containers":[]interface {}{map[string]interface {}{"env":[]interface {}{map[string]interface {}{"name":"POD_NAME", "valueFrom":map[string]interface {}{"fieldRef":map[string]interface {}{"fieldPath":"metadata.name"}}}, map[string]interface {}{"name":"SYSTEM_NAMESPACE", "valueFrom":map[string]interface {}{"fieldRef":map[string]interface {}{"fieldPath":"metadata.namespace"}}}, map[string]interface {}{"name":"CONFIG_LOGGING_NAME", "value":"config-logging"}, map[string]interface {}{"name":"CONFIG_OBSERVABILITY_NAME", "value":"config-observability"}, map[string]interface {}{"name":"WEBHOOK_PORT", "value":"8443"}, map[string]interface {}{"name":"METRICS_DOMAIN", "value":"knative.dev/serving"}}, "image":"gcr.io/knative-releases/knative.dev/serving/cmd/domain-mapping-webhook@sha256:34bc9025e3589241ddf4d57e42818069bcbf69b3ec9ab0220437d9bfa0853be7", "livenessProbe":map[interface {}]interface {}{"failureThreshold":6, "httpGet":map[string]interface {}{"httpHeaders":[]interface {}{map[string]interface {}{"name":"k-kubelet-probe", "value":"webhook"}}, "port":8443, "scheme":"HTTPS"}, "initialDelaySeconds":20, "periodSeconds":1}, "name":"domainmapping-webhook", "ports":[]interface {}{map[string]interface {}{"containerPort":9090, "name":"metrics"}, map[string]interface {}{"containerPort":8008, "name":"profiling"}, map[string]interface {}{"containerPort":8443, "name":"https-webhook"}}, "readinessProbe":map[string]interface {}{"httpGet":map[string]interface {}{"httpHeaders":[]interface {}{map[string]interface {}{"name":"k-kubelet-probe", "value":"webhook"}}, "port":8443, "scheme":"HTTPS"}, "periodSeconds":1}, "resources":map[string]interface {}{"limits":map[string]interface {}{"cpu":"500m", "memory":"500Mi"}, "requests":map[string]interface {}{"cpu":"100m", "memory":"100Mi"}}, "securityContext":map[string]interface {}{"allowPrivilegeEscalation":false, "capabilities":map[string]interface {}{"drop":[]interface {}{"all"}}, "readOnlyRootFilesystem":true, "runAsNonRoot":true}}}, "serviceAccountName":"controller", "terminationGracePeriodSeconds":300}}}}: json: unsupported type: map[interface {}]interface {}

The non YAML anchor related error example is in release.yaml:

apiVersion: "security.istio.io/v1beta1"
kind: "PeerAuthentication"
metadata:
  name: "domainmapping-webhook"
  namespace: "knative-serving"
  labels:
    serving.knative.dev/release: "v0.23.1"
    networking.knative.dev/ingress-provider: istio
spec:
  selector:
    matchLabels:
      app: domainmapping-webhook
  portLevelMtls:
    8443:
      mode: PERMISSIVE

The error we get is here:

Error: map[string]interface {}{"apiVersion":"security.istio.io/v1beta1", "kind":"PeerAuthentication", "metadata":map[string]interface {}{"labels":map[string]interface {}{"networking.knative.dev/ingress-provider":"istio", "serving.knative.dev/release":"v0.23.1"}, "name":"domainmapping-webhook", "namespace":"knative-serving"}, "spec":map[string]interface {}{"portLevelMtls":map[interface {}]interface {}{8443:map[string]interface {}{"mode":"PERMISSIVE"}}, "selector":map[string]interface {}{"matchLabels":map[string]interface {}{"app":"domainmapping-webhook"}}}}: json: unsupported type: map[interface {}]interface {}
@daraghlowe daraghlowe added the kind/bug Categorizes issue or PR as related to a bug. label Sep 28, 2021
@k8s-ci-robot k8s-ci-robot added the needs-triage Indicates an issue or PR lacks a `triage/foo` label and requires one. label Sep 28, 2021
@KnVerey
Copy link
Contributor

KnVerey commented Sep 29, 2021

The second problem might be caused by the integer key. Can you please try quoting it? Ref issue #3446

@monopole can you please take a look at the issue of the anchors still not working in the provided sample?

@eddiezane
Copy link
Member

Second issue is indeed #3446.

@monopole
Copy link
Contributor

@ack

@KnVerey
Copy link
Contributor

KnVerey commented Sep 29, 2021

/retitle Error during expansion of "!!merge <<:" anchor tags

@k8s-ci-robot k8s-ci-robot changed the title Knative Serving Support Error during expansion of "!!merge <<:" anchor tags Sep 29, 2021
@daraghlowe
Copy link
Author

Thanks @eddiezane @KnVerey, the integer key is the second issue, confirmed that it works fine when I put it in quotes.

@KnVerey
Copy link
Contributor

KnVerey commented Oct 27, 2021

/triage accepted

@k8s-ci-robot k8s-ci-robot added triage/accepted Indicates an issue or PR is ready to be actively worked on. and removed needs-triage Indicates an issue or PR lacks a `triage/foo` label and requires one. labels Oct 27, 2021
@apshoemaker
Copy link

I am currently still receiving errors on the below yaml snippet (from https://github.com/knative/eventing/releases/download/v0.26.0/eventing-core.yaml) :

# Copyright 2018 The Knative Authors
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
#     http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.

apiVersion: apps/v1
kind: Deployment
metadata:
  name: pingsource-mt-adapter
  namespace: knative-eventing
  labels:
    eventing.knative.dev/release: "v0.26.0"
    app.kubernetes.io/name: pingsource-mt-adapter
    app.kubernetes.io/version: "0.26.0"
    app.kubernetes.io/part-of: knative-eventing
spec:
  # when set to 0 (and only 0) will be set to 1 when the first PingSource is created.
  replicas: 0
  selector:
    matchLabels: &labels
      eventing.knative.dev/source: ping-source-controller
      sources.knative.dev/role: adapter
  template:
    metadata:
      labels:
        !!merge <<: *labels
        eventing.knative.dev/release: "v0.26.0"
        app.kubernetes.io/name: pingsource-mt-adapter
        app.kubernetes.io/version: "0.26.0"
        app.kubernetes.io/part-of: knative-eventing
    spec:
      affinity:
        podAntiAffinity:
          preferredDuringSchedulingIgnoredDuringExecution:
            - podAffinityTerm:
                labelSelector:
                  matchLabels: *labels
                topologyKey: kubernetes.io/hostname
              weight: 100
      enableServiceLinks: false
      containers:
        - name: dispatcher
          image: gcr.io/knative-releases/knative.dev/eventing/cmd/mtping@sha256:f47e953dfeb7747579f200b43af75f7796a5ab0e6fb616199abff233f3d03b4f
          env:
            - name: SYSTEM_NAMESPACE
              value: ""
              valueFrom:
                fieldRef:
                  apiVersion: v1
                  fieldPath: metadata.namespace
            # DO NOT MODIFY: The values below are being filled by the ping source controller
            # See 500-controller.yaml
            - name: K_METRICS_CONFIG
              value: ""
            - name: K_LOGGING_CONFIG
              value: ""
            - name: K_LEADER_ELECTION_CONFIG
              value: ""
            - name: K_NO_SHUTDOWN_AFTER
              value: ""
            - name: K_SINK_TIMEOUT
              value: "-1"
            - name: POD_NAME
              valueFrom:
                fieldRef:
                  fieldPath: metadata.name
          ports:
            - containerPort: 9090
              name: metrics
              protocol: TCP
          resources:
            requests:
              cpu: 125m
              memory: 64Mi
            limits:
              cpu: 1000m
              memory: 2048Mi
      serviceAccountName: pingsource-mt-adapter

The error received is:

Error: map[string]interface {}{"apiVersion":"apps/v1", "kind":"Deployment", "metadata":map[string]interface {}{"labels":map[string]interface {}{"app.kubernetes.io/name":"pingsource-mt-adapter", "app.kubernetes.io/part-of":"knative-eventing", "app.kubernetes.io/version":"0.26.0", "eventing.knative.dev/release":"v0.26.0"}, "name":"pingsource-mt-adapter", "namespace":"knative-eventing"}, "spec":map[string]interface {}{"replicas":0, "selector":map[string]interface {}{"matchLabels":map[string]interface {}{"eventing.knative.dev/source":"ping-source-controller", "sources.knative.dev/role":"adapter"}}, "template":map[string]interface {}{"metadata":map[string]interface {}{"labels":map[interface {}]interface {}{"app.kubernetes.io/name":"pingsource-mt-adapter", "app.kubernetes.io/part-of":"knative-eventing", "app.kubernetes.io/version":"0.26.0", "eventing.knative.dev/release":"v0.26.0", "eventing.knative.dev/source":"ping-source-controller", "sources.knative.dev/role":"adapter"}}, "spec":map[string]interface {}{"affinity":map[string]interface {}{"podAntiAffinity":map[string]interface {}{"preferredDuringSchedulingIgnoredDuringExecution":[]interface {}{map[string]interface {}{"podAffinityTerm":map[string]interface {}{"labelSelector":map[string]interface {}{"matchLabels":map[string]interface {}{"eventing.knative.dev/source":"ping-source-controller", "sources.knative.dev/role":"adapter"}}, "topologyKey":"kubernetes.io/hostname"}, "weight":100}}}}, "containers":[]interface {}{map[string]interface {}{"env":[]interface {}{map[string]interface {}{"name":"SYSTEM_NAMESPACE", "value":"", "valueFrom":map[string]interface {}{"fieldRef":map[string]interface {}{"apiVersion":"v1", "fieldPath":"metadata.namespace"}}}, map[string]interface {}{"name":"K_METRICS_CONFIG", "value":""}, map[string]interface {}{"name":"K_LOGGING_CONFIG", "value":""}, map[string]interface {}{"name":"K_LEADER_ELECTION_CONFIG", "value":""}, map[string]interface {}{"name":"K_NO_SHUTDOWN_AFTER", "value":""}, map[string]interface {}{"name":"K_SINK_TIMEOUT", "value":"-1"}, map[string]interface {}{"name":"POD_NAME", "valueFrom":map[string]interface {}{"fieldRef":map[string]interface {}{"fieldPath":"metadata.name"}}}}, "image":"gcr.io/knative-releases/knative.dev/eventing/cmd/mtping@sha256:f47e953dfeb7747579f200b43af75f7796a5ab0e6fb616199abff233f3d03b4f", "name":"dispatcher", "ports":[]interface {}{map[string]interface {}{"containerPort":9090, "name":"metrics", "protocol":"TCP"}}, "resources":map[string]interface {}{"limits":map[string]interface {}{"cpu":"1000m", "memory":"2048Mi"}, "requests":map[string]interface {}{"cpu":"125m", "memory":"64Mi"}}}}, "enableServiceLinks":false, "serviceAccountName":"pingsource-mt-adapter"}}}}: json: unsupported type: map[interface {}]interface {}
➜ ~/Downloads kustomize version                                             
{Version:kustomize/v4.4.0 GitCommit:63ec6bdb3d737a7c66901828c5743656c49b60e1 BuildDate:2021-09-27T16:24:12Z GoOs:linux GoArch:amd64}

Please advise - thanks!

@natasha41575 natasha41575 added the area/anchors related to yaml anchors label Dec 30, 2021
@RafaeLeal
Copy link
Contributor

I'm having this same issue, I tried to understand more deeply the issue and come up with a solution...

I'm still reading the Contribution Guidelines, and I was not sure if I could do it because I'm not familiar with the codebase.

I opened a PR on my fork, and I'm still dealing with some corner cases related to comments and JSON serialization...
https://github.com/RafaeLeal/kustomize/pull/1/files

After signing the CLA I can open this PR if there's nothing terribly wrong with it 😅

@natasha41575
Copy link
Contributor

natasha41575 commented Jan 11, 2022

@RafaeLeal I took a very quick glance at your PR, and nothing about it seems terribly outlandish, it would be great if you could open the PR here and we can do a more thorough review.

@RafaeLeal
Copy link
Contributor

@natasha41575 Created, thanks! :)

@KnVerey
Copy link
Contributor

KnVerey commented Mar 23, 2022

Closed by #4383

@KnVerey KnVerey closed this as completed Mar 23, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
area/anchors related to yaml anchors kind/bug Categorizes issue or PR as related to a bug. triage/accepted Indicates an issue or PR is ready to be actively worked on.
Projects
None yet
Development

No branches or pull requests

8 participants