client-go icon indicating copy to clipboard operation
client-go copied to clipboard

testing fixture should support types.ApplyPatchType

Open hypergig opened this issue 4 years ago • 31 comments

Currently all the fake clients leverage these fixtures:

https://github.com/kubernetes/client-go/blob/master/testing/fixture.go#L151-L184

Which are super great and helpful, but there is a new patch type in town and these fixtures don't know about it:

 types.ApplyPatchType

or

application/apply-patch+yaml

This leads to tests that perform server side applies to fail with PatchType is not supported. Support for SSA should be added to this fixture.

hypergig avatar Jun 24 '21 13:06 hypergig

The Kubernetes project currently lacks enough contributors to adequately respond to all issues and PRs.

This bot triages issues and PRs according to the following rules:

  • After 90d of inactivity, lifecycle/stale is applied
  • After 30d of inactivity since lifecycle/stale was applied, lifecycle/rotten is applied
  • After 30d of inactivity since lifecycle/rotten was applied, the issue is closed

You can:

  • Mark this issue or PR as fresh with /remove-lifecycle stale
  • Mark this issue or PR as rotten with /lifecycle rotten
  • Close this issue or PR with /close
  • Offer to help out with Issue Triage

Please send feedback to sig-contributor-experience at kubernetes/community.

/lifecycle stale

k8s-triage-robot avatar Sep 22 '21 14:09 k8s-triage-robot

/remove-lifecycle stale

mkumatag avatar Oct 18 '21 09:10 mkumatag

The Kubernetes project currently lacks enough contributors to adequately respond to all issues and PRs.

This bot triages issues and PRs according to the following rules:

  • After 90d of inactivity, lifecycle/stale is applied
  • After 30d of inactivity since lifecycle/stale was applied, lifecycle/rotten is applied
  • After 30d of inactivity since lifecycle/rotten was applied, the issue is closed

You can:

  • Mark this issue or PR as fresh with /remove-lifecycle stale
  • Mark this issue or PR as rotten with /lifecycle rotten
  • Close this issue or PR with /close
  • Offer to help out with Issue Triage

Please send feedback to sig-contributor-experience at kubernetes/community.

/lifecycle stale

k8s-triage-robot avatar Jan 16 '22 09:01 k8s-triage-robot

/remove-lifecycle stale

XinruZhang avatar Feb 14 '22 15:02 XinruZhang

The Kubernetes project currently lacks enough contributors to adequately respond to all issues and PRs.

This bot triages issues and PRs according to the following rules:

  • After 90d of inactivity, lifecycle/stale is applied
  • After 30d of inactivity since lifecycle/stale was applied, lifecycle/rotten is applied
  • After 30d of inactivity since lifecycle/rotten was applied, the issue is closed

You can:

  • Mark this issue or PR as fresh with /remove-lifecycle stale
  • Mark this issue or PR as rotten with /lifecycle rotten
  • Close this issue or PR with /close
  • Offer to help out with Issue Triage

Please send feedback to sig-contributor-experience at kubernetes/community.

/lifecycle stale

k8s-triage-robot avatar May 15 '22 16:05 k8s-triage-robot

/remove-lifecycle stale

mkumatag avatar May 15 '22 17:05 mkumatag

I would like to add types.ApplyPatchType into fixtures, Where can i find more info on types.ApplyPatchType so that i can update the file accordingly

Karthik-K-N avatar May 16 '22 15:05 Karthik-K-N

I think it's same? https://github.com/kubernetes/client-go/issues/970

Also: https://github.com/kubernetes/kubernetes/issues/104052

grishy avatar May 20 '22 17:05 grishy

Yeah, It will fix #970 as well

Karthik-K-N avatar May 23 '22 06:05 Karthik-K-N

So if I'm looking at the test code, I notice that we need to implement merging (i.e. decoding the patch and applying the patch, since that's what the other patch methods do) for the Apply patchtype.

The logic to do that in the apiserver is set-up here: https://github.com/kubernetes/kubernetes/blob/master/staging/src/k8s.io/apiserver/pkg/endpoints/handlers/patch.go#L470-L500

Mainly this code (decoding and applying):

	patchObj := &unstructured.Unstructured{Object: map[string]interface{}{}}
	if err := yaml.Unmarshal(p.patch, &patchObj.Object); err != nil {
		return nil, errors.NewBadRequest(fmt.Sprintf("error decoding YAML: %v", err))
	}

	obj, err := p.fieldManager.Apply(obj, patchObj, p.options.FieldManager, force)
	if err != nil {
		return obj, err
	}

The decoding is fairly straightforward, but the applying leads to a few questions:

  1. how do you get the fieldManager? I suspect it could live in the ObjectTracker a. You'll need the openapi schema to create the fieldmanager, how do you get that openapi? Not sure yet. b. the fieldManager object has a lot of fields for conversion, not sure how available these will be.
  2. Where are the options like FieldManager and Force come from? They are significant enough that you can't really skip these, I don't have an answer to this.

