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
1e800350
Commit
1e800350
authored
Nov 03, 2017
by
Cao Shufeng
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
partial fix crd patch failing
partial fixes
https://github.com/kubernetes/kubernetes/issues/53379
parent
134e89e6
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
70 additions
and
2 deletions
+70
-2
BUILD
...src/k8s.io/apiextensions-apiserver/test/integration/BUILD
+1
-0
basic_test.go
...io/apiextensions-apiserver/test/integration/basic_test.go
+64
-0
store.go
staging/src/k8s.io/apiserver/pkg/storage/etcd3/store.go
+5
-2
No files found.
staging/src/k8s.io/apiextensions-apiserver/test/integration/BUILD
View file @
1e800350
...
...
@@ -26,6 +26,7 @@ go_test(
"//vendor/k8s.io/apimachinery/pkg/apis/meta/v1:go_default_library",
"//vendor/k8s.io/apimachinery/pkg/apis/meta/v1/unstructured:go_default_library",
"//vendor/k8s.io/apimachinery/pkg/runtime:go_default_library",
"//vendor/k8s.io/apimachinery/pkg/types:go_default_library",
"//vendor/k8s.io/apimachinery/pkg/util/wait:go_default_library",
"//vendor/k8s.io/apimachinery/pkg/watch:go_default_library",
"//vendor/k8s.io/apiserver/pkg/util/feature:go_default_library",
...
...
staging/src/k8s.io/apiextensions-apiserver/test/integration/basic_test.go
View file @
1e800350
...
...
@@ -28,6 +28,7 @@ import (
metav1
"k8s.io/apimachinery/pkg/apis/meta/v1"
"k8s.io/apimachinery/pkg/apis/meta/v1/unstructured"
"k8s.io/apimachinery/pkg/runtime"
"k8s.io/apimachinery/pkg/types"
"k8s.io/apimachinery/pkg/util/wait"
"k8s.io/apimachinery/pkg/watch"
"k8s.io/client-go/dynamic"
...
...
@@ -546,6 +547,69 @@ func TestPreserveInt(t *testing.T) {
}
}
func
TestPatch
(
t
*
testing
.
T
)
{
stopCh
,
apiExtensionClient
,
clientPool
,
err
:=
testserver
.
StartDefaultServer
()
if
err
!=
nil
{
t
.
Fatal
(
err
)
}
defer
close
(
stopCh
)
noxuDefinition
:=
testserver
.
NewNoxuCustomResourceDefinition
(
apiextensionsv1beta1
.
ClusterScoped
)
noxuVersionClient
,
err
:=
testserver
.
CreateNewCustomResourceDefinition
(
noxuDefinition
,
apiExtensionClient
,
clientPool
)
if
err
!=
nil
{
t
.
Fatal
(
err
)
}
ns
:=
"not-the-default"
noxuNamespacedResourceClient
:=
noxuVersionClient
.
Resource
(
&
metav1
.
APIResource
{
Name
:
noxuDefinition
.
Spec
.
Names
.
Plural
,
Namespaced
:
true
,
},
ns
)
noxuInstanceToCreate
:=
testserver
.
NewNoxuInstance
(
ns
,
"foo"
)
createdNoxuInstance
,
err
:=
noxuNamespacedResourceClient
.
Create
(
noxuInstanceToCreate
)
if
err
!=
nil
{
t
.
Fatal
(
err
)
}
patch
:=
[]
byte
(
`{"num": {"num2":999}}`
)
createdNoxuInstance
,
err
=
noxuNamespacedResourceClient
.
Patch
(
"foo"
,
types
.
MergePatchType
,
patch
)
if
err
!=
nil
{
t
.
Fatalf
(
"unexpected error: %v"
,
err
)
}
// a patch with no change
createdNoxuInstance
,
err
=
noxuNamespacedResourceClient
.
Patch
(
"foo"
,
types
.
MergePatchType
,
patch
)
if
err
!=
nil
{
t
.
Fatalf
(
"unexpected error: %v"
,
err
)
}
// an empty patch
createdNoxuInstance
,
err
=
noxuNamespacedResourceClient
.
Patch
(
"foo"
,
types
.
MergePatchType
,
[]
byte
(
`{}`
))
if
err
!=
nil
{
t
.
Fatalf
(
"unexpected error: %v"
,
err
)
}
originalJSON
,
err
:=
runtime
.
Encode
(
unstructured
.
UnstructuredJSONScheme
,
createdNoxuInstance
)
if
err
!=
nil
{
t
.
Fatalf
(
"unexpected error: %v"
,
err
)
}
gottenNoxuInstance
,
err
:=
runtime
.
Decode
(
unstructured
.
UnstructuredJSONScheme
,
originalJSON
)
if
err
!=
nil
{
t
.
Fatalf
(
"unexpected error: %v"
,
err
)
}
// Check if int is preserved.
unstructuredObj
:=
gottenNoxuInstance
.
(
*
unstructured
.
Unstructured
)
.
Object
num
:=
unstructuredObj
[
"num"
]
.
(
map
[
string
]
interface
{})
num1
:=
num
[
"num1"
]
.
(
int64
)
num2
:=
num
[
"num2"
]
.
(
int64
)
if
num1
!=
9223372036854775807
||
num2
!=
999
{
t
.
Errorf
(
"Expected %v, got %v, %v"
,
`9223372036854775807, 999`
,
num1
,
num2
)
}
}
func
TestCrossNamespaceListWatch
(
t
*
testing
.
T
)
{
stopCh
,
apiExtensionClient
,
clientPool
,
err
:=
testserver
.
StartDefaultServer
()
if
err
!=
nil
{
...
...
staging/src/k8s.io/apiserver/pkg/storage/etcd3/store.go
View file @
1e800350
...
...
@@ -332,8 +332,11 @@ func (s *store) GuaranteedUpdate(
if
err
!=
nil
{
return
err
}
mustCheckData
=
false
continue
if
!
bytes
.
Equal
(
data
,
origState
.
data
)
{
// original data changed, restart loop
mustCheckData
=
false
continue
}
}
return
decode
(
s
.
codec
,
s
.
versioner
,
origState
.
data
,
out
,
origState
.
rev
)
}
...
...
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