Skip to content

Commit

Permalink
expand smart data file limit to 64KB
Browse files Browse the repository at this point in the history
Signed-off-by: Petr Fedchenkov <giggsoff@gmail.com>
  • Loading branch information
giggsoff authored and rvs committed Nov 10, 2021
1 parent b1a7a04 commit 6dd783a
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 5 deletions.
3 changes: 2 additions & 1 deletion pkg/pillar/cmd/nodeagent/nodeagent.go
Original file line number Diff line number Diff line change
Expand Up @@ -57,6 +57,7 @@ const (
maxDomainHaltTime uint32 = 300
domainHaltWaitIncrement uint32 = 5
maxReadSize = 16384 // From files in /persist
maxSmartCtlSize = 65536 // Limit size of smartctl output files read
)

var (
Expand Down Expand Up @@ -696,7 +697,7 @@ func parseSMARTData() {
previousSMARTfilename := "/persist/SMART_details_previous.json"
parseData := func(filePath string, SMARTDataObj *types.SmartData) {
data, err := fileutils.ReadWithMaxSize(log, filePath,
maxReadSize)
maxSmartCtlSize)
if err != nil {
log.Errorf("parseSMARTData: exception while opening %s. %s", filePath, err.Error())
return
Expand Down
10 changes: 6 additions & 4 deletions pkg/pillar/cmd/zedagent/reportinfo.go
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,6 @@ import (
"bytes"
"encoding/json"
"fmt"
"io/ioutil"
"os"
"strings"
"time"
Expand All @@ -25,14 +24,16 @@ import (
"github.com/lf-edge/eve/pkg/pillar/netclone"
"github.com/lf-edge/eve/pkg/pillar/types"
"github.com/lf-edge/eve/pkg/pillar/utils"
fileutils "github.com/lf-edge/eve/pkg/pillar/utils/file"
"github.com/lf-edge/eve/pkg/pillar/vault"
"github.com/lf-edge/eve/pkg/pillar/zedcloud"
"github.com/shirou/gopsutil/host"
)

var (
nilIPInfo = ipinfo.IPInfo{}
smartData = types.NewSmartDataWithDefaults()
nilIPInfo = ipinfo.IPInfo{}
smartData = types.NewSmartDataWithDefaults()
maxSmartCtlSize = 65536 // Limit size of smartctl output files
)

func deviceInfoTask(ctxPtr *zedagentContext, triggerDeviceInfo <-chan struct{}) {
Expand Down Expand Up @@ -926,7 +927,8 @@ func createAppInstances(ctxPtr *zedagentContext,

func parseSMARTData() {
filename := "/persist/SMART_details.json"
data, err := ioutil.ReadFile(filename)
data, err := fileutils.ReadWithMaxSize(log, filename,
maxSmartCtlSize)
if err != nil {
log.Errorf("parseSMARTData: exception while opening %s. %s", filename, err.Error())
return
Expand Down

0 comments on commit 6dd783a

Please sign in to comment.