mirror of
https://github.com/k3s-io/kubernetes.git
synced 2025-07-27 13:37:30 +00:00
Merge pull request #33101 from hongchaodeng/etcd_fix
Automatic merge from submit-queue Work around the etcd watch issue fix #32770 Underlyingly, differentiating context will unshare the grpc stream.
This commit is contained in:
commit
c24e7b5cba
@ -34,6 +34,8 @@ import (
|
|||||||
"k8s.io/kubernetes/pkg/runtime"
|
"k8s.io/kubernetes/pkg/runtime"
|
||||||
"k8s.io/kubernetes/pkg/types"
|
"k8s.io/kubernetes/pkg/types"
|
||||||
"k8s.io/kubernetes/pkg/util/wait"
|
"k8s.io/kubernetes/pkg/util/wait"
|
||||||
|
|
||||||
|
"golang.org/x/net/context"
|
||||||
)
|
)
|
||||||
|
|
||||||
type Tester struct {
|
type Tester struct {
|
||||||
@ -1233,6 +1235,7 @@ func (t *Tester) testWatchFields(obj runtime.Object, emitFn EmitFunc, fieldsPass
|
|||||||
for _, field := range fieldsPass {
|
for _, field := range fieldsPass {
|
||||||
for _, action := range actions {
|
for _, action := range actions {
|
||||||
options := &api.ListOptions{FieldSelector: field.AsSelector(), ResourceVersion: "1"}
|
options := &api.ListOptions{FieldSelector: field.AsSelector(), ResourceVersion: "1"}
|
||||||
|
ctx = context.WithValue(context.WithValue(ctx, "field", field), "action", action)
|
||||||
watcher, err := t.storage.(rest.Watcher).Watch(ctx, options)
|
watcher, err := t.storage.(rest.Watcher).Watch(ctx, options)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
t.Errorf("unexpected error: %v, %v", err, action)
|
t.Errorf("unexpected error: %v, %v", err, action)
|
||||||
@ -1257,6 +1260,7 @@ func (t *Tester) testWatchFields(obj runtime.Object, emitFn EmitFunc, fieldsPass
|
|||||||
for _, field := range fieldsFail {
|
for _, field := range fieldsFail {
|
||||||
for _, action := range actions {
|
for _, action := range actions {
|
||||||
options := &api.ListOptions{FieldSelector: field.AsSelector(), ResourceVersion: "1"}
|
options := &api.ListOptions{FieldSelector: field.AsSelector(), ResourceVersion: "1"}
|
||||||
|
ctx = context.WithValue(context.WithValue(ctx, "field", field), "action", action)
|
||||||
watcher, err := t.storage.(rest.Watcher).Watch(ctx, options)
|
watcher, err := t.storage.(rest.Watcher).Watch(ctx, options)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
t.Errorf("unexpected error: %v", err)
|
t.Errorf("unexpected error: %v", err)
|
||||||
@ -1277,11 +1281,12 @@ func (t *Tester) testWatchFields(obj runtime.Object, emitFn EmitFunc, fieldsPass
|
|||||||
}
|
}
|
||||||
|
|
||||||
func (t *Tester) testWatchLabels(obj runtime.Object, emitFn EmitFunc, labelsPass, labelsFail []labels.Set, actions []string) {
|
func (t *Tester) testWatchLabels(obj runtime.Object, emitFn EmitFunc, labelsPass, labelsFail []labels.Set, actions []string) {
|
||||||
ctx := t.TestContext()
|
ctx := t.TestContext().(context.Context)
|
||||||
|
|
||||||
for _, label := range labelsPass {
|
for _, label := range labelsPass {
|
||||||
for _, action := range actions {
|
for _, action := range actions {
|
||||||
options := &api.ListOptions{LabelSelector: label.AsSelector(), ResourceVersion: "1"}
|
options := &api.ListOptions{LabelSelector: label.AsSelector(), ResourceVersion: "1"}
|
||||||
|
ctx = context.WithValue(context.WithValue(ctx, "label", label), "action", action)
|
||||||
watcher, err := t.storage.(rest.Watcher).Watch(ctx, options)
|
watcher, err := t.storage.(rest.Watcher).Watch(ctx, options)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
t.Errorf("unexpected error: %v", err)
|
t.Errorf("unexpected error: %v", err)
|
||||||
@ -1305,6 +1310,7 @@ func (t *Tester) testWatchLabels(obj runtime.Object, emitFn EmitFunc, labelsPass
|
|||||||
for _, label := range labelsFail {
|
for _, label := range labelsFail {
|
||||||
for _, action := range actions {
|
for _, action := range actions {
|
||||||
options := &api.ListOptions{LabelSelector: label.AsSelector(), ResourceVersion: "1"}
|
options := &api.ListOptions{LabelSelector: label.AsSelector(), ResourceVersion: "1"}
|
||||||
|
ctx = context.WithValue(context.WithValue(ctx, "label", label), "action", action)
|
||||||
watcher, err := t.storage.(rest.Watcher).Watch(ctx, options)
|
watcher, err := t.storage.(rest.Watcher).Watch(ctx, options)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
t.Errorf("unexpected error: %v", err)
|
t.Errorf("unexpected error: %v", err)
|
||||||
|
Loading…
Reference in New Issue
Block a user