apelisse avatar Jun 03 '22 15:06 apelisse

Thanks @apelisse for your inputs, Instead of handling the patch here in client-go, How about creating a util package as like stratergicmergepatch and utilizing it over here, Is this sound good.

Karthik-K-N avatar Jun 07 '22 13:06 Karthik-K-N

You can try, I'm not entirely sure what the code will look like right now, so I'm not entirely sure where it should live yet.

apelisse avatar Jun 07 '22 15:06 apelisse

The Kubernetes project currently lacks enough contributors to adequately respond to all issues and PRs.

This bot triages issues and PRs according to the following rules:

  • After 90d of inactivity, lifecycle/stale is applied
  • After 30d of inactivity since lifecycle/stale was applied, lifecycle/rotten is applied
  • After 30d of inactivity since lifecycle/rotten was applied, the issue is closed

You can:

  • Mark this issue or PR as fresh with /remove-lifecycle stale
  • Mark this issue or PR as rotten with /lifecycle rotten
  • Close this issue or PR with /close
  • Offer to help out with Issue Triage

Please send feedback to sig-contributor-experience at kubernetes/community.

/lifecycle stale

k8s-triage-robot avatar Sep 05 '22 16:09 k8s-triage-robot

The Kubernetes project currently lacks enough active contributors to adequately respond to all issues and PRs.

This bot triages issues and PRs according to the following rules:

  • After 90d of inactivity, lifecycle/stale is applied
  • After 30d of inactivity since lifecycle/stale was applied, lifecycle/rotten is applied
  • After 30d of inactivity since lifecycle/rotten was applied, the issue is closed

You can:

  • Mark this issue or PR as fresh with /remove-lifecycle rotten
  • Close this issue or PR with /close
  • Offer to help out with Issue Triage

Please send feedback to sig-contributor-experience at kubernetes/community.

/lifecycle rotten

k8s-triage-robot avatar Oct 05 '22 17:10 k8s-triage-robot

@apelisse

Where are the options like FieldManager and Force come from? They are significant enough that you can't really skip these, I don't have an answer to this.

These can be taken from metav1.PatchOptions{} as normal in the client's patch call, so at least that's the easy part.

stevekuznetsov avatar Oct 28 '22 15:10 stevekuznetsov

A quick read of the constructors here shows that OpenAPI + a scheme should be sufficient-ish to get this working, I think.

stevekuznetsov avatar Oct 28 '22 15:10 stevekuznetsov

@justinsb is working on doing something somewhat similiar in https://github.com/kubernetes-sigs/kubebuilder-declarative-pattern/pull/270. I think we should do something that can be re-used throughout.

We would also probably need to revive/finish https://github.com/kubernetes/kubernetes/pull/87872 so that getting the openapi into the right format would be easier.

apelisse avatar Nov 14 '22 23:11 apelisse

The Kubernetes project currently lacks enough active contributors to adequately respond to all issues and PRs.

This bot triages issues according to the following rules:

  • After 90d of inactivity, lifecycle/stale is applied
  • After 30d of inactivity since lifecycle/stale was applied, lifecycle/rotten is applied
  • After 30d of inactivity since lifecycle/rotten was applied, the issue is closed

You can:

  • Reopen this issue with /reopen
  • Mark this issue as fresh with /remove-lifecycle rotten
  • Offer to help out with Issue Triage

Please send feedback to sig-contributor-experience at kubernetes/community.

/close not-planned

k8s-triage-robot avatar Dec 14 '22 23:12 k8s-triage-robot

@k8s-triage-robot: Closing this issue, marking it as "Not Planned".

In response to this:

The Kubernetes project currently lacks enough active contributors to adequately respond to all issues and PRs.

This bot triages issues according to the following rules:

  • After 90d of inactivity, lifecycle/stale is applied
  • After 30d of inactivity since lifecycle/stale was applied, lifecycle/rotten is applied
  • After 30d of inactivity since lifecycle/rotten was applied, the issue is closed

You can:

  • Reopen this issue with /reopen
  • Mark this issue as fresh with /remove-lifecycle rotten
  • Offer to help out with Issue Triage

Please send feedback to sig-contributor-experience at kubernetes/community.

/close not-planned

Instructions for interacting with me using PR comments are available here. If you have questions or suggestions related to my behavior, please file an issue against the kubernetes/test-infra repository.

k8s-ci-robot avatar Dec 14 '22 23:12 k8s-ci-robot

/reopen

apelisse avatar Dec 15 '22 16:12 apelisse

@apelisse: Reopened this issue.

In response to this:

/reopen

