Skip to content

Commit 76797a3

Browse files
neolit123pull[bot]
authored andcommitted
kubeadm: add default paths to 'upgrade diff'
After the flags to control manifest paths were removed, the variables in diff.go remained empty and the validation fails with "empty manifest path". Always populate the paths with the kubeadm defaults under /etc/kubernetes/manifest and remove the empty path validation.
1 parent cb2ac82 commit 76797a3

File tree

2 files changed

+5
-12
lines changed

2 files changed

+5
-12
lines changed

cmd/kubeadm/app/cmd/upgrade/diff.go

+5-5
Original file line numberDiff line numberDiff line change
@@ -57,8 +57,11 @@ type diffFlags struct {
5757
// newCmdDiff returns the cobra command for `kubeadm upgrade diff`
5858
func newCmdDiff(out io.Writer) *cobra.Command {
5959
flags := &diffFlags{
60-
kubeConfigPath: constants.GetAdminKubeConfigPath(),
61-
out: out,
60+
kubeConfigPath: constants.GetAdminKubeConfigPath(),
61+
out: out,
62+
apiServerManifestPath: constants.GetStaticPodFilepath(constants.KubeAPIServer, constants.GetStaticPodDirectory()),
63+
controllerManagerManifestPath: constants.GetStaticPodFilepath(constants.KubeControllerManager, constants.GetStaticPodDirectory()),
64+
schedulerManifestPath: constants.GetStaticPodFilepath(constants.KubeScheduler, constants.GetStaticPodDirectory()),
6265
}
6366

6467
cmd := &cobra.Command{
@@ -88,9 +91,6 @@ func newCmdDiff(out io.Writer) *cobra.Command {
8891

8992
func validateManifestsPath(manifests ...string) (err error) {
9093
for _, manifestPath := range manifests {
91-
if len(manifestPath) == 0 {
92-
return errors.New("empty manifest path")
93-
}
9494
s, err := os.Stat(manifestPath)
9595
if err != nil {
9696
if os.IsNotExist(err) {

cmd/kubeadm/app/cmd/upgrade/diff_test.go

-7
Original file line numberDiff line numberDiff line change
@@ -113,13 +113,6 @@ diff:
113113
cfgPath: "missing-path-to-a-config",
114114
expectedError: true,
115115
},
116-
{
117-
name: "invalid: valid config but empty manifest path",
118-
cfgPath: testUpgradeDiffConfig,
119-
setManifestPath: true,
120-
manifestPath: "",
121-
expectedError: true,
122-
},
123116
{
124117
name: "invalid: valid config but bad manifest path",
125118
cfgPath: testUpgradeDiffConfig,

0 commit comments

Comments
 (0)