Skip to content
This repository was archived by the owner on Feb 23, 2026. It is now read-only.

Commit c5e1175

Browse files
committed
refactor(system): remove context timeout from GetKernelVersion calls
1 parent 7fa2bd7 commit c5e1175

2 files changed

Lines changed: 6 additions & 10 deletions

File tree

cmd/patchmon-agent/commands/diagnostics.go

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -2,13 +2,11 @@ package commands
22

33
import (
44
"bufio"
5-
"context"
65
"fmt"
76
"io"
87
"os"
98
"runtime"
109
"strings"
11-
"time"
1210

1311
"patchmon-agent/internal/crontab"
1412
"patchmon-agent/internal/system"
@@ -39,9 +37,7 @@ func showDiagnostics() error {
3937
fmt.Printf(" Architecture: %s\n", runtime.GOARCH)
4038

4139
systemDetector := system.New(logger)
42-
ctx, cancel := context.WithTimeout(context.Background(), 5*time.Second)
43-
defer cancel()
44-
kernelVersion := systemDetector.GetKernelVersion(ctx)
40+
kernelVersion := systemDetector.GetKernelVersion()
4541
fmt.Printf(" Kernel: %s\n", kernelVersion)
4642

4743
if hostname, err := os.Hostname(); err == nil {

internal/system/system.go

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -57,13 +57,10 @@ func (d *Detector) DetectOS() (osType, osVersion string, err error) {
5757

5858
// GetSystemInfo gets additional system information
5959
func (d *Detector) GetSystemInfo() models.SystemInfo {
60-
ctx, cancel := context.WithTimeout(context.Background(), 10*time.Second)
61-
defer cancel()
62-
6360
d.logger.Debug("Beginning system information collection")
6461

6562
info := models.SystemInfo{
66-
KernelVersion: d.GetKernelVersion(ctx),
63+
KernelVersion: d.GetKernelVersion(),
6764
SELinuxStatus: d.getSELinuxStatus(),
6865
SystemUptime: d.getSystemUptime(ctx),
6966
LoadAverage: d.getLoadAverage(ctx),
@@ -139,7 +136,10 @@ func (d *Detector) GetIPAddress() string {
139136
}
140137

141138
// GetKernelVersion gets the kernel version
142-
func (d *Detector) GetKernelVersion(ctx context.Context) string {
139+
func (d *Detector) GetKernelVersion() string {
140+
ctx, cancel := context.WithTimeout(context.Background(), 5*time.Second)
141+
defer cancel()
142+
143143
info, err := host.InfoWithContext(ctx)
144144
if err != nil {
145145
d.logger.WithError(err).Warn("Failed to get kernel version")

0 commit comments

Comments
 (0)