Skip to content

Commit

Permalink
agent: golangci-lint fixes.
Browse files Browse the repository at this point in the history
Signed-off-by: Krisztian Litkey <[email protected]>
  • Loading branch information
klihub committed Dec 10, 2024
1 parent 331b1ec commit b4c9232
Show file tree
Hide file tree
Showing 4 changed files with 6 additions and 21 deletions.
6 changes: 3 additions & 3 deletions pkg/agent/agent.go
Original file line number Diff line number Diff line change
Expand Up @@ -212,10 +212,10 @@ func (a *Agent) Start(notifyFn NotifyFn) error {
break
}
if e.Type == watch.Added || e.Type == watch.Modified {
group, _ := e.Object.(*corev1.Node).Labels[a.groupLabel]
group := e.Object.(*corev1.Node).Labels[a.groupLabel]
if group == "" {
for _, l := range deprecatedGroupLabels {
group, _ = e.Object.(*corev1.Node).Labels[l]
group = e.Object.(*corev1.Node).Labels[l]
if group != "" {
log.Warnf("Using DEPRECATED config group label %q", l)
log.Warnf("Please switch to using label %q instead", a.groupLabel)
Expand Down Expand Up @@ -259,7 +259,7 @@ func (a *Agent) Stop() {

if a.stopC != nil {
close(a.stopC)
_ = <-a.doneC
<-a.doneC
a.stopC = nil
}
}
Expand Down
16 changes: 1 addition & 15 deletions pkg/agent/podresapi/client.go
Original file line number Diff line number Diff line change
Expand Up @@ -17,9 +17,7 @@ package podresapi
import (
"context"
"fmt"
"net"
"strings"
"time"

logger "github.com/containers/nri-plugins/pkg/log"
"google.golang.org/grpc"
Expand All @@ -43,7 +41,6 @@ const (
// these constants were obtained from NFD sources, cross-checked against
// https://github.com/kubernetes/kubernetes/blob/release-1.31/test/e2e_node/util.go#L83
defaultSocketPath = "/var/lib/kubelet/pod-resources/kubelet.sock"
timeout = 10 * time.Second
maxSize = 1024 * 1024 * 16
)

Expand Down Expand Up @@ -77,20 +74,9 @@ func NewClient(options ...ClientOption) (*Client, error) {
}

if c.conn == nil {
ctx, cancel := context.WithTimeout(context.Background(), timeout)
defer cancel()

dialer := func(ctx context.Context, addr string) (net.Conn, error) {
return (&net.Dialer{}).DialContext(ctx, "unix", addr)
}

conn, err := grpc.DialContext(
ctx,
c.socketPath,
conn, err := grpc.NewClient("unix://"+c.socketPath,
grpc.WithTransportCredentials(insecure.NewCredentials()),
grpc.WithContextDialer(dialer),
grpc.WithDefaultCallOptions(grpc.MaxCallRecvMsgSize(maxSize)),
grpc.WithBlock(),
)

if err != nil {
Expand Down
2 changes: 1 addition & 1 deletion pkg/agent/watch/file.go
Original file line number Diff line number Diff line change
Expand Up @@ -87,7 +87,7 @@ func (w *FileWatch) Stop() {

if w.stopC != nil {
close(w.stopC)
_ = <-w.doneC
<-w.doneC
w.stopC = nil
}
}
Expand Down
3 changes: 1 addition & 2 deletions pkg/agent/watch/object.go
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,6 @@ type ObjectWatch struct {
name string
resultC chan Event
wif watch.Interface
pending *Event
reopenC <-chan time.Time
failing bool

Expand Down Expand Up @@ -73,7 +72,7 @@ func (w *ObjectWatch) Stop() {

if w.stopC != nil {
close(w.stopC)
_ = <-w.doneC
<-w.doneC
w.stopC = nil
}
}
Expand Down

0 comments on commit b4c9232

Please sign in to comment.