Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

agent: golangci-lint fixes. #425

Merged
merged 1 commit into from
Dec 11, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
Loading