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
a5ecfbfe
Commit
a5ecfbfe
authored
Mar 10, 2015
by
Brian Grant
Browse files
Options
Browse Files
Download
Plain Diff
Merge pull request #5185 from smarterclayton/ignore_creation_timestamp
Ignore changes to creation timestamp from clients on update
parents
56cbe6c5
d016f478
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
26 additions
and
1 deletion
+26
-1
validation.go
pkg/api/validation/validation.go
+4
-1
validation_test.go
pkg/api/validation/validation_test.go
+22
-0
No files found.
pkg/api/validation/validation.go
View file @
a5ecfbfe
...
...
@@ -219,7 +219,10 @@ func ValidateObjectMetaUpdate(old, meta *api.ObjectMeta) errs.ValidationErrorLis
if
len
(
meta
.
UID
)
==
0
{
meta
.
UID
=
old
.
UID
}
if
meta
.
CreationTimestamp
.
IsZero
()
{
// ignore changes to timestamp
if
old
.
CreationTimestamp
.
IsZero
()
{
old
.
CreationTimestamp
=
meta
.
CreationTimestamp
}
else
{
meta
.
CreationTimestamp
=
old
.
CreationTimestamp
}
...
...
pkg/api/validation/validation_test.go
View file @
a5ecfbfe
...
...
@@ -19,6 +19,7 @@ package validation
import
(
"strings"
"testing"
"time"
"github.com/GoogleCloudPlatform/kubernetes/pkg/api"
"github.com/GoogleCloudPlatform/kubernetes/pkg/api/errors"
...
...
@@ -53,6 +54,27 @@ func TestValidateObjectMetaCustomName(t *testing.T) {
}
}
func
TestValidateObjectMetaUpdateIgnoresCreationTimestamp
(
t
*
testing
.
T
)
{
if
errs
:=
ValidateObjectMetaUpdate
(
&
api
.
ObjectMeta
{
Name
:
"test"
,
CreationTimestamp
:
util
.
NewTime
(
time
.
Unix
(
10
,
0
))},
&
api
.
ObjectMeta
{
Name
:
"test"
},
);
len
(
errs
)
!=
0
{
t
.
Fatalf
(
"unexpected errors: %v"
,
errs
)
}
if
errs
:=
ValidateObjectMetaUpdate
(
&
api
.
ObjectMeta
{
Name
:
"test"
},
&
api
.
ObjectMeta
{
Name
:
"test"
,
CreationTimestamp
:
util
.
NewTime
(
time
.
Unix
(
10
,
0
))},
);
len
(
errs
)
!=
0
{
t
.
Fatalf
(
"unexpected errors: %v"
,
errs
)
}
if
errs
:=
ValidateObjectMetaUpdate
(
&
api
.
ObjectMeta
{
Name
:
"test"
,
CreationTimestamp
:
util
.
NewTime
(
time
.
Unix
(
11
,
0
))},
&
api
.
ObjectMeta
{
Name
:
"test"
,
CreationTimestamp
:
util
.
NewTime
(
time
.
Unix
(
10
,
0
))},
);
len
(
errs
)
!=
0
{
t
.
Fatalf
(
"unexpected errors: %v"
,
errs
)
}
}
// Ensure trailing slash is allowed in generate name
func
TestValidateObjectMetaTrimsTrailingSlash
(
t
*
testing
.
T
)
{
errs
:=
ValidateObjectMeta
(
&
api
.
ObjectMeta
{
Name
:
"test"
,
GenerateName
:
"foo-"
},
false
,
nameIsDNSSubdomain
)
...
...
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