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
68ea48bd
Commit
68ea48bd
authored
Nov 20, 2017
by
Angus Lees
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Allow healthchecks to be skipped with --ignore-checks-errors too
parent
362e6293
Hide whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
43 additions
and
43 deletions
+43
-43
apply.go
cmd/kubeadm/app/cmd/upgrade/apply.go
+1
-1
common.go
cmd/kubeadm/app/cmd/upgrade/common.go
+2
-2
plan.go
cmd/kubeadm/app/cmd/upgrade/plan.go
+1
-1
BUILD
cmd/kubeadm/app/phases/upgrade/BUILD
+2
-0
health.go
cmd/kubeadm/app/phases/upgrade/health.go
+37
-39
No files found.
cmd/kubeadm/app/cmd/upgrade/apply.go
View file @
68ea48bd
...
...
@@ -119,7 +119,7 @@ func NewCmdApply(parentFlags *cmdUpgradeFlags) *cobra.Command {
func
RunApply
(
flags
*
applyFlags
)
error
{
// Start with the basics, verify that the cluster is healthy and get the configuration from the cluster (using the ConfigMap)
upgradeVars
,
err
:=
enforceRequirements
(
flags
.
parent
.
featureGatesString
,
flags
.
parent
.
kubeConfigPath
,
flags
.
parent
.
cfgPath
,
flags
.
parent
.
printConfig
,
flags
.
dryRun
)
upgradeVars
,
err
:=
enforceRequirements
(
flags
.
parent
.
featureGatesString
,
flags
.
parent
.
kubeConfigPath
,
flags
.
parent
.
cfgPath
,
flags
.
parent
.
printConfig
,
flags
.
dryRun
,
flags
.
parent
.
ignorePreflightErrorsSet
)
if
err
!=
nil
{
return
err
}
...
...
cmd/kubeadm/app/cmd/upgrade/common.go
View file @
68ea48bd
...
...
@@ -48,14 +48,14 @@ type upgradeVariables struct {
}
// enforceRequirements verifies that it's okay to upgrade and then returns the variables needed for the rest of the procedure
func
enforceRequirements
(
featureGatesString
,
kubeConfigPath
,
cfgPath
string
,
printConfig
,
dryRun
bool
)
(
*
upgradeVariables
,
error
)
{
func
enforceRequirements
(
featureGatesString
,
kubeConfigPath
,
cfgPath
string
,
printConfig
,
dryRun
bool
,
ignoreChecksErrors
sets
.
String
)
(
*
upgradeVariables
,
error
)
{
client
,
err
:=
getClient
(
kubeConfigPath
,
dryRun
)
if
err
!=
nil
{
return
nil
,
fmt
.
Errorf
(
"couldn't create a Kubernetes client from file %q: %v"
,
kubeConfigPath
,
err
)
}
// Run healthchecks against the cluster
if
err
:=
upgrade
.
CheckClusterHealth
(
client
);
err
!=
nil
{
if
err
:=
upgrade
.
CheckClusterHealth
(
client
,
ignoreChecksErrors
);
err
!=
nil
{
return
nil
,
fmt
.
Errorf
(
"[upgrade/health] FATAL: %v"
,
err
)
}
...
...
cmd/kubeadm/app/cmd/upgrade/plan.go
View file @
68ea48bd
...
...
@@ -55,7 +55,7 @@ func NewCmdPlan(parentFlags *cmdUpgradeFlags) *cobra.Command {
// RunPlan takes care of outputting available versions to upgrade to for the user
func
RunPlan
(
parentFlags
*
cmdUpgradeFlags
)
error
{
// Start with the basics, verify that the cluster is healthy, build a client and a versionGetter. Never set dry-run for plan.
upgradeVars
,
err
:=
enforceRequirements
(
parentFlags
.
featureGatesString
,
parentFlags
.
kubeConfigPath
,
parentFlags
.
cfgPath
,
parentFlags
.
printConfig
,
false
)
upgradeVars
,
err
:=
enforceRequirements
(
parentFlags
.
featureGatesString
,
parentFlags
.
kubeConfigPath
,
parentFlags
.
cfgPath
,
parentFlags
.
printConfig
,
false
,
parentFlags
.
ignorePreflightErrorsSet
)
if
err
!=
nil
{
return
err
}
...
...
cmd/kubeadm/app/phases/upgrade/BUILD
View file @
68ea48bd
...
...
@@ -32,6 +32,7 @@ go_library(
"//cmd/kubeadm/app/phases/etcd:go_default_library",
"//cmd/kubeadm/app/phases/selfhosting:go_default_library",
"//cmd/kubeadm/app/phases/uploadconfig:go_default_library",
"//cmd/kubeadm/app/preflight:go_default_library",
"//cmd/kubeadm/app/util:go_default_library",
"//cmd/kubeadm/app/util/apiclient:go_default_library",
"//cmd/kubeadm/app/util/config:go_default_library",
...
...
@@ -44,6 +45,7 @@ go_library(
"//vendor/k8s.io/apimachinery/pkg/apis/meta/v1:go_default_library",
"//vendor/k8s.io/apimachinery/pkg/runtime:go_default_library",
"//vendor/k8s.io/apimachinery/pkg/util/errors:go_default_library",
"//vendor/k8s.io/apimachinery/pkg/util/sets:go_default_library",
"//vendor/k8s.io/client-go/kubernetes:go_default_library",
],
)
...
...
cmd/kubeadm/app/phases/upgrade/health.go
View file @
68ea48bd
...
...
@@ -24,73 +24,71 @@ import (
apps
"k8s.io/api/apps/v1beta2"
"k8s.io/api/core/v1"
metav1
"k8s.io/apimachinery/pkg/apis/meta/v1"
"k8s.io/apimachinery/pkg/util/sets"
clientset
"k8s.io/client-go/kubernetes"
"k8s.io/kubernetes/cmd/kubeadm/app/constants"
"k8s.io/kubernetes/cmd/kubeadm/app/preflight"
)
// healthCheck is a helper struct for easily performing healthchecks against the cluster and printing the output
type
healthCheck
struct
{
description
,
okMessage
,
failMessage
string
// f is invoked with a k8s client passed to it. Should return an optional warning and/or an error
name
string
client
clientset
.
Interface
// f is invoked with a k8s client passed to it. Should return an optional error
f
func
(
clientset
.
Interface
)
error
}
// Check is part of the preflight.Checker interface
func
(
c
*
healthCheck
)
Check
()
(
warnings
,
errors
[]
error
)
{
if
err
:=
c
.
f
(
c
.
client
);
err
!=
nil
{
return
nil
,
[]
error
{
err
}
}
return
nil
,
nil
}
// Name is part of the preflight.Checker interface
func
(
c
*
healthCheck
)
Name
()
string
{
return
c
.
name
}
// CheckClusterHealth makes sure:
// - the API /healthz endpoint is healthy
// - all Nodes are Ready
// - (if self-hosted) that there are DaemonSets with at least one Pod for all control plane components
// - (if static pod-hosted) that all required Static Pod manifests exist on disk
func
CheckClusterHealth
(
client
clientset
.
Interface
)
error
{
func
CheckClusterHealth
(
client
clientset
.
Interface
,
ignoreChecksErrors
sets
.
String
)
error
{
fmt
.
Println
(
"[upgrade] Making sure the cluster is healthy:"
)
healthChecks
:=
[]
healthCheck
{
{
description
:
"API Server health"
,
okMessage
:
"Healthy"
,
failMessage
:
"Unhealthy"
,
f
:
apiServerHealthy
,
healthChecks
:=
[]
preflight
.
Checker
{
&
healthCheck
{
name
:
"APIServerHealth"
,
client
:
client
,
f
:
apiServerHealthy
,
},
{
description
:
"Node health"
,
okMessage
:
"All Nodes are healthy"
,
failMessage
:
"More than one Node unhealthy"
,
f
:
nodesHealthy
,
&
healthCheck
{
name
:
"NodeHealth"
,
client
:
client
,
f
:
nodesHealthy
,
},
// TODO: Add a check for ComponentStatuses here?
}
// Run slightly different health checks depending on control plane hosting type
if
IsControlPlaneSelfHosted
(
client
)
{
healthChecks
=
append
(
healthChecks
,
healthCheck
{
description
:
"Control plane DaemonSet health"
,
okMessage
:
"All control plane DaemonSets are healthy"
,
failMessage
:
"More than one control plane DaemonSet unhealthy"
,
f
:
controlPlaneHealth
,
healthChecks
=
append
(
healthChecks
,
&
healthCheck
{
name
:
"ControlPlaneHealth"
,
client
:
client
,
f
:
controlPlaneHealth
,
})
}
else
{
healthChecks
=
append
(
healthChecks
,
healthCheck
{
description
:
"Static Pod manifests exists on disk"
,
okMessage
:
"All manifests exist on disk"
,
failMessage
:
"Some manifests don't exist on disk"
,
f
:
staticPodManifestHealth
,
healthChecks
=
append
(
healthChecks
,
&
healthCheck
{
name
:
"StaticPodManifest"
,
client
:
client
,
f
:
staticPodManifestHealth
,
})
}
return
runHealthChecks
(
client
,
healthChecks
)
}
// runHealthChecks runs a set of health checks against the cluster
func
runHealthChecks
(
client
clientset
.
Interface
,
healthChecks
[]
healthCheck
)
error
{
for
_
,
check
:=
range
healthChecks
{
err
:=
check
.
f
(
client
)
if
err
!=
nil
{
fmt
.
Printf
(
"[upgrade/health] Checking %s: %s
\n
"
,
check
.
description
,
check
.
failMessage
)
return
fmt
.
Errorf
(
"The cluster is not in an upgradeable state due to: %v"
,
err
)
}
fmt
.
Printf
(
"[upgrade/health] Checking %s: %s
\n
"
,
check
.
description
,
check
.
okMessage
)
}
return
nil
return
preflight
.
RunChecks
(
healthChecks
,
os
.
Stderr
,
ignoreChecksErrors
)
}
// apiServerHealthy checks whether the API server's /healthz endpoint is healthy
...
...
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