Skip to content
This repository has been archived by the owner on Jan 19, 2023. It is now read-only.

Calling the DynamicCache.gvrFromKey method when the gvr is not cached returns an nil object #3177

Closed
fly2F opened this issue Feb 24, 2022 · 0 comments · Fixed by #3178
Closed

Comments

@fly2F
Copy link
Contributor

fly2F commented Feb 24, 2022

What steps did you take and what happened:
[A clear and concise description of what the bug is, and what commands you ran.)

https://github.com/vmware-tanzu/octant/blob/master/internal/objectstore/dynamic_cache.go#L487

func (d *DynamicCache) gvrFromKey(ctx context.Context, key store.Key) (schema.GroupVersionResource, error) {

...

gk := key.GroupVersionKind().GroupKind()
var gvr schema.GroupVersionResource

v, ok := d.gvrCache.Load(gk)
if !ok {
	gvr, _, err := d.client.Resource(gk)    // **THIS LINE IS WRONG**: declares and assigns a new object
	if err != nil {
		return schema.GroupVersionResource{}, err
	} 

...

}

What did you expect to happen:

https://github.com/vmware-tanzu/octant/blob/master/internal/objectstore/dynamic_cache.go#L487

func (d *DynamicCache) gvrFromKey(ctx context.Context, key store.Key) (schema.GroupVersionResource, error) {

...

gk := key.GroupVersionKind().GroupKind()
var gvr schema.GroupVersionResource

v, ok := d.gvrCache.Load(gk)
if !ok {
            var err error
            gvr, _, err = d.client.Resource(gk) 
            if err != nil {
                    return schema.GroupVersionResource{}, err
            } 

...

}

Anything else you would like to add:
[Miscellaneous information that will assist in solving the issue.]

Environment:

  • Octant version (use octant version): master
  • Kubernetes version (use kubectl version): v1.23.1
  • OS (macOS 10.15, Windows 10, Ubuntu 19.10 etc): macOS 12.2.1
fly2F pushed a commit to fly2F/octant that referenced this issue Feb 24, 2022
fly2F pushed a commit to fly2F/octant that referenced this issue Feb 24, 2022
GuessWhoSamFoo pushed a commit that referenced this issue Feb 24, 2022
…ached returns an nil object #3177 (#3178)

Signed-off-by: Yasong Li <[email protected]>

Co-authored-by: liys87x <[email protected]>
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
1 participant