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-api.internals.client/find-preferred-route behaves not as expected on multiple match #13

Open
lotuc opened this issue Sep 5, 2023 · 0 comments

Comments

@lotuc
Copy link

lotuc commented Sep 5, 2023

kubernetes-api.core APIs uses internals.client/find-preferred-route for finding the route to be called.

Now kubernetes-api.internals.client/find-preferred-route does

  1. Search routes with find-route which only uses :kind and :action fields, this could lead to multiple match
  2. Filter out Status routes (which related to Enable 'Status' routes #6 )
  3. For multiple matched route, choose the one route for which its version is the current preferred version. If multiple such routes meets the condition, just choose the first one.

I'm encountering that two route matches all the condition:

(require '[kubernetes-api.internals.client :refer [kind action all-namespaces-route?] :as internals.client])   

(->> (internals.client/find-route k8s {:kind :Ingress
                                       :action :patch/json-merge})
     (filter (fn [x] (not (clojure.string/ends-with? (name x) "Status"))))
     (map (fn [route]
            (filter #(and (= (:name %) (internals.client/group-of k8s route))
                        (= (:version (:preferredVersion %)) (internals.client/version-of k8s route)))
                  (internals.client/all-versions k8s)))))

;; ->

(({:name "networking.internal.knative.dev",
   :versions
   [{:groupVersion "networking.internal.knative.dev/v1alpha1",
     :version "v1alpha1"}],
   :preferredVersion
   {:groupVersion "networking.internal.knative.dev/v1alpha1",
    :version "v1alpha1"}})
 ({:name "networking.k8s.io",
   :versions [{:groupVersion "networking.k8s.io/v1", :version "v1"}],
   :preferredVersion {:groupVersion "networking.k8s.io/v1", :version "v1"}}))

And it chooses "networking.internal.knative.dev" which is not what I expected and it can not be opted out (though I can hack it around thanks to with-redefs).

It would be great if route search & preferring option can be customized.

lotuc added a commit to lotuc/k8s-api that referenced this issue Sep 5, 2023
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

No branches or pull requests

1 participant