Instructions for interacting with me using PR comments are available here. If you have questions or suggestions related to my behavior, please file an issue against the kubernetes/test-infra repository.

k8s-ci-robot avatar Dec 15 '22 16:12 k8s-ci-robot

The Kubernetes project currently lacks enough active contributors to adequately respond to all issues and PRs.

This bot triages issues according to the following rules:

  • After 90d of inactivity, lifecycle/stale is applied
  • After 30d of inactivity since lifecycle/stale was applied, lifecycle/rotten is applied
  • After 30d of inactivity since lifecycle/rotten was applied, the issue is closed

You can:

  • Reopen this issue with /reopen
  • Mark this issue as fresh with /remove-lifecycle rotten
  • Offer to help out with Issue Triage

Please send feedback to sig-contributor-experience at kubernetes/community.

/close not-planned

k8s-triage-robot avatar Jan 14 '23 16:01 k8s-triage-robot

@k8s-triage-robot: Closing this issue, marking it as "Not Planned".

In response to this:

The Kubernetes project currently lacks enough active contributors to adequately respond to all issues and PRs.

This bot triages issues according to the following rules:

  • After 90d of inactivity, lifecycle/stale is applied
  • After 30d of inactivity since lifecycle/stale was applied, lifecycle/rotten is applied
  • After 30d of inactivity since lifecycle/rotten was applied, the issue is closed

You can:

  • Reopen this issue with /reopen
  • Mark this issue as fresh with /remove-lifecycle rotten
  • Offer to help out with Issue Triage

Please send feedback to sig-contributor-experience at kubernetes/community.

/close not-planned

Instructions for interacting with me using PR comments are available here. If you have questions or suggestions related to my behavior, please file an issue against the kubernetes/test-infra repository.

k8s-ci-robot avatar Jan 14 '23 16:01 k8s-ci-robot

/reopen /remove-lifecycle rotten

(I assume this was the intention)

sbueringer avatar Jan 16 '23 09:01 sbueringer

@sbueringer: Reopened this issue.

In response to this:

/reopen /remove-lifecycle rotten

(I assume this was the intention)

Instructions for interacting with me using PR comments are available here. If you have questions or suggestions related to my behavior, please file an issue against the kubernetes/test-infra repository.

k8s-ci-robot avatar Jan 16 '23 09:01 k8s-ci-robot

The Kubernetes project currently lacks enough contributors to adequately respond to all issues.

This bot triages un-triaged issues according to the following rules:

  • After 90d of inactivity, lifecycle/stale is applied
  • After 30d of inactivity since lifecycle/stale was applied, lifecycle/rotten is applied
  • After 30d of inactivity since lifecycle/rotten was applied, the issue is closed

You can:

  • Mark this issue as fresh with /remove-lifecycle stale
  • Close this issue with /close
  • Offer to help out with Issue Triage

Please send feedback to sig-contributor-experience at kubernetes/community.

/lifecycle stale

k8s-triage-robot avatar Apr 16 '23 09:04 k8s-triage-robot

The Kubernetes project currently lacks enough active contributors to adequately respond to all issues.

This bot triages un-triaged issues according to the following rules:

  • After 90d of inactivity, lifecycle/stale is applied
  • After 30d of inactivity since lifecycle/stale was applied, lifecycle/rotten is applied
  • After 30d of inactivity since lifecycle/rotten was applied, the issue is closed

You can:

  • Mark this issue as fresh with /remove-lifecycle rotten
  • Close this issue with /close
  • Offer to help out with Issue Triage

Please send feedback to sig-contributor-experience at kubernetes/community.

/lifecycle rotten

k8s-triage-robot avatar May 16 '23 10:05 k8s-triage-robot

/cc /remove-lifecycle rotten

Shouldn't this issue be over in k/k? That's where the code gets developed.

pohly avatar May 26 '23 16:05 pohly

/cc /remove-lifecycle rotten

Shouldn't this issue be over in k/k? That's where the code gets developed.

🤷 sure?

should this repo have issues enabled then because it's just a gen stage?

jordan-da avatar May 26 '23 16:05 jordan-da

The Kubernetes project currently lacks enough contributors to adequately respond to all issues.

This bot triages un-triaged issues according to the following rules:

  • After 90d of inactivity, lifecycle/stale is applied
  • After 30d of inactivity since lifecycle/stale was applied, lifecycle/rotten is applied
  • After 30d of inactivity since lifecycle/rotten was applied, the issue is closed

You can:

  • Mark this issue as fresh with /remove-lifecycle stale
  • Close this issue with /close
  • Offer to help out with Issue Triage

Please send feedback to sig-contributor-experience at kubernetes/community.

/lifecycle stale

k8s-triage-robot avatar Jan 21 '24 09:01 k8s-triage-robot