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
557d4250
Commit
557d4250
authored
Sep 10, 2021
by
Brad Davidson
Committed by
Brad Davidson
Oct 20, 2021
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Minor cleanup on cribbed function
Signed-off-by:
Brad Davidson
<
brad.davidson@rancher.com
>
(cherry picked from commit
57377d2c
)
parent
4f28561e
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
7 additions
and
4 deletions
+7
-4
api.go
pkg/util/api.go
+7
-4
No files found.
pkg/util/api.go
View file @
557d4250
...
@@ -8,6 +8,8 @@ import (
...
@@ -8,6 +8,8 @@ import (
"strconv"
"strconv"
"time"
"time"
"github.com/pkg/errors"
"github.com/rancher/wrangler/pkg/merr"
"github.com/sirupsen/logrus"
"github.com/sirupsen/logrus"
v1
"k8s.io/api/core/v1"
v1
"k8s.io/api/core/v1"
"k8s.io/apimachinery/pkg/util/wait"
"k8s.io/apimachinery/pkg/util/wait"
...
@@ -38,12 +40,13 @@ func GetAddresses(endpoint *v1.Endpoints) []string {
...
@@ -38,12 +40,13 @@ func GetAddresses(endpoint *v1.Endpoints) []string {
// This is cribbed from the Kubernetes controller-manager app, but checks the readyz endpoint instead of the deprecated healthz endpoint.
// This is cribbed from the Kubernetes controller-manager app, but checks the readyz endpoint instead of the deprecated healthz endpoint.
func
WaitForAPIServerReady
(
client
clientset
.
Interface
,
timeout
time
.
Duration
)
error
{
func
WaitForAPIServerReady
(
client
clientset
.
Interface
,
timeout
time
.
Duration
)
error
{
var
lastErr
error
var
lastErr
error
restClient
:=
client
.
Discovery
()
.
RESTClient
()
err
:=
wait
.
PollImmediate
(
time
.
Second
,
timeout
,
func
()
(
bool
,
error
)
{
err
:=
wait
.
PollImmediate
(
time
.
Second
,
timeout
,
func
()
(
bool
,
error
)
{
healthStatus
:=
0
healthStatus
:=
0
result
:=
client
.
Discovery
()
.
RESTClient
()
.
Get
()
.
AbsPath
(
"/readyz"
)
.
Do
(
context
.
TODO
())
.
StatusCode
(
&
healthStatus
)
result
:=
restClient
.
Get
()
.
AbsPath
(
"/readyz"
)
.
Do
(
context
.
TODO
())
.
StatusCode
(
&
healthStatus
)
if
re
sult
.
Error
()
!=
nil
{
if
re
rr
:=
result
.
Error
();
rerr
!=
nil
{
lastErr
=
fmt
.
Errorf
(
"failed to get apiserver /readyz status: %v"
,
result
.
Error
()
)
lastErr
=
errors
.
Wrap
(
rerr
,
"failed to get apiserver /readyz status"
)
return
false
,
nil
return
false
,
nil
}
}
if
healthStatus
!=
http
.
StatusOK
{
if
healthStatus
!=
http
.
StatusOK
{
...
@@ -57,7 +60,7 @@ func WaitForAPIServerReady(client clientset.Interface, timeout time.Duration) er
...
@@ -57,7 +60,7 @@ func WaitForAPIServerReady(client clientset.Interface, timeout time.Duration) er
})
})
if
err
!=
nil
{
if
err
!=
nil
{
return
fmt
.
Errorf
(
"%v: %v"
,
err
,
lastErr
)
return
merr
.
NewErrors
(
err
,
lastErr
)
}
}
return
nil
return
nil
...
...
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