Skip to content

Commit

Permalink
Update Kubernetes dependencies
Browse files Browse the repository at this point in the history
  • Loading branch information
Nuckal777 committed Dec 19, 2023
1 parent ff9cae6 commit 2b17b9c
Show file tree
Hide file tree
Showing 3 changed files with 40 additions and 89 deletions.
27 changes: 20 additions & 7 deletions event/event.go
Original file line number Diff line number Diff line change
Expand Up @@ -198,28 +198,31 @@ func (e *eventBroadcasterImpl) StartEventWatcher(eventHandler func(*v1.Event)) w
}

// NewRecorder returns an EventRecorder that records events with the given event source.
func (e *eventBroadcasterImpl) NewRecorder(scheme *runtime.Scheme, source v1.EventSource) record.EventRecorder {
return &NodeRecorder{scheme, source, e.Broadcaster, clock.RealClock{}}
func (e *eventBroadcasterImpl) NewRecorder(scheme *runtime.Scheme, source v1.EventSource) record.EventRecorderLogger {
return &NodeRecorder{scheme, source, e.Broadcaster, clock.RealClock{}, klog.Background()}
}

type NodeRecorder struct {
scheme *runtime.Scheme
source v1.EventSource
*watch.Broadcaster
clock clock.Clock
clock clock.Clock
logger klog.Logger
}

func (recorder *NodeRecorder) generateEvent(object runtime.Object, annotations map[string]string,
source *v1.EventSource, eventtype, reason, message string) {
ref, err := ref.GetReference(recorder.scheme, object)
if err != nil {
klog.Errorf("Could not construct reference to: '%#v' due to: '%v'. Will not report event: '%v' '%v' '%v'",
object, err, eventtype, reason, message)
recorder.logger.Error(
err,
fmt.Sprintf("Could not construct reference to: '%#v' due to: '%v'. Will not report event: '%v' '%v' '%v'",
object, err, eventtype, reason, message))
return
}

if !util.ValidateEventType(eventtype) {
klog.Errorf("Unsupported event type: '%v'", eventtype)
recorder.logger.Error(nil, fmt.Sprintf("Unsupported event type: '%v'", eventtype))
return
}

Expand All @@ -235,7 +238,7 @@ func (recorder *NodeRecorder) generateEvent(object runtime.Object, annotations m
defer utilruntime.HandleCrash()
err = recorder.Action(watch.Added, event)
if err != nil {
klog.Errorf("error for recorder.Action in eventBroadcasterImpl: %s", err)
recorder.logger.Error(err, "error for recorder.Action in NodeRecorder")
}
}()
}
Expand All @@ -254,6 +257,16 @@ func (recorder *NodeRecorder) AnnotatedEventf(object runtime.Object,
recorder.generateEvent(object, annotations, nil, eventtype, reason, fmt.Sprintf(messageFmt, args...))
}

func (recorder *NodeRecorder) WithLogger(logger klog.Logger) record.EventRecorderLogger {
return &NodeRecorder{
scheme: recorder.scheme,
source: recorder.source,
clock: recorder.clock,
logger: logger,
Broadcaster: recorder.Broadcaster,
}
}

func (recorder *NodeRecorder) makeEvent(ref *v1.ObjectReference, annotations map[string]string,
eventtype, reason, message string) *v1.Event {
t := metav1.Time{Time: recorder.clock.Now()}
Expand Down
12 changes: 6 additions & 6 deletions go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -19,9 +19,9 @@ require (
go.uber.org/zap v1.26.0
golang.org/x/exp v0.0.0-20231214170342-aacd6d4b4611
gopkg.in/ini.v1 v1.67.0
k8s.io/api v0.28.4
k8s.io/apimachinery v0.28.4
k8s.io/client-go v0.28.4
k8s.io/api v0.29.0
k8s.io/apimachinery v0.29.0
k8s.io/client-go v0.29.0
k8s.io/klog/v2 v2.110.1
k8s.io/utils v0.0.0-20231127182322-b307cd553661
sigs.k8s.io/controller-runtime v0.16.3
Expand All @@ -48,7 +48,7 @@ require (
github.com/google/gofuzz v1.2.0 // indirect
github.com/google/pprof v0.0.0-20210720184732-4bb14d4b1be1 // indirect
github.com/google/uuid v1.4.0 // indirect
github.com/gorilla/websocket v1.4.2 // indirect
github.com/gorilla/websocket v1.5.0 // indirect
github.com/hashicorp/go-uuid v1.0.3 // indirect
github.com/imdario/mergo v0.3.12 // indirect
github.com/josharian/intern v1.0.0 // indirect
Expand Down Expand Up @@ -80,8 +80,8 @@ require (
gopkg.in/yaml.v3 v3.0.1 // indirect
k8s.io/apiextensions-apiserver v0.28.3 // indirect
k8s.io/component-base v0.28.3 // indirect
k8s.io/kube-openapi v0.0.0-20230717233707-2695361300d9 // indirect
k8s.io/kube-openapi v0.0.0-20231010175941-2dd684a91f00 // indirect
sigs.k8s.io/json v0.0.0-20221116044647-bc3834ca7abd // indirect
sigs.k8s.io/structured-merge-diff/v4 v4.2.3 // indirect
sigs.k8s.io/structured-merge-diff/v4 v4.4.1 // indirect
sigs.k8s.io/yaml v1.3.0 // indirect
)
Loading

0 comments on commit 2b17b9c

Please sign in to comment.