Skip to content
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
16 changes: 16 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,22 @@ log is based on the [Keep a CHANGELOG](http://keepachangelog.com/) project.

## Unreleased

## [0.18.1]

## Added

- Add static binary build [#160](https://github.com/Comcast/fishymetrics/pull/160)

## Updated

- Bump github.com/containerd/containerd from 1.7.27 to 1.7.29 [#156](https://github.com/Comcast/fishymetrics/pull/156)
- Bump golang.org/x/crypto from 0.36.0 to 0.45.0 [#158](https://github.com/Comcast/fishymetrics/pull/158)

## Fixed

- Storage drives not included in scrapes when collector.drives.modules-exclude flag is not passed [#157](https://github.com/Comcast/fishymetrics/issues/157)
- Credential rotation not happening after fetching secrets from vault [#161](https://github.com/Comcast/fishymetrics/issues/161)

## [0.18.0]

## Added
Expand Down
14 changes: 7 additions & 7 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -12,13 +12,13 @@ build:
" -v -o build/usr/bin/fishymetrics $(shell pwd)/cmd/fishymetrics

static:
@mkdir -p build/usr/bin
CGO_ENABLED=0 go build -a -ldflags "\
-extldflags '-static' \
-X \"github.com/comcast/fishymetrics/buildinfo.gitVersion=${REPO_VERSION}\" \
-X \"github.com/comcast/fishymetrics/buildinfo.gitRevision=${REPO_REV}\" \
-X \"github.com/comcast/fishymetrics/buildinfo.date=${BUILD_DATE}\" \
" -v -o build/usr/bin/fishymetrics $(shell pwd)/cmd/fishymetrics
@mkdir -p build/usr/bin
CGO_ENABLED=0 go build -a -ldflags "\
-extldflags '-static' \
-X \"github.com/comcast/fishymetrics/buildinfo.gitVersion=${REPO_VERSION}\" \
-X \"github.com/comcast/fishymetrics/buildinfo.gitRevision=${REPO_REV}\" \
-X \"github.com/comcast/fishymetrics/buildinfo.date=${BUILD_DATE}\" \
" -v -o build/usr/bin/fishymetrics $(shell pwd)/cmd/fishymetrics

docker:
docker build \
Expand Down
10 changes: 9 additions & 1 deletion common/util.go
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,11 @@ func Fetch(uri, host, profile string, client *retryablehttp.Client) func() ([]by
}
} else if resp.StatusCode == http.StatusUnauthorized {
if ChassisCreds.Vault != nil {
// Credentials may have rotated, go to vault and get the latest
// Credentials may have rotated, clear cache, go to vault and get the latest
ChassisCreds.mu.Lock()
delete(ChassisCreds.Creds, host)
ChassisCreds.mu.Unlock()

credential, err := ChassisCreds.GetCredentials(context.Background(), profile, host)
if err != nil {
return nil, fmt.Errorf("issue retrieving credentials from vault using target: %s", host)
Expand All @@ -86,6 +90,10 @@ func Fetch(uri, host, profile string, client *retryablehttp.Client) func() ([]by
}

time.Sleep(client.RetryWaitMin)

// Properly close the previous response before making the retry request
EmptyAndCloseBody(resp)

resp, err = DoRequest(client, req)
if err != nil {
return nil, fmt.Errorf("retry DoRequest failed - %v", err)
Expand Down
2 changes: 1 addition & 1 deletion exporter/exporter_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@ const (
GoodDiskDriveExpected = `
# HELP redfish_disk_drive_status Current Disk Drive status 1 = OK, 0 = BAD, -1 = DISABLED
# TYPE redfish_disk_drive_status gauge
redfish_disk_drive_status{capacityMiB="915715",chassisModel="model a",chassisSerialNumber="SN98765",failurePredicted="",id="0",location="1I:1:1",name="HpeSmartStorageDiskDrive",serialnumber="ABC123"} 1
redfish_disk_drive_status{capacityMiB="915715",chassisModel="model a",chassisSerialNumber="SN98765",failurePredicted="false",id="0",location="1I:1:1",name="HpeSmartStorageDiskDrive",serialnumber="ABC123"} 1
`
GoodNvmeDriveExpected = `
# HELP redfish_nvme_drive_status Current NVME status 1 = OK, 0 = BAD, -1 = DISABLED
Expand Down
32 changes: 12 additions & 20 deletions exporter/handlers.go
Original file line number Diff line number Diff line change
Expand Up @@ -347,20 +347,16 @@ func (e *Exporter) exportPhysicalDriveMetrics(body []byte) error {

if dlphysical.CapacityMiB != 0 {
cap = dlphysical.CapacityMiB
} else if dlphysical.CapacityBytes != 0 {
} else if dlphysical.CapacityBytes.Value != 0 {
// convert to MiB
cap = ((dlphysical.CapacityBytes / 1024) / 1024)
cap = ((dlphysical.CapacityBytes.Value / 1024) / 1024)
}

// if FailurePredicted is present in response, set the result, else set to empty string
if dlphysical.FailurePredicted != nil {
if *dlphysical.FailurePredicted {
failpredict = "true"
} else {
failpredict = "false"
}
if dlphysical.FailurePredicted.Value {
failpredict = "true"
} else {
failpredict = ""
failpredict = "false"
}

// Physical drives need to have a unique identifier like location so as to not overwrite data
Expand Down Expand Up @@ -408,9 +404,9 @@ func (e *Exporter) exportLogicalDriveMetrics(body []byte) error {
// Calculate capacity in MiB
if dllogical.CapacityMiB > 0 {
capacityMiB = dllogical.CapacityMiB
} else if dllogical.CapacityBytes > 0 {
} else if dllogical.CapacityBytes.Value > 0 {
// Convert bytes to MiB (1 MiB = 1048576 bytes)
capacityMiB = dllogical.CapacityBytes / 1048576
capacityMiB = dllogical.CapacityBytes.Value / 1048576
}

(*dllogicaldrive)["raidStatus"].WithLabelValues(strings.TrimRight(dllogical.Name, " "), e.ChassisSerialNumber, e.Model, strings.TrimRight(ldName, " "), volIdentifier, raidType, strconv.Itoa(capacityMiB)).Set(state)
Expand Down Expand Up @@ -440,20 +436,16 @@ func (e *Exporter) exportNVMeDriveMetrics(body []byte) error {
state = DISABLED
}

if dlnvme.CapacityBytes != 0 {
if dlnvme.CapacityBytes.Value != 0 {
// convert to MiB
cap = ((dlnvme.CapacityBytes / 1024) / 1024)
cap = ((dlnvme.CapacityBytes.Value / 1024) / 1024)
}

// if FailurePredicted is present in response, set the result, else set to empty string
if dlnvme.FailurePredicted != nil {
if *dlnvme.FailurePredicted {
failpredict = "true"
} else {
failpredict = "false"
}
if dlnvme.FailurePredicted.Value {
failpredict = "true"
} else {
failpredict = ""
failpredict = "false"
}

(*dlnvmedrive)["nvmeDriveStatus"].WithLabelValues(e.ChassisSerialNumber, e.Model, dlnvme.Protocol, dlnvme.ID, dlnvme.PhysicalLocation.PartLocation.ServiceLabel, dlnvme.SerialNumber, strconv.Itoa(cap), failpredict).Set(state)
Expand Down
Loading