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
d016f478
Commit
d016f478
authored
Mar 09, 2015
by
Clayton Coleman
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Ignore changes to creation timestamp from clients on update
CreationTimestamp is not an authoritative field (like UID) so mismatches can be safely ignored.
parent
02590e9a
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 @
d016f478
...
@@ -219,7 +219,10 @@ func ValidateObjectMetaUpdate(old, meta *api.ObjectMeta) errs.ValidationErrorLis
...
@@ -219,7 +219,10 @@ func ValidateObjectMetaUpdate(old, meta *api.ObjectMeta) errs.ValidationErrorLis
if
len
(
meta
.
UID
)
==
0
{
if
len
(
meta
.
UID
)
==
0
{
meta
.
UID
=
old
.
UID
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
meta
.
CreationTimestamp
=
old
.
CreationTimestamp
}
}
...
...
pkg/api/validation/validation_test.go
View file @
d016f478
...
@@ -19,6 +19,7 @@ package validation
...
@@ -19,6 +19,7 @@ package validation
import
(
import
(
"strings"
"strings"
"testing"
"testing"
"time"
"github.com/GoogleCloudPlatform/kubernetes/pkg/api"
"github.com/GoogleCloudPlatform/kubernetes/pkg/api"
"github.com/GoogleCloudPlatform/kubernetes/pkg/api/errors"
"github.com/GoogleCloudPlatform/kubernetes/pkg/api/errors"
...
@@ -53,6 +54,27 @@ func TestValidateObjectMetaCustomName(t *testing.T) {
...
@@ -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
// Ensure trailing slash is allowed in generate name
func
TestValidateObjectMetaTrimsTrailingSlash
(
t
*
testing
.
T
)
{
func
TestValidateObjectMetaTrimsTrailingSlash
(
t
*
testing
.
T
)
{
errs
:=
ValidateObjectMeta
(
&
api
.
ObjectMeta
{
Name
:
"test"
,
GenerateName
:
"foo-"
},
false
,
nameIsDNSSubdomain
)
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