Uploaded image for project: 'OpenShift Bugs'
  1. OpenShift Bugs
  2. OCPBUGS-52305

Problematic JSON fields with oc get

XMLWordPrintable

    • Icon: Bug Bug
    • Resolution: Not a Bug
    • Icon: Normal Normal
    • None
    • 4.18
    • oc
    • Quality / Stability / Reliability
    • False
    • Hide

      None

      Show
      None
    • None
    • Moderate
    • None
    • None
    • None
    • None
    • None
    • None
    • None
    • None
    • None
    • None
    • None
    • None

      Description of problem:

      I would like to use `oc get` to create a list of nodes in the cluster that displays the node architecture. Using the `custom-columns` option, I should be able to reference `.metadata.labels."kubernetes.io/arch"`, however, I am unable to escape the period in the name of the label.
      Both 
      $ oc get no manager0.jbsandbox2 -o json | jq  '.metadata.labels."kubernetes.io/arch"'
      "s390x"
      
      and 
      
      $ oc get no -l kubernetes.io/arch=s390x
      NAME                  STATUS   ROLES                  AGE   VERSION
      manager0.jbsandbox2   Ready    control-plane,master   24h   v1.31.5
      manager1.jbsandbox2   Ready    control-plane,master   24h   v1.31.5
      manager2.jbsandbox2   Ready    control-plane,master   24h   v1.31.5
      worker0.jbsandbox2    Ready    worker                 24h   v1.31.5
      worker1.jbsandbox2    Ready    worker                 24h   v1.31.5
      worker2.jbsandbox2    Ready    worker                 24h   v1.31.5
      
      seem to work, however, this does not
      
      $ oc get no -o custom-columns=ARCH:{.metadata.labels."kubernetes.io/arch"},NAME:.metadata.name
      ARCH     NAME
      <none>   manager0.jbsandbox2
      <none>   manager1.jbsandbox2
      <none>   manager2.jbsandbox2
      <none>   worker0.jbsandbox2
      <none>   worker1.jbsandbox2
      <none>   worker2.jbsandbox2
      <none>   worker3.jbsandbox2
      <none>   worker4.jbsandbox2
      
      I've tried all sorts of different quoting and escape characters without any luck.

      Version-Release number of selected component (if applicable):

      Client Version: 4.18.1
      Kustomize Version: v5.4.2
      Server Version: 4.18.1
      Kubernetes Version: v1.31.5
      

      How reproducible:

          Consistent

      Steps to Reproduce:

          1. Log into command line of cluster
          2. Run $ oc get no -o custom-columns=ARCH:{.metadata.labels."kubernetes.io/arch"},NAME:.metadata.name
          

      Actual results:

      ARCH     NAME
      <none>   manager0.jbsandbox2
      <none>   manager1.jbsandbox2
      <none>   manager2.jbsandbox2
      <none>   worker0.jbsandbox2
      <none>   worker1.jbsandbox2
      <none>   worker2.jbsandbox2
      <none>   worker3.jbsandbox2
      <none>   worker4.jbsandbox2
      

      Expected results:

      ARCH     NAME
      s390x    manager0.jbsandbox2
      s390x    manager1.jbsandbox2
      s390x    manager2.jbsandbox2
      s390x    worker0.jbsandbox2
      s390x    worker1.jbsandbox2
      s390x    worker2.jbsandbox2
      amd64    worker3.jbsandbox2
      amd64    worker4.jbsandbox2

      Additional info:

      1. I have similar issues when trying to get other default labels like kubernetes.io/hostname or beta.kubernetes.io/os.
      2. I also tried using the jsonpath option like this:
      $ oc get no -o jsonpath='{range .items[*]}{.metadata.labels.kubernetes.io/arch}{"\n"}{end}' but got only blanks

              aguclu@redhat.com Arda Guclu
              joshuabeha Joshua Beha (Inactive)
              None
              None
              None
              None
              Votes:
              0 Vote for this issue
              Watchers:
              2 Start watching this issue

                Created:
                Updated:
                Resolved: