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

kubernetes.json and openshift.json are invalid JSON #8554

Closed
murphye opened this issue Apr 14, 2020 · 4 comments
Closed

kubernetes.json and openshift.json are invalid JSON #8554

murphye opened this issue Apr 14, 2020 · 4 comments
Assignees
Labels
area/kubernetes kind/bug Something isn't working triage/wontfix This will not be worked on

Comments

@murphye
Copy link

murphye commented Apr 14, 2020

Describe the bug
The output from mvn clean package -Dquarkus.container-image.build=true results in invalid JSON data.

Expected behavior
kubernetes.json and openshift.json have valid JSON:

[
  {
  },
  {
  }
]

Actual behavior
kubernetes.json and openshift.json have invalid JSON.

It has multiple top-level elements, ie:

{
}
{
}

Note: oc apply doesn't seem to care that the JSON is not valid. That being said, this still is a potential problem for other JSON tools.

To Reproduce
Steps to reproduce the behavior:

  1. Add quarkus-openshift to project
  2. mvn clean package -Dquarkus.container-image.build=true
  3. Observe files under target/kubernetes
  4. Observer format of kubernetes.json and openshift.json with editor that has JSON validation

Configuration

Screenshots
Screen Shot 2020-04-13 at 11 52 48 PM

Environment (please complete the following information):

  • Output of uname -a or ver: Darwin MacBook-Pro-7 19.4.0 Darwin Kernel Version 19.4.0: Wed Mar 4 22:28:40 PST 2020; root:xnu-6153.101.6~15/RELEASE_X86_64 x86_64
  • Output of java -version: OpenJDK 64-Bit Server VM GraalVM CE 20.0.0 (build 11.0.6+9-jvmci-20.0-b02, mixed mode, sharing)
  • GraalVM version (if different from Java):
  • Quarkus version or git rev: 1.3.2
  • Build tool (ie. output of mvnw --version or gradlew --version): Apache Maven 3.6.3

Additional context
(Add any other context about the problem here.)

@murphye murphye added the kind/bug Something isn't working label Apr 14, 2020
@geoand
Copy link
Contributor

geoand commented Apr 14, 2020

@iocanel I think we have seen this before...

@murphye does this happen with 1.3.2.Final as well?

@murphye
Copy link
Author

murphye commented Apr 14, 2020

@geoand I meant 1.3.2, not 1.2.1. Was late at night :-)

@iocanel
Copy link
Contributor

iocanel commented May 4, 2020

@murphye: The issue I am having with [ { }, { } ] is getting kubectl to work with it.

For example, the JSON below [1] is valid, acceptable by both IDEA and other editors, yet kubectl and oc don't like it.

The options are the following:

  1. Leave it as is.
  2. Wrap the resources in a KubernetesList so that it's both valid JSON and acceptable by exiting tools.
  3. Use a different approach that satisfies both requirements.

Option 2 is interesting but that would mean that we have a different behavior between yaml and josn.

[1]:

[ {
    "apiVersion" : "v1",
    "kind" : "Service",
    "metadata" : {
      "labels" : {
        "app.kubernetes.io/name" : "example",
        "app.kubernetes.io/version" : "0.1-SNAPSHOT"
      },
      "name" : "example"
    },
    "spec" : {
      "ports" : [ {
        "name" : "http",
        "port" : 8080,
        "targetPort" : 8080
      } ],
      "selector" : {
        "app.kubernetes.io/name" : "example",
        "app.kubernetes.io/version" : "0.1-SNAPSHOT"
      },
      "type" : "ClusterIP"
    }
  }, {
    "apiVersion" : "apps/v1",
    "kind" : "Deployment",
    "metadata" : {
      "annotations" : {
        "app.dekorate.io/commit-id" : "8df750a6b5eb9c34f75fa5317dc48eed2777d219",
        "app.dekorate.io/vcs-url" : "https://github.com/iocanel/my-example.git"
      },
      "labels" : {
        "app.kubernetes.io/name" : "example",
        "app.kubernetes.io/version" : "0.1-SNAPSHOT"
      },
      "name" : "example"
    },
    "spec" : {
      "replicas" : 1,
      "selector" : {
        "matchLabels" : {
          "app.kubernetes.io/name" : "example",
          "app.kubernetes.io/version" : "0.1-SNAPSHOT"
        }
      },
      "template" : {
        "metadata" : {
          "annotations" : {
            "app.dekorate.io/commit-id" : "8df750a6b5eb9c34f75fa5317dc48eed2777d219",
            "app.dekorate.io/vcs-url" : "https://github.com/iocanel/my-example.git"
          },
          "labels" : {
            "app.kubernetes.io/name" : "example",
            "app.kubernetes.io/version" : "0.1-SNAPSHOT"
          }
        },
        "spec" : {
          "containers" : [ {
            "env" : [ {
              "name" : "KUBERNETES_NAMESPACE",
              "valueFrom" : {
                "fieldRef" : {
                  "fieldPath" : "metadata.namespace"
                }
              }
            } ],
            "image" : "quay.io/iocanel/example:latest",
            "imagePullPolicy" : "IfNotPresent",
            "livenessProbe" : {
              "failureThreshold" : 3,
              "httpGet" : {
                "path" : "/actuator/info",
                "port" : 8080,
                "scheme" : "HTTP"
              },
              "initialDelaySeconds" : 0,
              "periodSeconds" : 30,
              "successThreshold" : 1,
              "timeoutSeconds" : 10
            },
            "name" : "example",
            "ports" : [ {
              "containerPort" : 8080,
              "name" : "http",
              "protocol" : "TCP"
            } ],
            "readinessProbe" : {
              "failureThreshold" : 3,
              "httpGet" : {
                "path" : "/actuator/health",
                "port" : 8080,
                "scheme" : "HTTP"
              },
              "initialDelaySeconds" : 0,
              "periodSeconds" : 30,
              "successThreshold" : 1,
              "timeoutSeconds" : 10
            }
          } ]
        }
      }
    }
  } ]

@murphye
Copy link
Author

murphye commented May 5, 2020

@iocanel

#1 Describes issue that you faced:
kubernetes/kubernetes#8362

Seems like a poor resolution on their part because it doesn't work with JSONPath. Why they didn't just add support for [...] I have no idea.

#2 List format compatible with JSONPath:
https://kubernetes.io/docs/reference/kubectl/jsonpath/

Considering this is the behavior of Kubernetes JSON input per #1, I believe you should close this issue as wontfix.

@iocanel iocanel added the triage/wontfix This will not be worked on label May 6, 2020
@iocanel iocanel closed this as completed May 6, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
area/kubernetes kind/bug Something isn't working triage/wontfix This will not be worked on
Projects
None yet
Development

No branches or pull requests

3 participants