Skip to content

Error retrieving raw URIs from Rancher / Proxied-APIs #892

@strowi

Description

@strowi

Bug report

Might be related to #891 and #827 missing cluster_url on get --raw commands.

krane fails to get raw api-paths because it is missing the cluster_url on some requests:

[INFO][2022-05-27 10:05:20 +0200]	
[INFO][2022-05-27 10:05:20 +0200]	------------------------------------Phase 1: Initializing deploy------------------------------------
[INFO][2022-05-27 10:05:22 +0200]	All required parameters and files are present
[INFO][2022-05-27 10:05:22 +0200]	Discovering resources:
[WARN][2022-05-27 10:05:23 +0200]	The following command failed and cannot be retried: kubectl get --raw /apis/monitoring.coreos.com/v1alpha1 --context\=rvg --request-timeout\=15
[WARN][2022-05-27 10:05:23 +0200]	Error from server (NotFound): the server could not find the requested resource

[WARN][2022-05-27 10:05:23 +0200]	Error retrieving api path: Error from server (NotFound): the server could not find the requested resource
[WARN][2022-05-27 10:05:23 +0200]	The following command failed and cannot be retried: kubectl get --raw /apis/core.haproxy.org/v1alpha1 --context\=rvg --request-timeout\=15
[WARN][2022-05-27 10:05:23 +0200]	Error from server (NotFound): the server could not find the requested resource

Expected behavior: No errors, deployment should work.

Actual behavior: Deployment failed

Version(s) affected: 2.4.7

Steps to Reproduce

  1. setup some k8s-proxy tool like rancher
  2. try deploying via the rancher cluster-url "https://XYZ/k8s/clusters/c-gzcbw"
  3. see the above error.

Probable fix

A most probably dirty and not complete fix (there are probably other places to update) for me was changing the path in lib/krane/cluster_resource_discovery.rb:

lib/krane/cluster_resource_discovery.rb:

    def fetch_api_path(path)
      @api_path_cache[path] ||= begin
-        raw_json, err, st = kubectl.run("get", "--raw", path, attempts: 2, use_namespace: false)
+        raw_json, err, st = kubectl.run("get", "--raw", base_api_path + path, attempts: 2, use_namespace: false)
        if st.success?
          JSON.parse(raw_json)
        else

regards,
strowi

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions