Skip to content
This repository was archived by the owner on Mar 9, 2022. It is now read-only.

Commit b883157

Browse files
authored
Merge pull request #508 from Random-Liu/update-kubernetes
Update kubernetes to v1.9.0.
2 parents 93519cd + b701b0e commit b883157

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

50 files changed

+6487
-3780
lines changed

hack/versions

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,4 +3,4 @@ CNI_VERSION=v0.6.0
33
CONTAINERD_VERSION=6c7abf7c76c1973d4fb4b0bad51691de84869a51
44
CONTAINERD_REPO=
55
CRITOOL_VERSION=v1.0.0-alpha.0
6-
KUBERNETES_VERSION=164317879bcd810b97e5ebf1c8df041770f2ff1b
6+
KUBERNETES_VERSION=v1.9.0

pkg/server/container_update_resources.go

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -28,10 +28,10 @@ import (
2828
runtimespec "github.com/opencontainers/runtime-spec/specs-go"
2929
"github.com/opencontainers/runtime-tools/generate"
3030
"golang.org/x/net/context"
31-
"k8s.io/apimachinery/pkg/conversion"
3231
"k8s.io/kubernetes/pkg/kubelet/apis/cri/v1alpha1/runtime"
3332

3433
containerstore "github.com/kubernetes-incubator/cri-containerd/pkg/store/container"
34+
"github.com/kubernetes-incubator/cri-containerd/pkg/util"
3535
)
3636

