Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
K
k3s
Project
Project
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Registry
Registry
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Jacklull
k3s
Commits
e434f318
Commit
e434f318
authored
Aug 03, 2018
by
Tomas Nozicka
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Deprecate ListWatchUntil, fix it and call places
parent
07b8373a
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
16 additions
and
8 deletions
+16
-8
listwatch_test.go
pkg/client/tests/listwatch_test.go
+1
-1
client_builder.go
pkg/controller/client_builder.go
+2
-1
until.go
staging/src/k8s.io/client-go/tools/watch/until.go
+9
-4
csr.go
staging/src/k8s.io/client-go/util/certificate/csr/csr.go
+4
-2
No files found.
pkg/client/tests/listwatch_test.go
View file @
e434f318
...
...
@@ -214,7 +214,7 @@ func TestListWatchUntil(t *testing.T) {
}
timeout
:=
10
*
time
.
Second
lastEvent
,
err
:=
ListWatchUntil
(
timeout
,
listwatch
,
conditions
...
)
lastEvent
,
err
:=
watchtools
.
ListWatchUntil
(
timeout
,
listwatch
,
conditions
...
)
if
err
!=
nil
{
t
.
Fatalf
(
"expected nil error, got %#v"
,
err
)
}
...
...
pkg/controller/client_builder.go
View file @
e434f318
...
...
@@ -33,6 +33,7 @@ import (
v1core
"k8s.io/client-go/kubernetes/typed/core/v1"
restclient
"k8s.io/client-go/rest"
"k8s.io/client-go/tools/cache"
watchtools
"k8s.io/client-go/tools/watch"
"k8s.io/kubernetes/pkg/api/legacyscheme"
api
"k8s.io/kubernetes/pkg/apis/core"
"k8s.io/kubernetes/pkg/serviceaccount"
...
...
@@ -122,7 +123,7 @@ func (b SAControllerClientBuilder) Config(name string) (*restclient.Config, erro
return
b
.
CoreClient
.
Secrets
(
b
.
Namespace
)
.
Watch
(
options
)
},
}
_
,
err
=
cache
.
ListWatchUntil
(
30
*
time
.
Second
,
lw
,
_
,
err
=
watchtools
.
ListWatchUntil
(
30
*
time
.
Second
,
lw
,
func
(
event
watch
.
Event
)
(
bool
,
error
)
{
switch
event
.
Type
{
case
watch
.
Deleted
:
...
...
staging/src/k8s.io/client-go/tools/watch/until.go
View file @
e434f318
...
...
@@ -23,8 +23,10 @@ import (
"github.com/golang/glog"
"k8s.io/apimachinery/pkg/api/meta"
metav1
"k8s.io/apimachinery/pkg/apis/meta/v1"
"k8s.io/apimachinery/pkg/util/wait"
"k8s.io/apimachinery/pkg/watch"
"k8s.io/client-go/tools/cache"
)
// ConditionFunc returns true if the condition has been reached, false if it has not been reached yet,
...
...
@@ -105,7 +107,10 @@ func ContextWithOptionalTimeout(parent context.Context, timeout time.Duration) (
// ListWatchUntil checks the provided conditions against the items returned by the list watcher, returning wait.ErrWaitTimeout
// if timeout is exceeded without all conditions returning true, or an error if an error occurs.
// TODO: check for watch expired error and retry watch from latest point? Same issue exists for Until.
func
ListWatchUntil
(
timeout
time
.
Duration
,
lw
ListerWatcher
,
conditions
...
watchtools
.
ConditionFunc
)
(
*
watch
.
Event
,
error
)
{
// TODO: remove when no longer used
//
// Deprecated: Use UntilWithSync instead.
func
ListWatchUntil
(
timeout
time
.
Duration
,
lw
cache
.
ListerWatcher
,
conditions
...
ConditionFunc
)
(
*
watch
.
Event
,
error
)
{
if
len
(
conditions
)
==
0
{
return
nil
,
nil
}
...
...
@@ -167,10 +172,10 @@ func ListWatchUntil(timeout time.Duration, lw ListerWatcher, conditions ...watch
return
nil
,
err
}
ctx
,
cancel
:=
watchtools
.
ContextWithOptionalTimeout
(
context
.
Background
(),
timeout
)
ctx
,
cancel
:=
ContextWithOptionalTimeout
(
context
.
Background
(),
timeout
)
defer
cancel
()
evt
,
err
:=
watchtools
.
UntilWithoutRetry
(
ctx
,
watchInterface
,
remainingConditions
...
)
if
err
==
watchtools
.
ErrWatchClosed
{
evt
,
err
:=
UntilWithoutRetry
(
ctx
,
watchInterface
,
remainingConditions
...
)
if
err
==
ErrWatchClosed
{
// present a consistent error interface to callers
err
=
wait
.
ErrWaitTimeout
}
...
...
staging/src/k8s.io/client-go/util/certificate/csr/csr.go
View file @
e434f318
...
...
@@ -24,10 +24,11 @@ import (
"encoding/base64"
"encoding/pem"
"fmt"
"github.com/golang/glog"
"reflect"
"time"
"github.com/golang/glog"
certificates
"k8s.io/api/certificates/v1beta1"
"k8s.io/apimachinery/pkg/api/errors"
metav1
"k8s.io/apimachinery/pkg/apis/meta/v1"
...
...
@@ -38,6 +39,7 @@ import (
"k8s.io/apimachinery/pkg/watch"
certificatesclient
"k8s.io/client-go/kubernetes/typed/certificates/v1beta1"
"k8s.io/client-go/tools/cache"
watchtools
"k8s.io/client-go/tools/watch"
certutil
"k8s.io/client-go/util/cert"
)
...
...
@@ -121,7 +123,7 @@ func RequestCertificate(client certificatesclient.CertificateSigningRequestInter
func
WaitForCertificate
(
client
certificatesclient
.
CertificateSigningRequestInterface
,
req
*
certificates
.
CertificateSigningRequest
,
timeout
time
.
Duration
)
(
certData
[]
byte
,
err
error
)
{
fieldSelector
:=
fields
.
OneTermEqualSelector
(
"metadata.name"
,
req
.
Name
)
.
String
()
event
,
err
:=
cache
.
ListWatchUntil
(
event
,
err
:=
watchtools
.
ListWatchUntil
(
timeout
,
&
cache
.
ListWatch
{
ListFunc
:
func
(
options
metav1
.
ListOptions
)
(
runtime
.
Object
,
error
)
{
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment