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
4ed3216f
Unverified
Commit
4ed3216f
authored
Oct 05, 2018
by
k8s-ci-robot
Committed by
GitHub
Oct 05, 2018
Browse files
Options
Browse Files
Download
Plain Diff
Merge pull request #69463 from rosti/automated-cherry-pick-of-#69426-upstream-release-1.12
Automated cherry pick of #69426: kubeadm: Allow mixing Init and Join Configurations
parents
3bf9523a
9109e620
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
40 additions
and
21 deletions
+40
-21
common.go
cmd/kubeadm/app/util/config/common.go
+7
-8
common_test.go
cmd/kubeadm/app/util/config/common_test.go
+14
-12
nodeconfig.go
cmd/kubeadm/app/util/config/nodeconfig.go
+19
-1
No files found.
cmd/kubeadm/app/util/config/common.go
View file @
4ed3216f
...
...
@@ -93,19 +93,18 @@ func DetectUnsupportedVersion(b []byte) error {
}
knownKinds
[
gvk
.
Kind
]
=
true
}
// InitConfiguration, MasterConfiguration and NodeConfiguration
are mutually exclusive, error if more than one are
specified
// InitConfiguration, MasterConfiguration and NodeConfiguration
may not apply together, warn if more than one is
specified
mutuallyExclusive
:=
[]
string
{
constants
.
InitConfigurationKind
,
constants
.
MasterConfigurationKind
,
constants
.
JoinConfigurationKind
,
constants
.
NodeConfigurationKind
}
foundOne
:=
false
mutuallyExclusiveCount
:=
0
for
_
,
kind
:=
range
mutuallyExclusive
{
if
knownKinds
[
kind
]
{
if
!
foundOne
{
foundOne
=
true
continue
}
return
fmt
.
Errorf
(
"invalid configuration: kinds %v are mutually exclusive"
,
mutuallyExclusive
)
mutuallyExclusiveCount
++
}
}
if
mutuallyExclusiveCount
>
1
{
glog
.
Warningf
(
"WARNING: Detected resource kinds that may not apply: %v"
,
mutuallyExclusive
)
}
return
nil
}
...
...
cmd/kubeadm/app/util/config/common_test.go
View file @
4ed3216f
...
...
@@ -132,35 +132,37 @@ func TestDetectUnsupportedVersion(t *testing.T) {
fileContents
:
bytes
.
Join
([][]
byte
{
files
[
"Foo"
],
files
[
"Master_v1alpha1"
]},
[]
byte
(
constants
.
YAMLDocumentSeparator
)),
expectedErr
:
true
,
},
// CanMix* cases used to be MustNotMix*, however due to UX issues DetectUnsupportedVersion had to tolerate that.
// So the following tests actually verify, that previously conflicting configs can be mixed together with no error.
{
name
:
"
MustNot
MixMasterNode"
,
name
:
"
Can
MixMasterNode"
,
fileContents
:
bytes
.
Join
([][]
byte
{
files
[
"Master_v1alpha2"
],
files
[
"Node_v1alpha2"
]},
[]
byte
(
constants
.
YAMLDocumentSeparator
)),
expectedErr
:
tru
e
,
expectedErr
:
fals
e
,
},
{
name
:
"
MustNot
MixMasterJoin"
,
name
:
"
Can
MixMasterJoin"
,
fileContents
:
bytes
.
Join
([][]
byte
{
files
[
"Master_v1alpha2"
],
files
[
"Join_v1alpha3"
]},
[]
byte
(
constants
.
YAMLDocumentSeparator
)),
expectedErr
:
tru
e
,
expectedErr
:
fals
e
,
},
{
name
:
"
MustNot
MixJoinNode"
,
name
:
"
Can
MixJoinNode"
,
fileContents
:
bytes
.
Join
([][]
byte
{
files
[
"Join_v1alpha3"
],
files
[
"Node_v1alpha2"
]},
[]
byte
(
constants
.
YAMLDocumentSeparator
)),
expectedErr
:
tru
e
,
expectedErr
:
fals
e
,
},
{
name
:
"
MustNot
MixInitMaster"
,
name
:
"
Can
MixInitMaster"
,
fileContents
:
bytes
.
Join
([][]
byte
{
files
[
"Init_v1alpha3"
],
files
[
"Master_v1alpha2"
]},
[]
byte
(
constants
.
YAMLDocumentSeparator
)),
expectedErr
:
tru
e
,
expectedErr
:
fals
e
,
},
{
name
:
"
MustNot
MixInitNode"
,
name
:
"
Can
MixInitNode"
,
fileContents
:
bytes
.
Join
([][]
byte
{
files
[
"Init_v1alpha3"
],
files
[
"Node_v1alpha2"
]},
[]
byte
(
constants
.
YAMLDocumentSeparator
)),
expectedErr
:
tru
e
,
expectedErr
:
fals
e
,
},
{
name
:
"
MustNot
MixInitJoin"
,
name
:
"
Can
MixInitJoin"
,
fileContents
:
bytes
.
Join
([][]
byte
{
files
[
"Init_v1alpha3"
],
files
[
"Join_v1alpha3"
]},
[]
byte
(
constants
.
YAMLDocumentSeparator
)),
expectedErr
:
tru
e
,
expectedErr
:
fals
e
,
},
}
...
...
cmd/kubeadm/app/util/config/nodeconfig.go
View file @
4ed3216f
...
...
@@ -19,6 +19,7 @@ package config
import
(
"fmt"
"io/ioutil"
"k8s.io/kubernetes/cmd/kubeadm/app/constants"
"github.com/golang/glog"
...
...
@@ -27,6 +28,7 @@ import (
kubeadmscheme
"k8s.io/kubernetes/cmd/kubeadm/app/apis/kubeadm/scheme"
kubeadmapiv1alpha3
"k8s.io/kubernetes/cmd/kubeadm/app/apis/kubeadm/v1alpha3"
"k8s.io/kubernetes/cmd/kubeadm/app/apis/kubeadm/validation"
kubeadmutil
"k8s.io/kubernetes/cmd/kubeadm/app/util"
)
// SetJoinDynamicDefaults checks and sets configuration values for the JoinConfiguration object
...
...
@@ -61,7 +63,23 @@ func NodeConfigFileAndDefaultsToInternalConfig(cfgPath string, defaultversionedc
return
nil
,
err
}
if
err
:=
runtime
.
DecodeInto
(
kubeadmscheme
.
Codecs
.
UniversalDecoder
(),
b
,
internalcfg
);
err
!=
nil
{
gvkmap
,
err
:=
kubeadmutil
.
SplitYAMLDocuments
(
b
)
if
err
!=
nil
{
return
nil
,
err
}
joinBytes
:=
[]
byte
{}
for
gvk
,
bytes
:=
range
gvkmap
{
if
gvk
.
Kind
==
constants
.
JoinConfigurationKind
||
gvk
.
Kind
==
constants
.
NodeConfigurationKind
{
joinBytes
=
bytes
}
}
if
len
(
joinBytes
)
==
0
{
return
nil
,
fmt
.
Errorf
(
"no %s found in config file %q"
,
constants
.
JoinConfigurationKind
,
cfgPath
)
}
if
err
:=
runtime
.
DecodeInto
(
kubeadmscheme
.
Codecs
.
UniversalDecoder
(),
joinBytes
,
internalcfg
);
err
!=
nil
{
return
nil
,
err
}
}
else
{
...
...
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