3737
// UpdateContainerResources updates ContainerConfig of the container.
@@ -129,11 +129,11 @@ func updateContainerSpec(ctx context.Context, cntr containerd.Container, spec *r
129129
// updateOCILinuxResource updates container resource limit.
130130
func updateOCILinuxResource(spec *runtimespec.Spec, new *runtime.LinuxContainerResources) (*runtimespec.Spec, error) {
131131
// Copy to make sure old spec is not changed.
132-
cloned, err := conversion.NewCloner().DeepCopy(spec)
133-
if err != nil {
132+
var cloned runtimespec.Spec
133+
if err := util.DeepCopy(&cloned, spec); err != nil {
134134
return nil, fmt.Errorf("failed to deep copy: %v", err)
135135
}
136-
g := generate.NewFromSpec(cloned.(*runtimespec.Spec))
136+
g := generate.NewFromSpec(&cloned)
137137

138138
if new.GetCpuPeriod() != 0 {
139139
g.SetLinuxResourcesCPUPeriod(uint64(new.GetCpuPeriod()))

pkg/util/deep_copy.go

Lines changed: 41 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,41 @@
1+
/*
2+
Copyright 2017 The Kubernetes Authors.
3+
4+
Licensed under the Apache License, Version 2.0 (the "License");
5+
you may not use this file except in compliance with the License.
6+
You may obtain a copy of the License at
7+
8+
http://www.apache.org/licenses/LICENSE-2.0
9+
10+
Unless required by applicable law or agreed to in writing, software
11+
distributed under the License is distributed on an "AS IS" BASIS,
12+
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13+
See the License for the specific language governing permissions and
14+
limitations under the License.
15+
*/
16+
17+
package util
18+
19+
import (
20+
"encoding/json"
21+
"fmt"
22+
)
23+
24+
// DeepCopy makes a deep copy from src into dst.
25+
func DeepCopy(dst interface{}, src interface{}) error {
26+
if dst == nil {
27+
return fmt.Errorf("dst cannot be nil")
28+
}
29+
if src == nil {
30+
return fmt.Errorf("src cannot be nil")
31+
}
32+
bytes, err := json.Marshal(src)
33+
if err != nil {
34+
return fmt.Errorf("unable to marshal src: %s", err)
35+
}
36+
err = json.Unmarshal(bytes, dst)
37+
if err != nil {
38+
return fmt.Errorf("unable to unmarshal into dst: %s", err)
39+
}
40+
return nil
41+
}

pkg/util/deep_copy_test.go

Lines changed: 63 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,63 @@
1+
/*
2+
Copyright 2017 The Kubernetes Authors.
3+
4+
Licensed under the Apache License, Version 2.0 (the "License");
5+
you may not use this file except in compliance with the License.
6+
You may obtain a copy of the License at
7+
8+
http://www.apache.org/licenses/LICENSE-2.0
9+
10+
Unless required by applicable law or agreed to in writing, software
11+
distributed under the License is distributed on an "AS IS" BASIS,
12+
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13+
See the License for the specific language governing permissions and
14+
limitations under the License.
15+
*/
16+
17+
package util
18+
19+
import (
20+
"testing"
21+
22+
"github.com/stretchr/testify/assert"
23+
)
24+
25+
type A struct {
26+
String string
27+
Int int
28+
Strings []string
29+
Ints map[string]int
30+
As map[string]*A
31+
}
32+
33+
func TestCopy(t *testing.T) {
34+
src := &A{
35+
String: "Hello World",
36+
Int: 5,
37+
Strings: []string{"A", "B"},
38+
Ints: map[string]int{"A": 1, "B": 2, "C": 4},
39+
As: map[string]*A{
40+
"One": {String: "2"},
41+
"Two": {String: "3"},
42+
},
43+
}
44+
dst := &A{
45+
Strings: []string{"C"},
46+
Ints: map[string]int{"B": 3, "C": 4},
47+
As: map[string]*A{"One": {String: "1", Int: 5}},
48+
}
49+
expected := &A{
50+
String: "Hello World",
51+
Int: 5,
52+
Strings: []string{"A", "B"},
53+
Ints: map[string]int{"A": 1, "B": 2, "C": 4},
54+
As: map[string]*A{
55+
"One": {String: "2"},
56+
"Two": {String: "3"},
57+
},
58+
}
59+
assert.NotEqual(t, expected, dst)
60+
err := DeepCopy(dst, src)
61+
assert.NoError(t, err)
62+
assert.Equal(t, expected, dst)
63+
}

vendor.conf

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -62,10 +62,10 @@ google.golang.org/genproto d80a6e20e776b0b17a324d0ba1ab50a39c8e8944
6262
google.golang.org/grpc v1.7.2
6363
gopkg.in/inf.v0 3887ee99ecf07df5b447e9b00d9c0b2adaa9f3e4
6464
gopkg.in/yaml.v2 53feefa2559fb8dfa8d81baad31be332c97d6c77
65-
k8s.io/api 218912509d74a117d05a718bb926d0948e531c20
66-
k8s.io/apimachinery 18a564baac720819100827c16fdebcadb05b2d0d
67-
k8s.io/apiserver 7001bc4df8883d4a0ec84cd4b2117655a0009b6c
68-
k8s.io/client-go 72e1c2a1ef30b3f8da039e92d4a6a1f079f374e8
69-
k8s.io/kube-openapi 39a7bf85c140f972372c2a0d1ee40adbf0c8bfe1
70-
k8s.io/kubernetes 164317879bcd810b97e5ebf1c8df041770f2ff1b
71-
k8s.io/utils bf963466fd3fea33c428098b12a89d8ecd012f25
65+
k8s.io/api 9382f5a87a364c195477134986b578d103c7c24d
66+
k8s.io/apimachinery 23bc0b9defba312e3b5938fa0d0581f3e882f862
67+
k8s.io/apiserver cbbf2be01950dbf88df68c3ac331e532b3664464
68+
k8s.io/client-go 87887458218a51f3944b2f4c553eb38173458e97
69+
k8s.io/kube-openapi b16ebc07f5cad97831f961e4b5a9cc1caed33b7e
70+
k8s.io/kubernetes v1.9.0
71+
k8s.io/utils 66423a0293c555337adc04fe2c59748151291de8

vendor/k8s.io/api/core/v1/annotation_key_constants.go

Lines changed: 0 additions & 6 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

vendor/k8s.io/api/core/v1/doc.go

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)