Skip to content

Commit

Permalink
remove escape stripping
Browse files Browse the repository at this point in the history
  • Loading branch information
c-g-b committed Oct 24, 2023
1 parent c1c4d1e commit 4ff25cd
Show file tree
Hide file tree
Showing 2 changed files with 2 additions and 11 deletions.
11 changes: 1 addition & 10 deletions internal/collector/recon/utils.go
Original file line number Diff line number Diff line change
Expand Up @@ -97,25 +97,16 @@ func splitOutputPerHost(output []byte, cmdArgs []string) (map[string][]byte, err
data = bytes.ReplaceAll(data, []byte(`False`), []byte(`false`))
data = bytes.ReplaceAll(data, []byte(`None`), []byte(`"None"`))
data = bytes.ReplaceAll(data, []byte(`""None""`), []byte(`"None"`))
data = bytes.ReplaceAll(data, []byte(`\x`), []byte(`\\x`))
//^ We sometimes observe strings with the value "None".
//The None -> "None" replacement introduces double quoting there which we need to compensate for.

//In the event that object store issues add escape characters to swift-recon output, strip these chracters to continue.
data = []byte(stripEscapeChars(string(data)))

result[hostname] = data
}

return result, nil
}

func stripEscapeChars(s string) string {
re := regexp.MustCompile(`(?:(\\\w\d\d))*`)
return re.ReplaceAllStringFunc(s, func(s string) string {
return ``
})
}

func getSwiftReconOutputPerHost(ctxTimeout time.Duration, pathToExecutable string, cmdArgs ...string) (map[string][]byte, error) {
out, err := util.RunCommandWithTimeout(ctxTimeout, pathToExecutable, cmdArgs...)
if err != nil {
Expand Down
2 changes: 1 addition & 1 deletion test/fixtures/successful_collect.prom
Original file line number Diff line number Diff line change
Expand Up @@ -105,6 +105,7 @@ swift_cluster_containers_sharding_candidates_object_count{account=".shards_AUTH_
swift_cluster_containers_sharding_candidates_object_count{account=".shards_AUTH_ACCOUNT",container="container-sharding-1697704617.79400-0",storage_ip="10.0.0.6"} 1.496509e+06
swift_cluster_containers_sharding_candidates_object_count{account=".shards_AUTH_ACCOUNT",container="sharding-1695830239.64849-2",storage_ip="10.0.0.1"} 1.448062e+06
swift_cluster_containers_sharding_candidates_object_count{account=".shards_AUTH_ACCOUNT",container="sharding-c4f60a871b95e04ff96bb2cbbf1f96e6-1695830239.64849-3",storage_ip="10.0.0.5"} 1.681328e+06
swift_cluster_containers_sharding_candidates_object_count{account="AUTH_ACCOUNT",container="\\x00versions\\x00sharding",storage_ip="10.0.0.5"} 2.828027e+06
swift_cluster_containers_sharding_candidates_object_count{account="AUTH_ACCOUNT",container="atd-container1",storage_ip="10.0.0.2"} 1.00765e+06
swift_cluster_containers_sharding_candidates_object_count{account="AUTH_ACCOUNT",container="container-sharding",storage_ip="10.0.0.1"} 2.828027e+06
swift_cluster_containers_sharding_candidates_object_count{account="AUTH_ACCOUNT",container="container-sharding",storage_ip="10.0.0.2"} 1.983069e+06
Expand All @@ -116,7 +117,6 @@ swift_cluster_containers_sharding_candidates_object_count{account="AUTH_ACCOUNT"
swift_cluster_containers_sharding_candidates_object_count{account="AUTH_ACCOUNT",container="repo",storage_ip="10.0.0.4"} 1.088685e+06
swift_cluster_containers_sharding_candidates_object_count{account="AUTH_ACCOUNT",container="repo",storage_ip="10.0.0.6"} 1.088685e+06
swift_cluster_containers_sharding_candidates_object_count{account="AUTH_ACCOUNT",container="sharding3",storage_ip="10.0.0.1"} 2.818948e+06
swift_cluster_containers_sharding_candidates_object_count{account="AUTH_ACCOUNT",container="versionssharding",storage_ip="10.0.0.5"} 2.828027e+06
# HELP swift_cluster_containers_sharding_cleaved_attempted Container shard cleaved number attempted reported by the swift-recon tool.
# TYPE swift_cluster_containers_sharding_cleaved_attempted gauge
swift_cluster_containers_sharding_cleaved_attempted{storage_ip="10.0.0.1"} 0
Expand Down

0 comments on commit 4ff25cd

Please sign in to comment.