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
cf0b4153
Commit
cf0b4153
authored
Dec 11, 2014
by
Brendan Burns
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Make it easier to update nodes, make it possible to update capacity.
parent
7cf0c4d7
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
79 additions
and
1 deletion
+79
-1
types.go
pkg/api/types.go
+2
-0
validation.go
pkg/api/validation/validation.go
+12
-1
validation_test.go
pkg/api/validation/validation_test.go
+58
-0
rest.go
pkg/registry/minion/rest.go
+7
-0
No files found.
pkg/api/types.go
View file @
cf0b4153
...
...
@@ -129,6 +129,8 @@ const (
NamespaceDefault
string
=
"default"
// NamespaceAll is the default argument to specify on a context when you want to list or filter resources across all namespaces
NamespaceAll
string
=
""
// NamespaceNone is the argument for a context when there is no namespace.
NamespaceNone
string
=
""
// TerminationMessagePathDefault means the default path to capture the application termination message running in a container
TerminationMessagePathDefault
string
=
"/dev/termination-log"
)
...
...
pkg/api/validation/validation.go
View file @
cf0b4153
...
...
@@ -26,6 +26,8 @@ import (
"github.com/GoogleCloudPlatform/kubernetes/pkg/capabilities"
"github.com/GoogleCloudPlatform/kubernetes/pkg/labels"
"github.com/GoogleCloudPlatform/kubernetes/pkg/util"
"github.com/golang/glog"
)
// ServiceLister is an abstract interface for testing.
...
...
@@ -565,9 +567,18 @@ func ValidateMinion(minion *api.Node) errs.ValidationErrorList {
// ValidateMinionUpdate tests to make sure a minion update can be applied. Modifies oldMinion.
func
ValidateMinionUpdate
(
oldMinion
*
api
.
Node
,
minion
*
api
.
Node
)
errs
.
ValidationErrorList
{
allErrs
:=
errs
.
ValidationErrorList
{}
if
!
reflect
.
DeepEqual
(
minion
.
Status
,
api
.
NodeStatus
{})
{
allErrs
=
append
(
allErrs
,
errs
.
NewFieldInvalid
(
"status"
,
minion
.
Status
,
"status must be empty"
))
}
// Allow users to update labels and capacity
oldMinion
.
Labels
=
minion
.
Labels
oldMinion
.
Spec
.
Capacity
=
minion
.
Spec
.
Capacity
if
!
reflect
.
DeepEqual
(
oldMinion
,
minion
)
{
allErrs
=
append
(
allErrs
,
fmt
.
Errorf
(
"update contains more than labels changes"
))
glog
.
V
(
4
)
.
Infof
(
"Update failed validation %#v vs %#v"
,
oldMinion
,
minion
)
allErrs
=
append
(
allErrs
,
fmt
.
Errorf
(
"update contains more than labels or capacity changes"
))
}
return
allErrs
}
pkg/api/validation/validation_test.go
View file @
cf0b4153
...
...
@@ -1178,6 +1178,64 @@ func TestValidateMinionUpdate(t *testing.T) {
Labels
:
map
[
string
]
string
{
"foo"
:
"baz"
},
},
},
true
},
{
api
.
Node
{
ObjectMeta
:
api
.
ObjectMeta
{
Name
:
"foo"
,
},
Spec
:
api
.
NodeSpec
{
Capacity
:
api
.
ResourceList
{
"cpu"
:
util
.
NewIntOrStringFromInt
(
10000
),
"memory"
:
util
.
NewIntOrStringFromInt
(
100
),
},
},
},
api
.
Node
{
ObjectMeta
:
api
.
ObjectMeta
{
Name
:
"foo"
,
},
Spec
:
api
.
NodeSpec
{
Capacity
:
api
.
ResourceList
{
"cpu"
:
util
.
NewIntOrStringFromInt
(
100
),
"memory"
:
util
.
NewIntOrStringFromInt
(
10000
),
},
},
},
true
},
{
api
.
Node
{
ObjectMeta
:
api
.
ObjectMeta
{
Name
:
"foo"
,
Labels
:
map
[
string
]
string
{
"bar"
:
"foo"
},
},
Spec
:
api
.
NodeSpec
{
Capacity
:
api
.
ResourceList
{
"cpu"
:
util
.
NewIntOrStringFromInt
(
10000
),
"memory"
:
util
.
NewIntOrStringFromInt
(
100
),
},
},
},
api
.
Node
{
ObjectMeta
:
api
.
ObjectMeta
{
Name
:
"foo"
,
Labels
:
map
[
string
]
string
{
"bar"
:
"fooobaz"
},
},
Spec
:
api
.
NodeSpec
{
Capacity
:
api
.
ResourceList
{
"cpu"
:
util
.
NewIntOrStringFromInt
(
100
),
"memory"
:
util
.
NewIntOrStringFromInt
(
10000
),
},
},
},
true
},
{
api
.
Node
{
ObjectMeta
:
api
.
ObjectMeta
{
Name
:
"foo"
,
Labels
:
map
[
string
]
string
{
"bar"
:
"foo"
},
},
},
api
.
Node
{
ObjectMeta
:
api
.
ObjectMeta
{
Name
:
"foo"
,
Labels
:
map
[
string
]
string
{
"bar"
:
"fooobaz"
},
},
Status
:
api
.
NodeStatus
{
HostIP
:
"1.2.3.4"
,
},
},
false
},
}
for
_
,
test
:=
range
tests
{
errs
:=
ValidateMinionUpdate
(
&
test
.
oldMinion
,
&
test
.
minion
)
...
...
pkg/registry/minion/rest.go
View file @
cf0b4153
...
...
@@ -101,6 +101,13 @@ func (rs *REST) Update(ctx api.Context, obj runtime.Object) (<-chan apiserver.RE
if
!
ok
{
return
nil
,
fmt
.
Errorf
(
"not a minion: %#v"
,
obj
)
}
// This is hacky, but minions don't really have a namespace, but kubectl currently automatically
// stuffs one in there. Fix it here temporarily until we fix kubectl
if
minion
.
Namespace
==
api
.
NamespaceDefault
{
minion
.
Namespace
=
api
.
NamespaceNone
}
// Clear out the self link, if specified, since it's not in the registry either.
minion
.
SelfLink
=
""
// TODO: GetMinion will health check the minion, but we shouldn't require the minion to be
// running for updating labels.
...
...
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