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
877dc568
Commit
877dc568
authored
Apr 18, 2017
by
Kubernetes Submit Queue
Committed by
GitHub
Apr 18, 2017
Browse files
Options
Browse Files
Download
Plain Diff
Merge pull request #43282 from xilabao/use-healthz-api
Automatic merge from submit-queue use healthz api in WaitForAPI finish TODO
parents
c20e63bf
7f613f09
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
4 additions
and
23 deletions
+4
-23
BUILD
cmd/kubeadm/app/master/BUILD
+0
-1
apiclient.go
cmd/kubeadm/app/master/apiclient.go
+4
-22
No files found.
cmd/kubeadm/app/master/BUILD
View file @
877dc568
...
...
@@ -26,7 +26,6 @@ go_library(
"//pkg/kubectl/cmd/util:go_default_library",
"//pkg/util/version:go_default_library",
"//vendor/github.com/ghodss/yaml:go_default_library",
"//vendor/k8s.io/apimachinery/pkg/api/errors:go_default_library",
"//vendor/k8s.io/apimachinery/pkg/api/resource:go_default_library",
"//vendor/k8s.io/apimachinery/pkg/apis/meta/v1:go_default_library",
"//vendor/k8s.io/apimachinery/pkg/util/intstr:go_default_library",
...
...
cmd/kubeadm/app/master/apiclient.go
View file @
877dc568
...
...
@@ -18,13 +18,11 @@ package master
import
(
"fmt"
"net/http"
"time"
apierrs
"k8s.io/apimachinery/pkg/api/errors"
metav1
"k8s.io/apimachinery/pkg/apis/meta/v1"
"k8s.io/apimachinery/pkg/util/wait"
clientset
"k8s.io/client-go/kubernetes"
"k8s.io/client-go/pkg/api/v1"
kubeadmconstants
"k8s.io/kubernetes/cmd/kubeadm/app/constants"
kubeconfigutil
"k8s.io/kubernetes/cmd/kubeadm/app/util/kubeconfig"
)
...
...
@@ -44,28 +42,12 @@ func CreateClientAndWaitForAPI(file string) (*clientset.Clientset, error) {
func
WaitForAPI
(
client
*
clientset
.
Clientset
)
{
start
:=
time
.
Now
()
wait
.
PollInfinite
(
kubeadmconstants
.
APICallRetryInterval
,
func
()
(
bool
,
error
)
{
// TODO: use /healthz API instead of this
cs
,
err
:=
client
.
ComponentStatuses
()
.
List
(
metav1
.
ListOptions
{})
if
err
!=
nil
{
if
apierrs
.
IsForbidden
(
err
)
{
fmt
.
Println
(
"[apiclient] Waiting for API server authorization"
)
}
healthStatus
:=
0
client
.
Discovery
()
.
RESTClient
()
.
Get
()
.
AbsPath
(
"/healthz"
)
.
Do
()
.
StatusCode
(
&
healthStatus
)
if
healthStatus
!=
http
.
StatusOK
{
return
false
,
nil
}
// TODO(phase2) must revisit this when we implement HA
if
len
(
cs
.
Items
)
<
3
{
return
false
,
nil
}
for
_
,
item
:=
range
cs
.
Items
{
for
_
,
condition
:=
range
item
.
Conditions
{
if
condition
.
Type
!=
v1
.
ComponentHealthy
{
fmt
.
Printf
(
"[apiclient] Control plane component %q is still unhealthy: %#v
\n
"
,
item
.
ObjectMeta
.
Name
,
item
.
Conditions
)
return
false
,
nil
}
}
}
fmt
.
Printf
(
"[apiclient] All control plane components are healthy after %f seconds
\n
"
,
time
.
Since
(
start
)
.
Seconds
())
return
true
,
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