Skip to content

Commit

Permalink
Merge pull request kubernetes#816 from hakman/remove_fakeclock
Browse files Browse the repository at this point in the history
Remove dependency on code.cloudfoundry.org/clock
  • Loading branch information
k8s-ci-robot authored Sep 19, 2023
2 parents fb49856 + 65e4aa3 commit ed94dff
Show file tree
Hide file tree
Showing 18 changed files with 4 additions and 607 deletions.
1 change: 0 additions & 1 deletion go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@ go 1.20

require (
cloud.google.com/go/compute/metadata v0.2.3
code.cloudfoundry.org/clock v1.1.0
contrib.go.opencensus.io/exporter/prometheus v0.4.2
contrib.go.opencensus.io/exporter/stackdriver v0.13.14
github.com/acobaugh/osrelease v0.1.0
Expand Down
3 changes: 0 additions & 3 deletions go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -58,8 +58,6 @@ cloud.google.com/go/storage v1.8.0/go.mod h1:Wv1Oy7z6Yz3DshWRJFhqM/UCfaWIRTdp0RX
cloud.google.com/go/storage v1.10.0/go.mod h1:FLPqc6j+Ki4BU591ie1oL6qBQGu2Bl/tZ9ullr3+Kg0=
cloud.google.com/go/trace v1.10.1 h1:EwGdOLCNfYOOPtgqo+D2sDLZmRCEO1AagRTJCU6ztdg=
cloud.google.com/go/trace v1.10.1/go.mod h1:gbtL94KE5AJLH3y+WVpfWILmqgc6dXcqgNXdOPAQTYk=
code.cloudfoundry.org/clock v1.1.0 h1:XLzC6W3Ah/Y7ht1rmZ6+QfPdt1iGWEAAtIZXgiaj57c=
code.cloudfoundry.org/clock v1.1.0/go.mod h1:yA3fxddT9RINQL2XHS7PS+OXxKCGhfrZmlNUCIM6AKo=
contrib.go.opencensus.io/exporter/prometheus v0.4.2 h1:sqfsYl5GIY/L570iT+l93ehxaWJs2/OwXtiWwew3oAg=
contrib.go.opencensus.io/exporter/prometheus v0.4.2/go.mod h1:dvEHbiKmgvbr5pjaF9fpw1KeYcjrnC1J8B+JKjsZyRQ=
contrib.go.opencensus.io/exporter/stackdriver v0.13.14 h1:zBakwHardp9Jcb8sQHcHpXy/0+JIb1M8KjigCJzx7+4=
Expand Down Expand Up @@ -1074,7 +1072,6 @@ github.com/syndtr/gocapability v0.0.0-20170704070218-db04d3cc01c8/go.mod h1:hkRG
github.com/syndtr/gocapability v0.0.0-20180916011248-d98352740cb2/go.mod h1:hkRG7XYTFWNJGYcbNJQlaLq0fg1yr4J4t/NcTQtrfww=
github.com/syndtr/gocapability v0.0.0-20200815063812-42c35b437635/go.mod h1:hkRG7XYTFWNJGYcbNJQlaLq0fg1yr4J4t/NcTQtrfww=
github.com/tchap/go-patricia v2.2.6+incompatible/go.mod h1:bmLyhP68RS6kStMGxByiQ23RP/odRBOTVjwp2cDyi6I=
github.com/tedsuo/ifrit v0.0.0-20230330192023-5cba443a66c4 h1:MGZzzxBuPuK4J0XQo+0uy0NnXQGKzHXhYp5oG1Wy860=
github.com/tidwall/pretty v1.0.0/go.mod h1:XNkn88O1ChpSDQmQeStsy+sBenx6DDtFZJxhVysOjyk=
github.com/tklauser/go-sysconf v0.3.12 h1:0QaGUFOdQaIVdPgfITYzaTegZvdCjmYO52cSFAEVmqU=
github.com/tklauser/go-sysconf v0.3.12/go.mod h1:Ho14jnntGE1fpdOqQEEaiKRpvIavV0hSfmBq8nJbHYI=
Expand Down
3 changes: 0 additions & 3 deletions pkg/systemlogmonitor/logwatchers/filelog/log_watcher.go
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,6 @@ import (
"strings"
"time"

utilclock "code.cloudfoundry.org/clock"
"k8s.io/klog/v2"

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

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

Expand Down
6 changes: 2 additions & 4 deletions pkg/systemlogmonitor/logwatchers/filelog/log_watcher_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -25,8 +25,8 @@ import (
logtypes "k8s.io/node-problem-detector/pkg/systemlogmonitor/types"
"k8s.io/node-problem-detector/pkg/util"

"code.cloudfoundry.org/clock/fakeclock"
"github.com/stretchr/testify/assert"
testclock "k8s.io/utils/clock/testing"
)

// getTestPluginConfig returns a plugin config for test. Use configuration for
Expand All @@ -42,7 +42,7 @@ func getTestPluginConfig() map[string]string {
func TestWatch(t *testing.T) {
// now is a fake time
now := time.Date(time.Now().Year(), time.January, 2, 3, 4, 5, 0, time.Local)
fakeClock := fakeclock.NewFakeClock(now)
fakeClock := testclock.NewFakeClock(now)
testCases := []struct {
uptime time.Duration
lookback string
Expand Down Expand Up @@ -155,8 +155,6 @@ Jan 2 03:04:05 kernel: [2.000000] 3
})
// Set the startTime.
w.(*filelogWatcher).startTime, _ = util.GetStartTime(fakeClock.Now(), test.uptime, test.lookback, test.delay)
// Set the fake clock.
w.(*filelogWatcher).clock = fakeClock
logCh, err := w.Watch()
assert.NoError(t, err)
defer w.Stop()
Expand Down
3 changes: 0 additions & 3 deletions pkg/systemlogmonitor/logwatchers/kmsg/log_watcher_linux.go
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,6 @@ import (
"strings"
"time"

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

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

kmsgParser kmsgparser.Parser
clock utilclock.Clock
}

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

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,12 +17,11 @@ limitations under the License.
package kmsg

import (
testclock "k8s.io/utils/clock/testing"
"testing"

"code.cloudfoundry.org/clock/fakeclock"
"github.com/euank/go-kmsg-parser/kmsgparser"
"github.com/stretchr/testify/assert"

"time"

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

func TestWatch(t *testing.T) {
now := time.Date(time.Now().Year(), time.January, 2, 3, 4, 5, 0, time.Local)
fakeClock := fakeclock.NewFakeClock(now)
fakeClock := testclock.NewFakeClock(now)
testCases := []struct {
uptime time.Duration
lookback string
Expand Down Expand Up @@ -150,7 +149,6 @@ func TestWatch(t *testing.T) {
for _, test := range testCases {
w := NewKmsgWatcher(types.WatcherConfig{Lookback: test.lookback})
w.(*kernelLogWatcher).startTime, _ = util.GetStartTime(fakeClock.Now(), test.uptime, test.lookback, test.delay)
w.(*kernelLogWatcher).clock = fakeClock
w.(*kernelLogWatcher).kmsgParser = test.log
logCh, err := w.Watch()
if err != nil {
Expand Down
201 changes: 0 additions & 201 deletions vendor/code.cloudfoundry.org/clock/LICENSE

This file was deleted.

20 changes: 0 additions & 20 deletions vendor/code.cloudfoundry.org/clock/NOTICE

This file was deleted.

13 changes: 0 additions & 13 deletions vendor/code.cloudfoundry.org/clock/README.md

This file was deleted.

Loading

0 comments on commit ed94dff

Please sign in to comment.