Skip to content

Commit 89cfb52

Browse files
committed
bump kubernetes to 1.9
1 parent f479d09 commit 89cfb52

File tree

2,259 files changed

+464195
-732462
lines changed

Some content is hidden

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

2,259 files changed

+464195
-732462
lines changed

Godeps/Godeps.json

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

pkg/condition/manager.go

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -25,8 +25,8 @@ import (
2525
"k8s.io/node-problem-detector/pkg/types"
2626
problemutil "k8s.io/node-problem-detector/pkg/util"
2727

28-
"k8s.io/kubernetes/pkg/api"
29-
"k8s.io/kubernetes/pkg/util/clock"
28+
"k8s.io/api/core/v1"
29+
"k8s.io/apimachinery/pkg/util/clock"
3030

3131
"github.com/golang/glog"
3232
)
@@ -151,7 +151,7 @@ func (c *conditionManager) needHeartbeat() bool {
151151
func (c *conditionManager) sync() {
152152
c.latestTry = c.clock.Now()
153153
c.resyncNeeded = false
154-
conditions := []api.NodeCondition{}
154+
conditions := []v1.NodeCondition{}
155155
for i := range c.conditions {
156156
conditions = append(conditions, problemutil.ConvertToAPICondition(c.conditions[i]))
157157
}

pkg/condition/manager_test.go

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -27,8 +27,8 @@ import (
2727
"k8s.io/node-problem-detector/pkg/types"
2828
problemutil "k8s.io/node-problem-detector/pkg/util"
2929

30-
"k8s.io/kubernetes/pkg/api"
31-
"k8s.io/kubernetes/pkg/util/clock"
30+
"k8s.io/api/core/v1"
31+
"k8s.io/apimachinery/pkg/util/clock"
3232
)
3333

3434
func newTestManager() (*conditionManager, *problemclient.FakeProblemClient, *clock.FakeClock) {
@@ -98,7 +98,7 @@ func TestResync(t *testing.T) {
9898
condition := newTestCondition("TestCondition")
9999
m.conditions = map[string]types.Condition{condition.Type: condition}
100100
m.sync()
101-
expected := []api.NodeCondition{problemutil.ConvertToAPICondition(condition)}
101+
expected := []v1.NodeCondition{problemutil.ConvertToAPICondition(condition)}
102102
assert.Nil(t, fakeClient.AssertConditions(expected), "Condition should be updated via client")
103103

104104
assert.False(t, m.needResync(), "Should not resync before resync period")
@@ -118,7 +118,7 @@ func TestHeartbeat(t *testing.T) {
118118
condition := newTestCondition("TestCondition")
119119
m.conditions = map[string]types.Condition{condition.Type: condition}
120120
m.sync()
121-
expected := []api.NodeCondition{problemutil.ConvertToAPICondition(condition)}
121+
expected := []v1.NodeCondition{problemutil.ConvertToAPICondition(condition)}
122122
assert.Nil(t, fakeClient.AssertConditions(expected), "Condition should be updated via client")
123123

124124
assert.False(t, m.needHeartbeat(), "Should not heartbeat before heartbeat period")

pkg/logcounter/log_counter.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ import (
2020
"fmt"
2121
"time"
2222

23-
"k8s.io/kubernetes/pkg/util/clock"
23+
"k8s.io/apimachinery/pkg/util/clock"
2424

2525
"k8s.io/node-problem-detector/cmd/logcounter/options"
2626
"k8s.io/node-problem-detector/pkg/logcounter/types"

pkg/logcounter/log_counter_test.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ import (
2020
"testing"
2121
"time"
2222

23-
"k8s.io/kubernetes/pkg/util/clock"
23+
"k8s.io/apimachinery/pkg/util/clock"
2424

2525
"k8s.io/node-problem-detector/pkg/logcounter/types"
2626
"k8s.io/node-problem-detector/pkg/systemlogmonitor"

pkg/problemclient/fake_problem_client.go

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -21,20 +21,20 @@ import (
2121
"reflect"
2222
"sync"
2323

24-
"k8s.io/kubernetes/pkg/api"
24+
"k8s.io/api/core/v1"
2525
)
2626

2727
// FakeProblemClient is a fake problem client for debug.
2828
type FakeProblemClient struct {
2929
sync.Mutex
30-
conditions map[api.NodeConditionType]api.NodeCondition
30+
conditions map[v1.NodeConditionType]v1.NodeCondition
3131
errors map[string]error
3232
}
3333

3434
// NewFakeProblemClient creates a new fake problem client.
3535
func NewFakeProblemClient() *FakeProblemClient {
3636
return &FakeProblemClient{
37-
conditions: make(map[api.NodeConditionType]api.NodeCondition),
37+
conditions: make(map[v1.NodeConditionType]v1.NodeCondition),
3838
errors: make(map[string]error),
3939
}
4040
}
@@ -48,8 +48,8 @@ func (f *FakeProblemClient) InjectError(fun string, err error) {
4848

4949
// AssertConditions asserts that the internal conditions in fake problem client should match
5050
// the expected conditions.
51-
func (f *FakeProblemClient) AssertConditions(expected []api.NodeCondition) error {
52-
conditions := map[api.NodeConditionType]api.NodeCondition{}
51+
func (f *FakeProblemClient) AssertConditions(expected []v1.NodeCondition) error {
52+
conditions := map[v1.NodeConditionType]v1.NodeCondition{}
5353
for _, condition := range expected {
5454
conditions[condition.Type] = condition
5555
}
@@ -60,7 +60,7 @@ func (f *FakeProblemClient) AssertConditions(expected []api.NodeCondition) error
6060
}
6161

6262
// SetConditions is a fake mimic of SetConditions, it only update the internal condition cache.
63-
func (f *FakeProblemClient) SetConditions(conditions []api.NodeCondition) error {
63+
func (f *FakeProblemClient) SetConditions(conditions []v1.NodeCondition) error {
6464
f.Lock()
6565
defer f.Unlock()
6666
if err, ok := f.errors["SetConditions"]; ok {
@@ -73,13 +73,13 @@ func (f *FakeProblemClient) SetConditions(conditions []api.NodeCondition) error
7373
}
7474

7575
// GetConditions is a fake mimic of GetConditions, it returns the conditions cached internally.
76-
func (f *FakeProblemClient) GetConditions(types []api.NodeConditionType) ([]*api.NodeCondition, error) {
76+
func (f *FakeProblemClient) GetConditions(types []v1.NodeConditionType) ([]*v1.NodeCondition, error) {
7777
f.Lock()
7878
defer f.Unlock()
7979
if err, ok := f.errors["GetConditions"]; ok {
8080
return nil, err
8181
}
82-
conditions := []*api.NodeCondition{}
82+
conditions := []*v1.NodeCondition{}
8383
for _, t := range types {
8484
condition, ok := f.conditions[t]
8585
if ok {

pkg/problemclient/problem_client.go

Lines changed: 28 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -23,13 +23,17 @@ import (
2323
"os"
2424
"path/filepath"
2525

26-
"k8s.io/kubernetes/pkg/api"
27-
"k8s.io/kubernetes/pkg/api/unversioned"
28-
"k8s.io/kubernetes/pkg/client/record"
29-
client "k8s.io/kubernetes/pkg/client/unversioned"
30-
"k8s.io/kubernetes/pkg/types"
31-
"k8s.io/kubernetes/pkg/util/clock"
26+
typedcorev1 "k8s.io/client-go/kubernetes/typed/core/v1"
27+
"k8s.io/kubernetes/pkg/api/legacyscheme"
3228

29+
"k8s.io/api/core/v1"
30+
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
31+
"k8s.io/apimachinery/pkg/types"
32+
"k8s.io/apimachinery/pkg/util/clock"
33+
clientset "k8s.io/client-go/kubernetes"
34+
"k8s.io/client-go/tools/record"
35+
36+
"github.com/golang/glog"
3337
"k8s.io/heapster/common/kubernetes"
3438
"k8s.io/node-problem-detector/cmd/options"
3539
"k8s.io/node-problem-detector/pkg/version"
@@ -38,19 +42,19 @@ import (
3842
// Client is the interface of problem client
3943
type Client interface {
4044
// GetConditions get all specifiec conditions of current node.
41-
GetConditions(conditionTypes []api.NodeConditionType) ([]*api.NodeCondition, error)
45+
GetConditions(conditionTypes []v1.NodeConditionType) ([]*v1.NodeCondition, error)
4246
// SetConditions set or update conditions of current node.
43-
SetConditions(conditions []api.NodeCondition) error
47+
SetConditions(conditions []v1.NodeCondition) error
4448
// Eventf reports the event.
4549
Eventf(eventType string, source, reason, messageFmt string, args ...interface{})
4650
}
4751

4852
type nodeProblemClient struct {
4953
nodeName string
50-
client *client.Client
54+
client typedcorev1.CoreV1Interface
5155
clock clock.Clock
5256
recorders map[string]record.EventRecorder
53-
nodeRef *api.ObjectReference
57+
nodeRef *v1.ObjectReference
5458
}
5559

5660
// NewClientOrDie creates a new problem client, panics if error occurs.
@@ -67,19 +71,19 @@ func NewClientOrDie(npdo *options.NodeProblemDetectorOptions) Client {
6771

6872
cfg.UserAgent = fmt.Sprintf("%s/%s", filepath.Base(os.Args[0]), version.Version())
6973
// TODO(random-liu): Set QPS Limit
70-
c.client = client.NewOrDie(cfg)
74+
c.client = clientset.NewForConfigOrDie(cfg).CoreV1()
7175
c.nodeName = npdo.NodeName
7276
c.nodeRef = getNodeRef(c.nodeName)
7377
c.recorders = make(map[string]record.EventRecorder)
7478
return c
7579
}
7680

77-
func (c *nodeProblemClient) GetConditions(conditionTypes []api.NodeConditionType) ([]*api.NodeCondition, error) {
78-
node, err := c.client.Nodes().Get(c.nodeName)
81+
func (c *nodeProblemClient) GetConditions(conditionTypes []v1.NodeConditionType) ([]*v1.NodeCondition, error) {
82+
node, err := c.client.Nodes().Get(c.nodeName, metav1.GetOptions{})
7983
if err != nil {
8084
return nil, err
8185
}
82-
conditions := []*api.NodeCondition{}
86+
conditions := []*v1.NodeCondition{}
8387
for _, conditionType := range conditionTypes {
8488
for _, condition := range node.Status.Conditions {
8589
if condition.Type == conditionType {
@@ -90,16 +94,16 @@ func (c *nodeProblemClient) GetConditions(conditionTypes []api.NodeConditionType
9094
return conditions, nil
9195
}
9296

93-
func (c *nodeProblemClient) SetConditions(newConditions []api.NodeCondition) error {
97+
func (c *nodeProblemClient) SetConditions(newConditions []v1.NodeCondition) error {
9498
for i := range newConditions {
9599
// Each time we update the conditions, we update the heart beat time
96-
newConditions[i].LastHeartbeatTime = unversioned.NewTime(c.clock.Now())
100+
newConditions[i].LastHeartbeatTime = metav1.NewTime(c.clock.Now())
97101
}
98102
patch, err := generatePatch(newConditions)
99103
if err != nil {
100104
return err
101105
}
102-
return c.client.Patch(api.StrategicMergePatchType).Resource("nodes").Name(c.nodeName).SubResource("status").Body(patch).Do().Error()
106+
return c.client.RESTClient().Patch(types.StrategicMergePatchType).Resource("nodes").Name(c.nodeName).SubResource("status").Body(patch).Do().Error()
103107
}
104108

105109
func (c *nodeProblemClient) Eventf(eventType, source, reason, messageFmt string, args ...interface{}) {
@@ -113,7 +117,7 @@ func (c *nodeProblemClient) Eventf(eventType, source, reason, messageFmt string,
113117
}
114118

115119
// generatePatch generates condition patch
116-
func generatePatch(conditions []api.NodeCondition) ([]byte, error) {
120+
func generatePatch(conditions []v1.NodeCondition) ([]byte, error) {
117121
raw, err := json.Marshal(&conditions)
118122
if err != nil {
119123
return nil, err
@@ -122,16 +126,17 @@ func generatePatch(conditions []api.NodeCondition) ([]byte, error) {
122126
}
123127

124128
// getEventRecorder generates a recorder for specific node name and source.
125-
func getEventRecorder(c *client.Client, nodeName, source string) record.EventRecorder {
129+
func getEventRecorder(c typedcorev1.CoreV1Interface, nodeName, source string) record.EventRecorder {
126130
eventBroadcaster := record.NewBroadcaster()
127-
recorder := eventBroadcaster.NewRecorder(api.EventSource{Component: source, Host: nodeName})
128-
eventBroadcaster.StartRecordingToSink(c.Events(""))
131+
eventBroadcaster.StartLogging(glog.V(4).Infof)
132+
recorder := eventBroadcaster.NewRecorder(legacyscheme.Scheme, v1.EventSource{Component: source, Host: nodeName})
133+
eventBroadcaster.StartRecordingToSink(&typedcorev1.EventSinkImpl{Interface: c.Events("")})
129134
return recorder
130135
}
131136

132-
func getNodeRef(nodeName string) *api.ObjectReference {
137+
func getNodeRef(nodeName string) *v1.ObjectReference {
133138
// TODO(random-liu): Get node to initialize the node reference
134-
return &api.ObjectReference{
139+
return &v1.ObjectReference{
135140
Kind: "Node",
136141
Name: nodeName,
137142
UID: types.UID(nodeName),

pkg/problemclient/problem_client_test.go

Lines changed: 11 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -22,10 +22,10 @@ import (
2222
"testing"
2323
"time"
2424

25-
"k8s.io/kubernetes/pkg/api"
26-
"k8s.io/kubernetes/pkg/api/unversioned"
27-
"k8s.io/kubernetes/pkg/client/record"
28-
"k8s.io/kubernetes/pkg/util/clock"
25+
"k8s.io/api/core/v1"
26+
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
27+
"k8s.io/apimachinery/pkg/util/clock"
28+
"k8s.io/client-go/tools/record"
2929

3030
"github.com/stretchr/testify/assert"
3131
)
@@ -48,18 +48,18 @@ func newFakeProblemClient() *nodeProblemClient {
4848

4949
func TestGeneratePatch(t *testing.T) {
5050
now := time.Now()
51-
update := []api.NodeCondition{
51+
update := []v1.NodeCondition{
5252
{
5353
Type: "TestType1",
54-
Status: api.ConditionTrue,
55-
LastTransitionTime: unversioned.NewTime(now),
54+
Status: v1.ConditionTrue,
55+
LastTransitionTime: metav1.NewTime(now),
5656
Reason: "TestReason1",
5757
Message: "TestMessage1",
5858
},
5959
{
6060
Type: "TestType2",
61-
Status: api.ConditionFalse,
62-
LastTransitionTime: unversioned.NewTime(now),
61+
Status: v1.ConditionFalse,
62+
LastTransitionTime: metav1.NewTime(now),
6363
Reason: "TestReason2",
6464
Message: "TestMessage2",
6565
},
@@ -79,8 +79,8 @@ func TestEvent(t *testing.T) {
7979
fakeRecorder := record.NewFakeRecorder(1)
8080
client := newFakeProblemClient()
8181
client.recorders[testSource] = fakeRecorder
82-
client.Eventf(api.EventTypeWarning, testSource, "test reason", "test message")
83-
expected := fmt.Sprintf("%s %s %s", api.EventTypeWarning, "test reason", "test message")
82+
client.Eventf(v1.EventTypeWarning, testSource, "test reason", "test message")
83+
expected := fmt.Sprintf("%s %s %s", v1.EventTypeWarning, "test reason", "test message")
8484
got := <-fakeRecorder.Events
8585
if expected != got {
8686
t.Errorf("expected event %q, got %q", expected, got)

pkg/problemdetector/problem_detector.go

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ import (
2222

2323
"github.com/golang/glog"
2424

25-
"k8s.io/kubernetes/pkg/util/clock"
25+
"k8s.io/apimachinery/pkg/util/clock"
2626

2727
"k8s.io/node-problem-detector/pkg/condition"
2828
"k8s.io/node-problem-detector/pkg/problemclient"
@@ -78,8 +78,8 @@ func (p *problemDetector) Run() error {
7878
for _, event := range status.Events {
7979
p.client.Eventf(util.ConvertToAPIEventType(event.Severity), status.Source, event.Reason, event.Message)
8080
}
81-
for _, condition := range status.Conditions {
82-
p.conditionManager.UpdateCondition(condition)
81+
for _, cdt := range status.Conditions {
82+
p.conditionManager.UpdateCondition(cdt)
8383
}
8484
}
8585
}

pkg/util/convert.go

Lines changed: 17 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -19,32 +19,32 @@ package util
1919
import (
2020
"time"
2121

22-
"k8s.io/kubernetes/pkg/api"
23-
"k8s.io/kubernetes/pkg/api/unversioned"
22+
"k8s.io/api/core/v1"
23+
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
2424

2525
"k8s.io/node-problem-detector/pkg/types"
2626
)
2727

28-
// ConvertToAPICondition converts the internal node condition to api.NodeCondition.
29-
func ConvertToAPICondition(condition types.Condition) api.NodeCondition {
30-
return api.NodeCondition{
31-
Type: api.NodeConditionType(condition.Type),
28+
// ConvertToAPICondition converts the internal node condition to v1.NodeCondition.
29+
func ConvertToAPICondition(condition types.Condition) v1.NodeCondition {
30+
return v1.NodeCondition{
31+
Type: v1.NodeConditionType(condition.Type),
3232
Status: ConvertToAPIConditionStatus(condition.Status),
3333
LastTransitionTime: ConvertToAPITimestamp(condition.Transition),
3434
Reason: condition.Reason,
3535
Message: condition.Message,
3636
}
3737
}
3838

39-
// ConvertToAPIConditionStatus converts the internal node condition status to api.ConditionStatus.
40-
func ConvertToAPIConditionStatus(status types.ConditionStatus) api.ConditionStatus {
39+
// ConvertToAPIConditionStatus converts the internal node condition status to v1.ConditionStatus.
40+
func ConvertToAPIConditionStatus(status types.ConditionStatus) v1.ConditionStatus {
4141
switch status {
4242
case types.True:
43-
return api.ConditionTrue
43+
return v1.ConditionTrue
4444
case types.False:
45-
return api.ConditionFalse
45+
return v1.ConditionFalse
4646
case types.Unknown:
47-
return api.ConditionUnknown
47+
return v1.ConditionUnknown
4848
default:
4949
panic("unknown condition status")
5050
}
@@ -54,16 +54,16 @@ func ConvertToAPIConditionStatus(status types.ConditionStatus) api.ConditionStat
5454
func ConvertToAPIEventType(severity types.Severity) string {
5555
switch severity {
5656
case types.Info:
57-
return api.EventTypeNormal
57+
return v1.EventTypeNormal
5858
case types.Warn:
59-
return api.EventTypeWarning
59+
return v1.EventTypeWarning
6060
default:
6161
// Should never get here, just in case
62-
return api.EventTypeNormal
62+
return v1.EventTypeNormal
6363
}
6464
}
6565

66-
// ConvertToAPITimestamp converts the timestamp to unversioned.Time
67-
func ConvertToAPITimestamp(timestamp time.Time) unversioned.Time {
68-
return unversioned.NewTime(timestamp)
66+
// ConvertToAPITimestamp converts the timestamp to metav1.Time
67+
func ConvertToAPITimestamp(timestamp time.Time) metav1.Time {
68+
return metav1.NewTime(timestamp)
6969
}

0 commit comments

Comments
 (0)