Skip to content

Commit ed94dff

Browse files
authored
Merge pull request #816 from hakman/remove_fakeclock
Remove dependency on code.cloudfoundry.org/clock
2 parents fb49856 + 65e4aa3 commit ed94dff

File tree

18 files changed

+4
-607
lines changed

18 files changed

+4
-607
lines changed

go.mod

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,6 @@ go 1.20
44

55
require (
66
cloud.google.com/go/compute/metadata v0.2.3
7-
code.cloudfoundry.org/clock v1.1.0
87
contrib.go.opencensus.io/exporter/prometheus v0.4.2
98
contrib.go.opencensus.io/exporter/stackdriver v0.13.14
109
github.com/acobaugh/osrelease v0.1.0

go.sum

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -58,8 +58,6 @@ cloud.google.com/go/storage v1.8.0/go.mod h1:Wv1Oy7z6Yz3DshWRJFhqM/UCfaWIRTdp0RX
5858
cloud.google.com/go/storage v1.10.0/go.mod h1:FLPqc6j+Ki4BU591ie1oL6qBQGu2Bl/tZ9ullr3+Kg0=
5959
cloud.google.com/go/trace v1.10.1 h1:EwGdOLCNfYOOPtgqo+D2sDLZmRCEO1AagRTJCU6ztdg=
6060
cloud.google.com/go/trace v1.10.1/go.mod h1:gbtL94KE5AJLH3y+WVpfWILmqgc6dXcqgNXdOPAQTYk=
61-
code.cloudfoundry.org/clock v1.1.0 h1:XLzC6W3Ah/Y7ht1rmZ6+QfPdt1iGWEAAtIZXgiaj57c=
62-
code.cloudfoundry.org/clock v1.1.0/go.mod h1:yA3fxddT9RINQL2XHS7PS+OXxKCGhfrZmlNUCIM6AKo=
6361
contrib.go.opencensus.io/exporter/prometheus v0.4.2 h1:sqfsYl5GIY/L570iT+l93ehxaWJs2/OwXtiWwew3oAg=
6462
contrib.go.opencensus.io/exporter/prometheus v0.4.2/go.mod h1:dvEHbiKmgvbr5pjaF9fpw1KeYcjrnC1J8B+JKjsZyRQ=
6563
contrib.go.opencensus.io/exporter/stackdriver v0.13.14 h1:zBakwHardp9Jcb8sQHcHpXy/0+JIb1M8KjigCJzx7+4=
@@ -1074,7 +1072,6 @@ github.com/syndtr/gocapability v0.0.0-20170704070218-db04d3cc01c8/go.mod h1:hkRG
10741072
github.com/syndtr/gocapability v0.0.0-20180916011248-d98352740cb2/go.mod h1:hkRG7XYTFWNJGYcbNJQlaLq0fg1yr4J4t/NcTQtrfww=
10751073
github.com/syndtr/gocapability v0.0.0-20200815063812-42c35b437635/go.mod h1:hkRG7XYTFWNJGYcbNJQlaLq0fg1yr4J4t/NcTQtrfww=
10761074
github.com/tchap/go-patricia v2.2.6+incompatible/go.mod h1:bmLyhP68RS6kStMGxByiQ23RP/odRBOTVjwp2cDyi6I=
1077-
github.com/tedsuo/ifrit v0.0.0-20230330192023-5cba443a66c4 h1:MGZzzxBuPuK4J0XQo+0uy0NnXQGKzHXhYp5oG1Wy860=
10781075
github.com/tidwall/pretty v1.0.0/go.mod h1:XNkn88O1ChpSDQmQeStsy+sBenx6DDtFZJxhVysOjyk=
10791076
github.com/tklauser/go-sysconf v0.3.12 h1:0QaGUFOdQaIVdPgfITYzaTegZvdCjmYO52cSFAEVmqU=
10801077
github.com/tklauser/go-sysconf v0.3.12/go.mod h1:Ho14jnntGE1fpdOqQEEaiKRpvIavV0hSfmBq8nJbHYI=

pkg/systemlogmonitor/logwatchers/filelog/log_watcher.go

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,6 @@ import (
2323
"strings"
2424
"time"
2525

26-
utilclock "code.cloudfoundry.org/clock"
2726
"k8s.io/klog/v2"
2827

2928
"k8s.io/node-problem-detector/pkg/systemlogmonitor/logwatchers/types"
@@ -40,7 +39,6 @@ type filelogWatcher struct {
4039
logCh chan *logtypes.Log
4140
startTime time.Time
4241
tomb *tomb.Tomb
43-
clock utilclock.Clock
4442
}
4543

4644
// NewSyslogWatcherOrDie creates a new log watcher. The function panics
@@ -62,7 +60,6 @@ func NewSyslogWatcherOrDie(cfg types.WatcherConfig) types.LogWatcher {
6260
tomb: tomb.NewTomb(),
6361
// A capacity 1000 buffer should be enough
6462
logCh: make(chan *logtypes.Log, 1000),
65-
clock: utilclock.NewClock(),
6663
}
6764
}
6865

pkg/systemlogmonitor/logwatchers/filelog/log_watcher_test.go

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

28-
"code.cloudfoundry.org/clock/fakeclock"
2928
"github.com/stretchr/testify/assert"
29+
testclock "k8s.io/utils/clock/testing"
3030
)
3131

