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
7f613f09
Commit
7f613f09
authored
Mar 17, 2017
by
xilabao
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
use healthz api instead of componentstatus in WaitForAPI
parent
dee81ed5
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 @
7f613f09
...
@@ -26,7 +26,6 @@ go_library(
...
@@ -26,7 +26,6 @@ go_library(
"//pkg/kubectl/cmd/util:go_default_library",
"//pkg/kubectl/cmd/util:go_default_library",
"//pkg/util/version:go_default_library",
"//pkg/util/version:go_default_library",
"//vendor/github.com/ghodss/yaml: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/api/resource:go_default_library",
"//vendor/k8s.io/apimachinery/pkg/apis/meta/v1:go_default_library",
"//vendor/k8s.io/apimachinery/pkg/apis/meta/v1:go_default_library",
"//vendor/k8s.io/apimachinery/pkg/util/intstr:go_default_library",
"//vendor/k8s.io/apimachinery/pkg/util/intstr:go_default_library",
...
...
cmd/kubeadm/app/master/apiclient.go
View file @
7f613f09
...
@@ -18,13 +18,11 @@ package master
...
@@ -18,13 +18,11 @@ package master
import
(
import
(
"fmt"
"fmt"
"net/http"
"time"
"time"
apierrs
"k8s.io/apimachinery/pkg/api/errors"
metav1
"k8s.io/apimachinery/pkg/apis/meta/v1"
"k8s.io/apimachinery/pkg/util/wait"
"k8s.io/apimachinery/pkg/util/wait"
clientset
"k8s.io/client-go/kubernetes"
clientset
"k8s.io/client-go/kubernetes"
"k8s.io/client-go/pkg/api/v1"
kubeadmconstants
"k8s.io/kubernetes/cmd/kubeadm/app/constants"
kubeadmconstants
"k8s.io/kubernetes/cmd/kubeadm/app/constants"
kubeconfigutil
"k8s.io/kubernetes/cmd/kubeadm/app/util/kubeconfig"
kubeconfigutil
"k8s.io/kubernetes/cmd/kubeadm/app/util/kubeconfig"
)
)
...
@@ -44,28 +42,12 @@ func CreateClientAndWaitForAPI(file string) (*clientset.Clientset, error) {
...
@@ -44,28 +42,12 @@ func CreateClientAndWaitForAPI(file string) (*clientset.Clientset, error) {
func
WaitForAPI
(
client
*
clientset
.
Clientset
)
{
func
WaitForAPI
(
client
*
clientset
.
Clientset
)
{
start
:=
time
.
Now
()
start
:=
time
.
Now
()
wait
.
PollInfinite
(
kubeadmconstants
.
APICallRetryInterval
,
func
()
(
bool
,
error
)
{
wait
.
PollInfinite
(
kubeadmconstants
.
APICallRetryInterval
,
func
()
(
bool
,
error
)
{
// TODO: use /healthz API instead of this
healthStatus
:=
0
cs
,
err
:=
client
.
ComponentStatuses
()
.
List
(
metav1
.
ListOptions
{})
client
.
Discovery
()
.
RESTClient
()
.
Get
()
.
AbsPath
(
"/healthz"
)
.
Do
()
.
StatusCode
(
&
healthStatus
)
if
err
!=
nil
{
if
healthStatus
!=
http
.
StatusOK
{
if
apierrs
.
IsForbidden
(
err
)
{
fmt
.
Println
(
"[apiclient] Waiting for API server authorization"
)
}
return
false
,
nil
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
())
fmt
.
Printf
(
"[apiclient] All control plane components are healthy after %f seconds
\n
"
,
time
.
Since
(
start
)
.
Seconds
())
return
true
,
nil
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