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
c7e56c7e
Unverified
Commit
c7e56c7e
authored
Mar 19, 2019
by
Kubernetes Prow Robot
Committed by
GitHub
Mar 19, 2019
Browse files
Options
Browse Files
Download
Plain Diff
Merge pull request #74719 from vaamarnath/refactor-dir-create-for-dry-runs
kubeadm: refactored directory fetch code
parents
9c5be7aa
be8d1c24
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
6 additions
and
22 deletions
+6
-22
init.go
cmd/kubeadm/app/cmd/init.go
+1
-2
node.go
cmd/kubeadm/app/cmd/upgrade/node.go
+1
-14
postupgrade.go
cmd/kubeadm/app/phases/upgrade/postupgrade.go
+4
-6
No files found.
cmd/kubeadm/app/cmd/init.go
View file @
c7e56c7e
...
...
@@ -19,7 +19,6 @@ package cmd
import
(
"fmt"
"io"
"io/ioutil"
"os"
"path/filepath"
"strings"
...
...
@@ -341,7 +340,7 @@ func newInitData(cmd *cobra.Command, args []string, options *initOptions, out io
// if dry running creates a temporary folder for saving kubeadm generated files
dryRunDir
:=
""
if
options
.
dryRun
{
if
dryRunDir
,
err
=
ioutil
.
TempDir
(
""
,
"kubeadm-init-dryrun"
);
err
!=
nil
{
if
dryRunDir
,
err
=
kubeadmconstants
.
CreateTempDirForKubeadm
(
"kubeadm-init-dryrun"
);
err
!=
nil
{
return
nil
,
errors
.
Wrap
(
err
,
"couldn't create a temporary directory"
)
}
}
...
...
cmd/kubeadm/app/cmd/upgrade/node.go
View file @
c7e56c7e
...
...
@@ -18,7 +18,6 @@ package upgrade
import
(
"fmt"
"io/ioutil"
"os"
"path/filepath"
...
...
@@ -162,7 +161,7 @@ func RunUpgradeNodeConfig(flags *nodeUpgradeFlags) error {
}
// Set up the kubelet directory to use. If dry-running, use a fake directory
kubeletDir
,
err
:=
g
etKubeletDir
(
flags
.
dryRun
)
kubeletDir
,
err
:=
upgrade
.
G
etKubeletDir
(
flags
.
dryRun
)
if
err
!=
nil
{
return
err
}
...
...
@@ -192,18 +191,6 @@ func RunUpgradeNodeConfig(flags *nodeUpgradeFlags) error {
return
nil
}
// getKubeletDir gets the kubelet directory based on whether the user is dry-running this command or not.
func
getKubeletDir
(
dryRun
bool
)
(
string
,
error
)
{
if
dryRun
{
dryRunDir
,
err
:=
ioutil
.
TempDir
(
""
,
"kubeadm-init-dryrun"
)
if
err
!=
nil
{
return
""
,
errors
.
Wrap
(
err
,
"couldn't create a temporary directory"
)
}
return
dryRunDir
,
nil
}
return
constants
.
KubeletRunDirectory
,
nil
}
// printFilesIfDryRunning prints the Static Pod manifests to stdout and informs about the temporary directory to go and lookup
func
printFilesIfDryRunning
(
dryRun
bool
,
kubeletDir
string
)
error
{
if
!
dryRun
{
...
...
cmd/kubeadm/app/phases/upgrade/postupgrade.go
View file @
c7e56c7e
...
...
@@ -18,7 +18,6 @@ package upgrade
import
(
"fmt"
"io/ioutil"
"os"
"path/filepath"
"time"
...
...
@@ -185,7 +184,7 @@ func BackupAPIServerCertIfNeeded(cfg *kubeadmapi.InitConfiguration, dryRun bool)
}
func
writeKubeletConfigFiles
(
client
clientset
.
Interface
,
cfg
*
kubeadmapi
.
InitConfiguration
,
newK8sVer
*
version
.
Version
,
dryRun
bool
)
error
{
kubeletDir
,
err
:=
g
etKubeletDir
(
dryRun
)
kubeletDir
,
err
:=
G
etKubeletDir
(
dryRun
)
if
err
!=
nil
{
// The error here should never occur in reality, would only be thrown if /tmp doesn't exist on the machine.
return
err
...
...
@@ -221,11 +220,10 @@ func writeKubeletConfigFiles(client clientset.Interface, cfg *kubeadmapi.InitCon
return
errorsutil
.
NewAggregate
(
errs
)
}
// getKubeletDir gets the kubelet directory based on whether the user is dry-running this command or not.
// TODO: Consolidate this with similar funcs?
func
getKubeletDir
(
dryRun
bool
)
(
string
,
error
)
{
// GetKubeletDir gets the kubelet directory based on whether the user is dry-running this command or not.
func
GetKubeletDir
(
dryRun
bool
)
(
string
,
error
)
{
if
dryRun
{
return
ioutil
.
TempDir
(
""
,
"kubeadm-upgrade-dryrun"
)
return
kubeadmconstants
.
CreateTempDirForKubeadm
(
"kubeadm-upgrade-dryrun"
)
}
return
kubeadmconstants
.
KubeletRunDirectory
,
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