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 retrieving raw URIs from Rancher / Proxied-APIs #892

Open
strowi opened this issue May 27, 2022 · 3 comments · May be fixed by #959
Open

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

strowi opened this issue May 27, 2022 · 3 comments · May be fixed by #959

Comments

@strowi
Copy link
Contributor

strowi commented May 27, 2022

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

@strowi
Copy link
Contributor Author

strowi commented Nov 16, 2022

For anyone interested - here is a compileable working version.

@strowi
Copy link
Contributor Author

strowi commented Jan 24, 2024

not to play gravedigger, but could anyone take a look? Just tried an update from 2.x to v3.4.0, and i am still running into the same issue, which is fixed for e.g. rancher with a simple:

diff --git a/lib/krane/cluster_resource_discovery.rb b/lib/krane/cluster_resource_discovery.rb
index 44f9689..e60af01 100644
--- a/lib/krane/cluster_resource_discovery.rb
+++ b/lib/krane/cluster_resource_discovery.rb
@@ -64,7 +64,7 @@ module Krane
 
     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?
           MultiJson.load(raw_json)
         else

pinging @timothysmith0609 - not sure you're the right person, but you fixed + merged my previous attempts mentioned on the top post.

@strowi
Copy link
Contributor Author

strowi commented Jul 19, 2024

Problem still exists with 3.6.0 so i created a PR, sadly i have no idea about the failing unit-tests ;(
But have verified it working on top-level and sub-domain cluster-urls.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

1 participant