3232
// getTestPluginConfig returns a plugin config for test. Use configuration for
@@ -42,7 +42,7 @@ func getTestPluginConfig() map[string]string {
4242
func TestWatch(t *testing.T) {
4343
// now is a fake time
4444
now := time.Date(time.Now().Year(), time.January, 2, 3, 4, 5, 0, time.Local)
45-
fakeClock := fakeclock.NewFakeClock(now)
45+
fakeClock := testclock.NewFakeClock(now)
4646
testCases := []struct {
4747
uptime time.Duration
4848
lookback string
@@ -155,8 +155,6 @@ Jan 2 03:04:05 kernel: [2.000000] 3
155155
})
156156
// Set the startTime.
157157
w.(*filelogWatcher).startTime, _ = util.GetStartTime(fakeClock.Now(), test.uptime, test.lookback, test.delay)
158-
// Set the fake clock.
159-
w.(*filelogWatcher).clock = fakeClock
160158
logCh, err := w.Watch()
161159
assert.NoError(t, err)
162160
defer w.Stop()

pkg/systemlogmonitor/logwatchers/kmsg/log_watcher_linux.go

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,6 @@ import (
2121
"strings"
2222
"time"
2323

24-
utilclock "code.cloudfoundry.org/clock"
2524
"github.com/euank/go-kmsg-parser/kmsgparser"
2625
"k8s.io/klog/v2"
2726

@@ -38,7 +37,6 @@ type kernelLogWatcher struct {
3837
tomb *tomb.Tomb
3938

4039
kmsgParser kmsgparser.Parser
41-
clock utilclock.Clock
4240
}
4341

4442
// NewKmsgWatcher creates a watcher which will read messages from /dev/kmsg
@@ -58,7 +56,6 @@ func NewKmsgWatcher(cfg types.WatcherConfig) types.LogWatcher {
5856
tomb: tomb.NewTomb(),
5957
// Arbitrary capacity
6058
logCh: make(chan *logtypes.Log, 100),
61-
clock: utilclock.NewClock(),
6259
}
6360
}
6461

pkg/systemlogmonitor/logwatchers/kmsg/log_watcher_linux_test.go

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -17,12 +17,11 @@ limitations under the License.
1717
package kmsg
1818

1919
import (
20+
testclock "k8s.io/utils/clock/testing"
2021
"testing"
2122

22-
"code.cloudfoundry.org/clock/fakeclock"
2323
"github.com/euank/go-kmsg-parser/kmsgparser"
2424
"github.com/stretchr/testify/assert"
25-
2625
"time"
2726

2827
"k8s.io/node-problem-detector/pkg/systemlogmonitor/logwatchers/types"
@@ -49,7 +48,7 @@ func (m *mockKmsgParser) SeekEnd() error { return nil }
4948

5049
func TestWatch(t *testing.T) {
5150
now := time.Date(time.Now().Year(), time.January, 2, 3, 4, 5, 0, time.Local)
52-
fakeClock := fakeclock.NewFakeClock(now)
51+
fakeClock := testclock.NewFakeClock(now)
5352
testCases := []struct {
5453
uptime time.Duration
5554
lookback string
@@ -150,7 +149,6 @@ func TestWatch(t *testing.T) {
150149
for _, test := range testCases {
151150
w := NewKmsgWatcher(types.WatcherConfig{Lookback: test.lookback})
152151
w.(*kernelLogWatcher).startTime, _ = util.GetStartTime(fakeClock.Now(), test.uptime, test.lookback, test.delay)
153-
w.(*kernelLogWatcher).clock = fakeClock
154152
w.(*kernelLogWatcher).kmsgParser = test.log
155153
logCh, err := w.Watch()
156154
if err != nil {

vendor/code.cloudfoundry.org/clock/LICENSE

Lines changed: 0 additions & 201 deletions
This file was deleted.

vendor/code.cloudfoundry.org/clock/NOTICE

Lines changed: 0 additions & 20 deletions
This file was deleted.

vendor/code.cloudfoundry.org/clock/README.md

Lines changed: 0 additions & 13 deletions
This file was deleted.

0 commit comments

Comments
 (0)