Skip to content

Fix parsing Kubernetes Resources without GroupVersionKind#38956

Merged
tigrato merged 2 commits into
masterfrom
tigrato/fix-parsing-resources-without-gvk
Mar 10, 2024
Merged

Fix parsing Kubernetes Resources without GroupVersionKind#38956
tigrato merged 2 commits into
masterfrom
tigrato/fix-parsing-resources-without-gvk

Conversation

@tigrato
Copy link
Copy Markdown
Contributor

@tigrato tigrato commented Mar 5, 2024

Kubernetes API has a concept of GroupVersionKind where each payload includes the type identification (group, version, kind) that uniquely identifies the resource structure withing Kubernetes itself.

Kubernetes API and kubectl always honor this information but custom tools and tools that use equivalents of json.Marshal without setting the GVK data fail to be decoded when decoding CREATE requests targeted to support kinds through Teleport.

This PR aims to fix that by providing an hint to the Kubernetes decoder that aims to be used as fallback GVK when unmarshaling a payload without the specification.

The hint is provided by the API request path that Teleport extracts from the request URI.

Changelog: Resolved sporadic errors caused by requests fail to comply with Kubernetes API spec by not specifying resource identifiers.

Fixes #37972

Kubernetes API has a concept of `GroupVersionKind` where each payload
includes the type identification `(group, version, kind)` that uniquely
identifies the resource withing Kubernetes itself.

Kubernetes API and `kubectl` always honor this information but custom
tools and tools that use equivalents of `json.Marshal` without setting
the `GVK` data fail to be decoded when decoding `CREATE` requests
targeted to support kinds.

This PR aims to fix that by providing an hint to the Kubernetes decoder
that aims to be used as fallback GVK when unmarshaling a payload without
the specification.

The hint is provided by the API request path that Teleport extracts from
the request URI.

Fixes #37972

Signed-off-by: Tiago Silva <tiago.silva@goteleport.com>
Comment thread lib/kube/proxy/scheme.go Outdated
Comment thread lib/kube/proxy/cluster_details.go
@tigrato
Copy link
Copy Markdown
Contributor Author

tigrato commented Mar 10, 2024

@zmb3 @fheinecke friendly ping

@public-teleport-github-review-bot public-teleport-github-review-bot Bot removed the request for review from fheinecke March 10, 2024 20:34
@tigrato tigrato added this pull request to the merge queue Mar 10, 2024
Merged via the queue into master with commit 1e77bb3 Mar 10, 2024
@tigrato tigrato deleted the tigrato/fix-parsing-resources-without-gvk branch March 10, 2024 21:31
@public-teleport-github-review-bot
Copy link
Copy Markdown

@tigrato See the table below for backport results.

Branch Result
branch/v14 Create PR
branch/v15 Create PR

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Object 'Kind' is missing on Teleport 14.x and above when using Lens "Node Shell"

3 participants