replicatedhq / troubleshoot

Preflight Checks and Support Bundles Framework for Kubernetes Applications
https://troubleshoot.sh
Apache License 2.0
543 stars 93 forks source link

fix: Use correct cron job kind when discovering API versions #1554

Closed banjoh closed 4 months ago

banjoh commented 4 months ago

Description, Motivation and Context

Use correct cron job kind when discovering API versions

Fixes: https://github.com/replicatedhq/troubleshoot/issues/1553

Checklist

Does this PR introduce a breaking change?

diamonwiggins commented 4 months ago

I've approved, but I guess I do have a question. The issue this is referencing says that the issue was batch/v1beta1/cronjobs vs batch/v1/cronjobs. Does changing this from CronJobs to CronJob actually fix this?

banjoh commented 4 months ago

I've approved, but I guess I do have a question. The issue this is referencing says that the issue was batch/v1beta1/cronjobs vs batch/v1/cronjobs. Does changing this from CronJobs to CronJob actually fix this?

It does. Below is a snippet of the API description object fetched from the API server during discovery. The "kind": "CronJob") field is used in discovery.HasResource() to select the resource. That condition always failed due to the typo. The API call we see in the logs contains a concatenation of values from "groupVersion" and "name" fields. Hope that makes sense.

  {
    "groupVersion": "batch/v1",
    "resources": [
      {
        "name": "cronjobs",
        "singularName": "cronjob",
        "namespaced": true,
        "kind": "CronJob",
        "verbs": [
          "create",
          "delete",
          "deletecollection",
          "get",
          "list",
          "patch",
          "update",
          "watch"
        ],
        "shortNames": [
          "cj"
        ],
        "categories": [
          "all"
        ]
      },