ManageIQ / ManageIQ/kubeclient

Could exceptions identify specific resource accessed?

Open
#415 0 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

enhancement help wanted
Dominant language
Ruby
Stars
426
Forks
171
PR merge metrics
No merged PRs in 30d

Description

I'm looking at app logs that perform many get_* calls, one of them failing, but I can't tell which, neither from kubeclient stack portion, nor the calling app:

[----] E, [2019-06-21T10:03:51.073003 #19344:590f4c] ERROR -- : [JSON::ParserError]: 765: unexpected token at 'This request caused apiserver to panic. Look in the logs for details.
'  Method:[block (2 levels) in <class:LogProxy>]
[----] E, [2019-06-21T10:03:51.073119 #19344:590f4c] ERROR -- : /usr/share/gems/gems/json-2.1.0/lib/json/common.rb:156:in `parse'
/usr/share/gems/gems/json-2.1.0/lib/json/common.rb:156:in `parse'
/opt/rh/cfme-gemset/gems/kubeclient-4.1.2/lib/kubeclient/common.rb:501:in `format_response'
/opt/rh/cfme-gemset/gems/kubeclient-4.1.2/lib/kubeclient/common.rb:315:in `get_entities'
/opt/rh/cfme-gemset/gems/kubeclient-4.1.2/lib/kubeclient/common.rb:206:in `block (2 levels) in define_entity_methods'
/opt/rh/cfme-gemset/bundler/gems/cfme-providers-kubernetes-339029025f99/app/models/manageiq/providers/kubernetes/container_manager/refresher_mixin.rb:67:in `block in fetch_entities'
/opt/rh/cfme-gemset/bundler/gems/cfme-providers-kubernetes-339029025f99/app/models/manageiq/providers/kubernetes/container_manager/refresher_mixin.rb:65:in `each'
/opt/rh/cfme-gemset/bundler/gems/cfme-providers-kubernetes-339029025f99/app/models/manageiq/providers/kubernetes/container_manager/refresher_mixin.rb:65:in `each_with_object'
/opt/rh/cfme-gemset/bundler/gems/cfme-providers-kubernetes-339029025f99/app/models/manageiq/providers/kubernetes/container_manager/refresher_mixin.rb:65:in `fetch_entities'
/opt/rh/cfme-gemset/bundler/gems/cfme-providers-openshift-eb55293f9470/app/models/manageiq/providers/openshift/container_manager/refresher.rb:30:in `block in collect_full_inventory'

This is an unfortunate interaction between the app (manageiq) doing client.send("get_#{entity[:name]}") in a loop:
https://github.com/ManageIQ/manageiq-providers-kubernetes/blob/bf6594110f8716f128a387e5a0817e89645d248e/app/models/manageiq/providers/kubernetes/container_manager/refresher_mixin.rb#L58-L67
and kubeclient defining method dynamically, so best you see in stack trace is generic get_entity:
https://github.com/abonas/kubeclient/blob/cb998b94a11ca271c1493d5d993804fd1c215a42/lib/kubeclient/common.rb#L207-L212

I know how to log better in the calling app, but I wonder if kubeclient could do something to make stack traces more informative?

I have some (ugly) ideas for dynamic methods like get_pod, but here's a harder challenge:
what about dynamic interfaces like .get(kind: ..., ..., metadata: {name: ..., }) that we want to add in #332 ? This is by definition a single method.

  • One idea I have is not worrying about descriptive stack frames, but annotating the final exception object with details — what operation, what kind, what namespace/name (or just full URL accessed).

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start with lib/kubeclient/common.rb, especially format_response, get_entities, and define_entity_methods, and compare the caller loop in refresher_mixin.rb at lines 58-67. Determine how failures can retain operation, resource, or URL context, including the proposed dynamic interface in #332; done means the reported get_* failure exposes which resource access failed.

Written by the indexing model from the issue text.

Assessment

Tech stack
kubernetes, ruby
Domain
api, backend-api-design
Issue type
Feature
Difficulty
5/5
Estimated time
Over a week
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
25/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.