Fixes #3030 (from 2014, would that be a record?)
The current state is ugly, but could be tidied up and tests added. I put a random test-cmd check in there for proof.
Any concerns about where and how I did this? It requires
I'd probably reconcile the pkg/api/meta
cycle by pushing these into the pkg/runtime/scheme
package.
@kubernetes/sig-api-machinery-bugs
@smarterclayton @liggitt @lavalamp @sttts
https://github.com/kubernetes/kubernetes/pull/63972
—
You are receiving this because you are on a team that was mentioned.
Reply to this email directly, view it on GitHub, or mute the thread.
@deads2k: Adding the "do-not-merge/release-note-label-needed" label because no release-note block was detected, please follow our release note process to remove it.
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.
[APPROVALNOTIFIER] This PR is APPROVED
This pull-request has been approved by: deads2k
The full list of commands accepted by this bot can be found here.
The pull request process is described here
Needs approval from an approver in each of these files:Approvers can indicate their approval by writing /approve
in a comment
Approvers can cancel approval by writing /approve cancel
in a comment
@deads2k: The following test failed, say /retest
to rerun them all:
Test name | Commit | Details | Rerun command |
---|---|---|---|
pull-kubernetes-e2e-kops-aws | 931943b | link | /test pull-kubernetes-e2e-kops-aws |
Full PR test history. Your PR dashboard. Please help us cut down on flakes by linking to an open issue when you hit one in your PR.
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. I understand the commands that are listed here.
@deads2k: The following tests failed, say /retest
to rerun them all:
Test name | Commit | Details | Rerun command |
---|
pull-kubernetes-bazel-test | 931943b | link | /test pull-kubernetes-bazel-test |
Full PR test history. Your PR dashboard. Please help us cut down on flakes by linking to an open issue when you hit one in your PR.
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. I understand the commands that are listed here.
—
@lavalamp commented on this pull request.
In staging/src/k8s.io/apimachinery/pkg/runtime/scheme.go:
> if copy { obj = obj.DeepCopyObject() } - setTargetKind(obj, kind) - return obj, nil + err := s.setTargetKind(obj, kind) + return obj, err
Please return nil, err
if err is not nil, makes it clear that obj can't be used if there was an error.
@lavalamp commented on this pull request.
In hack/make-rules/test-cmd-util.sh:
> @@ -4861,6 +4861,10 @@ runTests() { kube::log::status "Creating namespace ${ns_name}" kubectl create namespace "${ns_name}" kubectl config set-context "${CONTEXT}" --namespace="${ns_name}" + + # convenient spot to check for namespace kinds being set. + # TODO before merge, I'll make a real test
...and add a TODO that we probably need to do this for embedded types that don't happen to be list items, if we have any :(
How badly does this hurt performance? LGTM
How badly does this hurt performance?
I had the same question, it looks like a really complex inner loop. I'm imagining this running on every item listed across all resources on informer lists.
I'll find the benchmark and run it. How much are we willing to tolerate to make life easier for every client? Some percentage of the entire encoding path I'd imagine
@deads2k commented on this pull request.
In hack/make-rules/test-cmd-util.sh:
> @@ -4861,6 +4861,10 @@ runTests() { kube::log::status "Creating namespace ${ns_name}" kubectl create namespace "${ns_name}" kubectl config set-context "${CONTEXT}" --namespace="${ns_name}" + + # convenient spot to check for namespace kinds being set. + # TODO before merge, I'll make a real test
...and add a TODO that we probably need to do this for embedded types that don't happen to be list items, if we have any :(
Not as bad as you think. My test failures here indicate that we actually check this in fuzz tests, so I update the fuzz tests and we get full coverage.
@deads2k commented on this pull request.
In staging/src/k8s.io/apimachinery/pkg/runtime/scheme.go:
> if copy { obj = obj.DeepCopyObject() } - setTargetKind(obj, kind) - return obj, nil + err := s.setTargetKind(obj, kind) + return obj, err
Please return nil, err if err is not nil, makes it clear that obj can't be used if there was an error.
ok
I had the same question, it looks like a really complex inner loop. I'm imagining this running on every item listed across all resources on informer lists.
Remember that this is only down the conversion path. Anything on external types doesn't get converted, just decoded. This won't impact the controllers on the read side. The real hit is server-side, where we already walk the list multiple times.
I think I'm willing to pay 5%, but I'm not sure about the scalability folks.
5% seems fair. It's a big behavior benefit.
@wojtek-t @shyamjvs is there a good existing benchmark in the code I should be looking at for a conversion change. We'll hit this on the api-server when serving a list.
@sttts commented on this pull request.
In staging/src/k8s.io/apimachinery/pkg/runtime/scheme.go:
> +func isListType(obj Object) bool { + // if we're a runtime.Unstructured, check whether this is a list. + // TODO: refactor GetItemsPtr to use an interface that returns []runtime.Object + if unstructured, ok := obj.(Unstructured); ok { + return unstructured.IsList() + } + + _, err := getItemsPtr(obj) + return err == nil +} + +// GetItemsPtr returns a pointer to the list object's Items member. +// If 'list' doesn't have an Items member, it's not really a list type +// and an error will be returned. +// This function will either return a pointer to a slice, or an error, but not both. +func getItemsPtr(list Object) (interface{}, error) {
this duplicated code here concerns me. Something is wrong with the layering.
Why not move meta.GetItemsPtr
here?
@sttts commented on this pull request.
In staging/src/k8s.io/apimachinery/pkg/runtime/scheme.go:
> +func isListType(obj Object) bool { + // if we're a runtime.Unstructured, check whether this is a list. + // TODO: refactor GetItemsPtr to use an interface that returns []runtime.Object + if unstructured, ok := obj.(Unstructured); ok { + return unstructured.IsList() + } + + _, err := getItemsPtr(obj) + return err == nil +} + +// GetItemsPtr returns a pointer to the list object's Items member. +// If 'list' doesn't have an Items member, it's not really a list type +// and an error will be returned. +// This function will either return a pointer to a slice, or an error, but not both. +func getItemsPtr(list Object) (interface{}, error) {
Same for EachListItem.
is there a good existing benchmark in the code I should be looking at for a conversion change.
@deads2k I'm not sure what you're exactly looking for, but there a whole bunch of benchmarks under pkg/api/testing
(especially conversion_test.go
) that you might find useful.
I think I'm willing to pay 5%, but I'm not sure about the scalability folks.
IIUC that you mean 5% increase in list latencies, that might be ok. We have some slack b/w our current latencies and SLO for list calls (which is atm 5s for namespaced list calls and 10s for cluster-scoped ones).
cc @wojtek-t
@deads2k commented on this pull request.
In staging/src/k8s.io/apimachinery/pkg/runtime/scheme.go:
> +func isListType(obj Object) bool { + // if we're a runtime.Unstructured, check whether this is a list. + // TODO: refactor GetItemsPtr to use an interface that returns []runtime.Object + if unstructured, ok := obj.(Unstructured); ok { + return unstructured.IsList() + } + + _, err := getItemsPtr(obj) + return err == nil +} + +// GetItemsPtr returns a pointer to the list object's Items member. +// If 'list' doesn't have an Items member, it's not really a list type +// and an error will be returned. +// This function will either return a pointer to a slice, or an error, but not both. +func getItemsPtr(list Object) (interface{}, error) {
this duplicated code here concerns me. Something is wrong with the layering.
Why not move meta.GetItemsPtr here?
From the description of a WIP pull: "I'd probably reconcile the pkg/api/meta cycle by pushing these into the pkg/runtime/scheme package.". I figure I'll expose them and meta will keep it's wrapper to here since that's where they make more sense.
[APPROVALNOTIFIER] This PR is NOT APPROVED
This pull-request has been approved by: deads2k
To fully approve this pull request, please assign additional approvers.
We suggest the following additional approver: lavalamp
Assign the PR to them by writing /assign @lavalamp
in a comment when ready.
The full list of commands accepted by this bot can be found here.
The pull request process is described here
Needs approval from an approver in each of these files:Approvers can indicate their approval by writing /approve
in a comment
Approvers can cancel approval by writing /approve cancel
in a comment
—
No real difference for normal types, but lists are a more significant bump:
OLD BenchmarkReplicationControllerListConversion-8 100000 14848 ns/op
NEW BenchmarkReplicationControllerListConversion-8 100000 16719 ns/op
@deads2k: The following tests failed, say /retest
to rerun them all:
Test name | Commit | Details | Rerun command |
---|
pull-kubernetes-e2e-kops-aws | 931943b | link | /test pull-kubernetes-e2e-kops-aws |
pull-kubernetes-bazel-test | 931943b | link | /test pull-kubernetes-bazel-test |
pull-kubernetes-node-e2e | b7dd2a7 | link | /test pull-kubernetes-node-e2e |
Full PR test history. Your PR dashboard. Please help us cut down on flakes by linking to an open issue when you hit one in your PR.
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. I understand the commands that are listed here.
—
@deads2k: The following tests failed, say /retest
to rerun them all:
Test name | Commit | Details | Rerun command |
---|
pull-kubernetes-bazel-test | b7dd2a7 | link | /test pull-kubernetes-bazel-test |
Full PR test history. Your PR dashboard. Please help us cut down on flakes by linking to an open issue when you hit one in your PR.
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. I understand the commands that are listed here.
—
@deads2k: The following tests failed, say /retest
to rerun them all:
Test name | Commit | Details | Rerun command |
---|
pull-kubernetes-e2e-kops-aws | 931943b | link | /test pull-kubernetes-e2e-kops-aws |
pull-kubernetes-node-e2e | b7dd2a7 | link | /test pull-kubernetes-node-e2e |
pull-kubernetes-bazel-test | b7dd2a7 | link | /test pull-kubernetes-bazel-test |
pull-kubernetes-verify | b7dd2a7 | link | /test pull-kubernetes-verify |
Full PR test history. Your PR dashboard. Please help us cut down on flakes by linking to an open issue when you hit one in your PR.
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. I understand the commands that are listed here.
—
@deads2k pushed 1 commit.
—
You are receiving this because you are subscribed to this thread.
View it on GitHub or mute the thread.
Alright, got a POC commit that shows how to do this fast enough.
with specific methods BenchmarkReplicationControllerListConversion-8 100000 14819 ns/op
[APPROVALNOTIFIER] This PR is NOT APPROVED
This pull-request has been approved by: deads2k
To fully approve this pull request, please assign additional approvers.
We suggest the following additional approver: lavalamp
Assign the PR to them by writing /assign @lavalamp
in a comment when ready.
The full list of commands accepted by this bot can be found here.
The pull request process is described here
Needs approval from an approver in each of these files:Approvers can indicate their approval by writing /approve
in a comment
Approvers can cancel approval by writing /approve cancel
in a comment
—
@deads2k commented on this pull request.
In staging/src/k8s.io/api/core/v1/types.go:
> @@ -5090,3 +5091,20 @@ const ( // and data streams for a single forwarded connection PortForwardRequestIDHeader = "requestID" ) + +func (l *ReplicationControllerList) EachListItem(fn func(runtime.Object) error) error { + for i := range l.Items { + if err := fn(&l.Items[i]); err != nil { + return err + } + } + return nil +} + +func (l *ReplicationControllerList) AssignTypes() error {
Who's got an appetite to generate these?
@deads2k: The following tests failed, say /retest
to rerun them all:
Test name | Commit | Details | Rerun command |
---|
pull-kubernetes-bazel-test | b7dd2a7 | link | /test pull-kubernetes-bazel-test |
pull-kubernetes-verify | b7dd2a7 | link | /test pull-kubernetes-verify |
pull-kubernetes-node-e2e | 303a1e2 | link | /test pull-kubernetes-node-e2e |
Full PR test history. Your PR dashboard. Please help us cut down on flakes by linking to an open issue when you hit one in your PR.
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. I understand the commands that are listed here.
—
@deads2k: The following tests failed, say /retest
to rerun them all:
Test name | Commit | Details | Rerun command |
---|
pull-kubernetes-e2e-kops-aws | 931943b | link | /test pull-kubernetes-e2e-kops-aws |
pull-kubernetes-bazel-test | b7dd2a7 | link | /test pull-kubernetes-bazel-test |
pull-kubernetes-verify | 303a1e2 | link | /test pull-kubernetes-verify |
@deads2k: The following tests failed, say /retest
to rerun them all:
Test name | Commit | Details | Rerun command |
---|
pull-kubernetes-bazel-test | b7dd2a7 | link | /test pull-kubernetes-bazel-test |
pull-kubernetes-node-e2e | 303a1e2 | link | /test pull-kubernetes-node-e2e |
pull-kubernetes-verify | 303a1e2 | link | /test pull-kubernetes-verify |
pull-kubernetes-e2e-kops-aws | 303a1e2 | link | /test pull-kubernetes-e2e-kops-aws |
@deads2k: The following tests failed, say /retest
to rerun them all:
Test name | Commit | Details | Rerun command |
---|
pull-kubernetes-node-e2e | 303a1e2 | link | /test pull-kubernetes-node-e2e |
pull-kubernetes-verify | 303a1e2 | link | /test pull-kubernetes-verify |
pull-kubernetes-e2e-kops-aws | 303a1e2 | link | /test pull-kubernetes-e2e-kops-aws |
pull-kubernetes-bazel-test | 303a1e2 | link | /test pull-kubernetes-bazel-test |
@deads2k: The following tests failed, say /retest
to rerun them all:
Test name | Commit | Details | Rerun command |
---|
pull-kubernetes-node-e2e | 303a1e2 | link | /test pull-kubernetes-node-e2e |
pull-kubernetes-verify | 303a1e2 | link | /test pull-kubernetes-verify |
pull-kubernetes-e2e-kops-aws | 303a1e2 | link | /test pull-kubernetes-e2e-kops-aws |
pull-kubernetes-bazel-test | 303a1e2 | link | /test pull-kubernetes-bazel-test |
pull-kubernetes-kubemark-e2e-gce | 303a1e2 | link | /test pull-kubernetes-kubemark-e2e-gce |
@sttts commented on this pull request.
In staging/src/k8s.io/api/core/v1/types.go:
> @@ -5090,3 +5091,20 @@ const ( // and data streams for a single forwarded connection PortForwardRequestIDHeader = "requestID" ) + +func (l *ReplicationControllerList) EachListItem(fn func(runtime.Object) error) error { + for i := range l.Items { + if err := fn(&l.Items[i]); err != nil { + return err + } + } + return nil +} + +func (l *ReplicationControllerList) AssignTypes() error {
Would a generic helper SetTypeMeta(gv)
using an accessor do the same thing?
@sttts commented on this pull request.
In staging/src/k8s.io/api/core/v1/types.go:
> @@ -5090,3 +5091,20 @@ const ( // and data streams for a single forwarded connection PortForwardRequestIDHeader = "requestID" ) + +func (l *ReplicationControllerList) EachListItem(fn func(runtime.Object) error) error { + for i := range l.Items { + if err := fn(&l.Items[i]); err != nil { + return err + } + } + return nil +} + +func (l *ReplicationControllerList) AssignTypes() error {
Also related: there was a discussion that we might want to generate register.go.
@deads2k: PR needs rebase.
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.
—
Issues go stale after 90d of inactivity.
Mark the issue as fresh with /remove-lifecycle stale
.
Stale issues rot after an additional 30d of inactivity and eventually close.
If this issue is safe to close now please do so with /close
.
Send feedback to sig-testing, kubernetes/test-infra and/or fejta.
/lifecycle stale
Stale issues rot after 30d of inactivity.
Mark the issue as fresh with /remove-lifecycle rotten
.
Rotten issues close after an additional 30d of inactivity.
If this issue is safe to close now please do so with /close
.
Send feedback to sig-testing, kubernetes/test-infra and/or fejta.
/lifecycle rotten
Hey, are there any updates on this? I'd love to see this fixed as it's convenient to have the Kind and APIVersion for each resource. Let me know how I can help move this along.
Rotten issues close after 30d of inactivity.
Reopen the issue with /reopen
.
Mark the issue as fresh with /remove-lifecycle rotten
.
Send feedback to sig-testing, kubernetes/test-infra and/or fejta.
/close
Closed #63972.
@fejta-bot: Closed this PR.
In response to this:
Rotten issues close after 30d of inactivity.
Reopen the issue with/reopen
.
Mark the issue as fresh with/remove-lifecycle rotten
.Send feedback to sig-testing, kubernetes/test-infra and/or fejta.
/close
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.
—
/remove-lifecycle rotten
/reopen
@nfons: You can't reopen an issue/PR unless you authored it or you are a collaborator.
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.
—
Reopening based on ^^
/reopen
Reopened #63972.
@nikhita: Reopened this PR.
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.
—
[APPROVALNOTIFIER] This PR is NOT APPROVED
This pull-request has been approved by: deads2k
To fully approve this pull request, please assign additional approvers.
We suggest the following additional approver: lavalamp
If they are not already assigned, you can assign the PR to them by writing /assign @lavalamp
in a comment when ready.
The full list of commands accepted by this bot can be found here.
The pull request process is described here
Needs approval from an approver in each of these files:Approvers can indicate their approval by writing /approve
in a comment
Approvers can cancel approval by writing /approve cancel
in a comment
—
—
@deads2k: The following tests failed, say /retest
to rerun them all:
Test name | Commit | Details | Rerun command |
---|
pull-kubernetes-node-e2e | 303a1e2 | link | /test pull-kubernetes-node-e2e |
pull-kubernetes-verify | 303a1e2 | link | /test pull-kubernetes-verify |
pull-kubernetes-e2e-kops-aws | 303a1e2 | link | /test pull-kubernetes-e2e-kops-aws |
pull-kubernetes-kubemark-e2e-gce | 303a1e2 | link | /test pull-kubernetes-kubemark-e2e-gce |
pull-kubernetes-e2e-gce | 303a1e2 | link | /test pull-kubernetes-e2e-gce |
pull-kubernetes-bazel-test | 303a1e2 | link | /test pull-kubernetes-bazel-test |
@deads2k: The following tests failed, say /retest
to rerun them all:
Test name | Commit | Details | Rerun command |
---|
@deads2k: The following tests failed, say /retest
to rerun them all:
Test name | Commit | Details | Rerun command |
---|
Issues go stale after 90d of inactivity.
Mark the issue as fresh with /remove-lifecycle stale
.
Stale issues rot after an additional 30d of inactivity and eventually close.
If this issue is safe to close now please do so with /close
.
Send feedback to sig-testing, kubernetes/test-infra and/or fejta.
/lifecycle stale
Stale issues rot after 30d of inactivity.
Mark the issue as fresh with /remove-lifecycle rotten
.
Rotten issues close after an additional 30d of inactivity.
If this issue is safe to close now please do so with /close
.
Send feedback to sig-testing, kubernetes/test-infra and/or fejta.
/lifecycle rotten
Rotten issues close after 30d of inactivity.
Reopen the issue with /reopen
.
Mark the issue as fresh with /remove-lifecycle rotten
.
Send feedback to sig-testing, kubernetes/test-infra and/or fejta.
/close
@fejta-bot: Closed this PR.
In response to this:
Rotten issues close after 30d of inactivity.
Reopen the issue with/reopen
.
Mark the issue as fresh with/remove-lifecycle rotten
.
Send feedback to sig-testing, kubernetes/test-infra and/or fejta.
/close
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.
—
Closed #63972.
Any updates?
any update?
—
You are receiving this because you are on a team that was mentioned.
Reply to this email directly, view it on GitHub, or unsubscribe.
The lack of this fix bit me again today.
I just ran into this
—
Reply to this email directly, view it on GitHub, or unsubscribe.
You are receiving this because you are on a team that was mentioned.