kubernetes-sigs / kubernetes-sigs/controller-runtime

RestMapper cache is never invalidated when a client requests a group without specifying a version

Open
#3,542 0 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Dominant language
Go
Stars
3k
Forks
1.3k
Avg merge
2d 5h
Merged PRs (30d)
14

Description

If a client requests a mapping for an API group without specifying the version, the current code will always rely on findAPIGroupByNameAndMaybeAggregatedDiscoveryLocked to retrieve group resources using aggregated discovery.

But since this function looks at the apiGroups cache first, once an apiGroup has been discovered, its resources will never be updated. If some CRDs that declares new versions for an existing group are installed after this initial lookup, subsequent calls to mapper.RESTMapping("newKind") will continuously fail.

This has been observed in sylva project that uses flux kustomize controller. It sometimes fails to perform healthChecks on some resources and continuously returns a NoMatchError, whereas the CRD is installed for a while in cluster (see flux issue). Kustomize controller relies on kstatus library to perform healthCheck on resources, and that library does not provide any version while calling mapper.RESTMapping.

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 by locating findAPIGroupByNameAndMaybeAggregatedDiscoveryLocked and the apiGroups cache, then trace calls from mapper.RESTMapping when no version is supplied. Reproduce the sequence with an initial lookup followed by installing a CRD that adds a version, and verify the mapper refreshes resources instead of returning NoMatchError.

Written by the indexing model from the issue text.

Assessment

Tech stack
go
Domain
api, backend
Issue type
Bug
Difficulty
3/5
Estimated time
1-2 days
Activity status
Quiet
Clarity
Mostly clear
Newbie friendliness
52/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.