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

Malformed payloads cause excessive warning headers, potentially leading to 502 responses #9016

Open
mantis-toboggan-md opened this issue May 31, 2023 · 6 comments
Labels
Epic kind/bug research-needed Label for design issue that requires more technical research than what is in the issue description
Milestone

Comments

@mantis-toboggan-md
Copy link
Member

mantis-toboggan-md commented May 31, 2023

This is a follow up from #9012 and there's more detail in the comments there.

Steve adds a few fields to all resources:
metadata.fields
metadata.state
metadata.relationships
status.conditions[i].error
status.conditions[i].transitioning

When the user edits a resource, these are included in the payload, and each results in a warning header in the response.

The ui has been sending these extra fields for a while and it's only recently become a problem due to the combo of k8s 1.25 validating by default, and steve including warning headers as of 2.7.2. There will need to be more discussion around how to handle this, potentially in coordination with backend work.

@gaktive
Copy link
Member

gaktive commented Jun 1, 2023

@KevinJoiner to flesh out some of the impact here and then file a related backend ticket to see what can be done in the API since though UI can truncate, new fields could be added.

@richard-cox to explore around this a bit.

@richard-cox
Copy link
Member

richard-cox commented Jun 1, 2023

Useful References

original PR that brought this in - kubernetes/enhancements#2885
limited docs - https://kubernetes.io/docs/reference/using-api/api-concepts/#validation-for-unrecognized-or-duplicate-fields-setting-the-field-validation-level

Current state

I've created #9030 to help identify where we get warnings. Some output below (create followed by edit for pod, deployment and secret resources)

Validation Warnings for https://localhost:8005/v1/pods

299 - unknown field "spec.containers[0].__active"
299 - unknown field "spec.containers[0]._init"
299 - unknown field "spec.selector"
299 - unknown field "type"


Validation Warnings for https://localhost:8005/v1/pods/default/aaaaa

299 - unknown field "metadata.fields"
299 - unknown field "metadata.relationships"
299 - unknown field "metadata.state"
299 - unknown field "spec.containers[0].__active"
299 - unknown field "spec.containers[0]._init"
299 - unknown field "status.conditions[0].error"
299 - unknown field "status.conditions[0].lastUpdateTime"
299 - unknown field "status.conditions[0].transitioning"
299 - unknown field "status.conditions[1].error"
299 - unknown field "status.conditions[1].lastUpdateTime"
299 - unknown field "status.conditions[1].transitioning"
299 - unknown field "status.conditions[2].error"
299 - unknown field "status.conditions[2].lastUpdateTime"
299 - unknown field "status.conditions[2].transitioning"
299 - unknown field "status.conditions[3].error"
299 - unknown field "status.conditions[3].lastUpdateTime"
299 - unknown field "status.conditions[3].transitioning"



Validation Warnings for https://localhost:8005/v1/apps.deployments

299 - unknown field "spec.template.spec.containers[0].__active"
299 - unknown field "spec.template.spec.containers[0]._init"
299 - unknown field "type"

console.js:31 Validation Warnings for https://localhost:8005/v1/apps.deployments/default/aaaaa

299 - unknown field "metadata.fields"
299 - unknown field "metadata.relationships"
299 - unknown field "metadata.state"
299 - unknown field "spec.template.spec.containers[0].__active"
299 - unknown field "spec.template.spec.containers[0]._init"
299 - unknown field "status.conditions[0].error"
299 - unknown field "status.conditions[0].transitioning"
299 - unknown field "status.conditions[1].error"
299 - unknown field "status.conditions[1].transitioning"



Validation Warnings for https://localhost:8005/v1/secrets

299 - unknown field "_type"

Validation Warnings for https://localhost:8005/v1/secrets/default/asdsadsad

299 - unknown field "metadata.fields"
299 - unknown field "metadata.relationships"
299 - unknown field "metadata.state"

Create vs Edit

We do strip out some properties already, but only when cloning or saving as yaml. Importantly NOT when editing

  • see
    cleanForNew(ctx, obj) {
  • root properties - 'actions', 'links', 'status', 'id'
  • metadata properties - 'uid', 'ownerReferences', 'selfLink', 'creationTimestamp', 'deletionTimestamp', 'state', 'fields', 'relationships', 'generation', 'managedFields', 'resourceVersion',

Edit - Actually it looks like cleanForDownload does pretty much what we want to do, it even contains references to the error and transitioning status condition keys

Options

  • Head in sand / Ignore warnings
    • Add fieldValidation=Ignore to all post/put requests
  • Remove fields client side (basic edition)
    • We can add a toSave fn to the steve model (this pattern already exists) that calls a beefed up version of toJSON. The toJson will remove a similar set of properties as per cleanForNew
      • Should status be also removed?
    • On a more case by case basis remove properties outside of those removed above (in particular properties with a preceding _)
  • Remove fields client side (advanced edition)
    • Iterate through all fields removing properties not in schema
    • This does raise the question, shouldn't calculated fields added by steve be in the schema? Should they be marked as something that shouldn't be persisted?
  • Remove fields server side
    • Kind of like two client side options above, it either removes properties it added... or removes any not in a schema
    • This has the added benefit of supporting users who edit steve resources outside of the UI

@aalves08
Copy link
Member

aalves08 commented Jun 5, 2023

FYI @aalves08

@gaktive
Copy link
Member

gaktive commented Jul 19, 2023

We need to dig into this some more since we could tackle the generic ones, but that may be 80% of what's there.

This feels like an epic that needs to be split up.

@gaktive gaktive added the research-needed Label for design issue that requires more technical research than what is in the issue description label Jul 19, 2023
@richard-cox
Copy link
Member

The two issues required to resolve this are...

@richard-cox richard-cox removed size/3 Size Estimate 3 [zube]: Groomed labels Jul 19, 2023
@richard-cox
Copy link
Member

Linking backend changes (which covers some of the common cases) - rancher/rancher#41772

@richard-cox richard-cox modified the milestones: v2.8.0, v2.8.next1 Sep 5, 2023
@Shavindra Shavindra self-assigned this Oct 3, 2023
@zube zube bot unassigned richard-cox Oct 27, 2023
@nwmac nwmac modified the milestones: v2.9.0, v2.9.x Feb 27, 2024
@gaktive gaktive modified the milestones: v2.9.x, v2.12.0 Oct 18, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Epic kind/bug research-needed Label for design issue that requires more technical research than what is in the issue description
Projects
None yet
Development

No branches or pull requests

6 participants