Skip to content

Commit

Permalink
Merge pull request #199 from aerospike/v7.2.0
Browse files Browse the repository at this point in the history
V7.2.0
  • Loading branch information
robertglonek authored Nov 6, 2023
2 parents 6b05515 + 8749de5 commit 6cbaa7f
Show file tree
Hide file tree
Showing 15 changed files with 132 additions and 18 deletions.
2 changes: 1 addition & 1 deletion expiries/gcp/function.go
Original file line number Diff line number Diff line change
Expand Up @@ -95,7 +95,7 @@ func aerolabExpireDo() error {
}
instances := pair.Value.Instances
for _, instance := range instances {
if strings.ToUpper(*instance.Status) == "STOPPING" || strings.ToUpper(*instance.Status) == "TERMINATED" {
if strings.ToUpper(*instance.Status) != "RUNNING" && strings.ToUpper(*instance.Status) != "TERMINATED" && strings.ToUpper(*instance.Status) != "SUSPENDED" {
continue
}
expire, ok := instance.Labels["aerolab4expires"]
Expand Down
3 changes: 2 additions & 1 deletion src/go.mod
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
module github.com/aerospike/aerolab

go 1.21
go 1.21.3

require (
cloud.google.com/go/compute v1.23.2
Expand All @@ -24,6 +24,7 @@ require (
github.com/rglonek/aerospike-config-file-parser v1.0.3
github.com/rglonek/envconfig v0.0.0-20230911195903-c4c689bf1744
github.com/rglonek/jeddevdk-goflags v2.0.0+incompatible
github.com/rglonek/sbs v1.0.0
golang.org/x/crypto v0.14.0
golang.org/x/sys v0.13.0
golang.org/x/term v0.13.0
Expand Down
2 changes: 2 additions & 0 deletions src/go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -142,6 +142,8 @@ github.com/rglonek/envconfig v0.0.0-20230911195903-c4c689bf1744 h1:HyBW093bA2fLY
github.com/rglonek/envconfig v0.0.0-20230911195903-c4c689bf1744/go.mod h1:CS128EIeoFCR4HBOwZDqzicTdDDcwzAWSqPUof2r8vI=
github.com/rglonek/jeddevdk-goflags v2.0.0+incompatible h1:YetOOw5mSL6xmwbF5GMcmvMbpthp03tmGLx3U/ke/YA=
github.com/rglonek/jeddevdk-goflags v2.0.0+incompatible/go.mod h1:yWO03+fWZps+sVPozmNXFoq1v+V3xIGOd8m2WU9Vm70=
github.com/rglonek/sbs v1.0.0 h1:CU15j5+gcBE6Oee0P7ldp7WHBVvUszNy83tPX8v92Lk=
github.com/rglonek/sbs v1.0.0/go.mod h1:abz3p7k2s1/vpiP6QOrOoKapqTzc8e9h+Ofza0aKDhU=
github.com/rivo/uniseg v0.2.0/go.mod h1:J6wj4VEh+S6ZtnVlnTBMWIodfgj8LQOQFoIToxlJtxc=
github.com/rivo/uniseg v0.4.4 h1:8TfxU8dW6PdqD27gjM8MVNuicgxIjxpm4K7x4jp8sis=
github.com/rivo/uniseg v0.4.4/go.mod h1:FN3SvrM+Zdj16jyLfmOkMNblXMcoc8DfTHruCPUcx88=
Expand Down
3 changes: 2 additions & 1 deletion src/ingest/compression.go
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ import (
"strings"

"github.com/gabriel-vasile/mimetype"
"github.com/rglonek/sbs"

"github.com/nwaples/rardecode"
)
Expand Down Expand Up @@ -161,7 +162,7 @@ func un7z(src string, dst string) error {
}
out, err := exec.Command("7z", "x", "-aou", "-y", fmt.Sprintf("-o%s", dst), src).CombinedOutput()
if err != nil {
return fmt.Errorf("err:%s .. out:%s", err, string(out))
return fmt.Errorf("err:%s .. out:%s", err, sbs.ByteSliceToString(out))
}
return nil
}
Expand Down
3 changes: 2 additions & 1 deletion src/ingest/preprocess-special.go
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ import (

"github.com/bestmethod/logger"
"github.com/gabriel-vasile/mimetype"
"github.com/rglonek/sbs"
)

// {"JsonPayload":{"Log": "full line..."}}
Expand All @@ -34,7 +35,7 @@ func (i *Ingest) preProcessSpecial(fn string, mimeType *mimetype.MIME) (fnlist [
}
fh.Seek(0, 0)
// test for tab formats
line := strings.Split(string(b), "\n")[0]
line := strings.Split(sbs.ByteSliceToString(b), "\n")[0]
tabsplit := strings.Split(line, "\t")
if len(tabsplit) == 4 {
logger.Debug("PreProcess-special: %s is tab-4", fn)
Expand Down
5 changes: 3 additions & 2 deletions src/ingest/processlogs.go
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ import (
"github.com/aerospike/aerospike-client-go/v6"
"github.com/bestmethod/inslice"
"github.com/bestmethod/logger"
"github.com/rglonek/sbs"
)

type metaEntries struct {
Expand Down Expand Up @@ -85,7 +86,7 @@ func (i *Ingest) ProcessLogs() error {
}
for k, v := range rec.Record.Bins {
metaItem := &metaEntries{}
err = json.Unmarshal([]byte(v.(string)), &metaItem)
err = json.Unmarshal(sbs.StringToByteSlice(v.(string)), &metaItem)
if err != nil {
logger.Warn("Failed to unmarshal existing label data: %s", err)
}
Expand Down Expand Up @@ -150,7 +151,7 @@ func (i *Ingest) ProcessLogs() error {
<-threads
return
}
bin := aerospike.NewBin(k, string(metajson))
bin := aerospike.NewBin(k, sbs.ByteSliceToString(metajson))
aerr = i.db.PutBins(i.wp, key, bin)
if aerr != nil {
metaLock.Unlock()
Expand Down
3 changes: 2 additions & 1 deletion src/plugin/backendQueryAndCache.go
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ import (

"github.com/bestmethod/inslice"
"github.com/bestmethod/logger"
"github.com/rglonek/sbs"
)

func (p *Plugin) queryAndCache() {
Expand Down Expand Up @@ -98,7 +99,7 @@ func (p *Plugin) cacheMetadataList() error {
}
for k, v := range rec.Record.Bins {
metaItem := &metaEntries{}
nerr := json.Unmarshal([]byte(v.(string)), &metaItem)
nerr := json.Unmarshal(sbs.StringToByteSlice(v.(string)), &metaItem)
if nerr != nil {
logger.Warn("Failed to unmarshal existing label data for %s: %s", k, nerr)
}
Expand Down
5 changes: 3 additions & 2 deletions src/plugin/frontendMetrics.go
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ import (
"net/http"

"github.com/bestmethod/logger"
"github.com/rglonek/sbs"
)

type metricQuery struct {
Expand All @@ -29,7 +30,7 @@ func (p *Plugin) handleMetrics(w http.ResponseWriter, r *http.Request) {
responseError(w, http.StatusBadRequest, "Failed to read body (remote:%s) (error:%s)", r.RemoteAddr, err)
return
}
logger.Detail("(remote:%s) (payload:%s)", r.RemoteAddr, string(body))
logger.Detail("(remote:%s) (payload:%s)", r.RemoteAddr, sbs.ByteSliceToString(body))
query := new(metricQuery)
err = json.Unmarshal(body, query)
if err != nil {
Expand All @@ -53,5 +54,5 @@ func (p *Plugin) handleMetrics(w http.ResponseWriter, r *http.Request) {
func responseError(w http.ResponseWriter, httpStatus int, message string, tail ...interface{}) {
logger.Warn(message, tail...)
w.WriteHeader(httpStatus)
w.Write([]byte(fmt.Sprintf(message, tail...)))
w.Write(sbs.StringToByteSlice(fmt.Sprintf(message, tail...)))
}
5 changes: 3 additions & 2 deletions src/plugin/frontendQuery.go
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ import (

"github.com/aerospike/aerospike-client-go/v6"
"github.com/bestmethod/logger"
"github.com/rglonek/sbs"
)

func isSocketTimeout(ctx context.Context) bool {
Expand Down Expand Up @@ -57,7 +58,7 @@ func (p *Plugin) handleQuery(w http.ResponseWriter, r *http.Request) {
responseError(w, http.StatusBadRequest, "Failed to read body (remote:%s) (error:%s)", r.RemoteAddr, err)
return
}
logger.Detail("(remote:%s) (payload:%s)", r.RemoteAddr, string(body))
logger.Detail("(remote:%s) (payload:%s)", r.RemoteAddr, sbs.ByteSliceToString(body))
req := new(queryRequest)
err = json.Unmarshal(body, req)
if err != nil {
Expand Down Expand Up @@ -105,7 +106,7 @@ func (p *Plugin) handleQuery(w http.ResponseWriter, r *http.Request) {
responseError(w, http.StatusBadRequest, "Failed to marshal body json of scoped vars for detail logging (remote:%s) (error:%s)", r.RemoteAddr, err)
return
}
logger.Detail("(remote:%s) (parsed-payload:%s) (selected-vars:%s)", r.RemoteAddr, string(body), string(bodyx))
logger.Detail("(remote:%s) (parsed-payload:%s) (selected-vars:%s)", r.RemoteAddr, sbs.ByteSliceToString(body), sbs.ByteSliceToString(bodyx))
}
logger.Info("QUERY ALLOCATE_JOB (type:query) (runningJobs:%d) (remote:%s)", len(p.jobs), r.RemoteAddr)
jtime := time.Now()
Expand Down
9 changes: 5 additions & 4 deletions src/plugin/frontendVariable.go
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ import (

"github.com/bestmethod/inslice"
"github.com/bestmethod/logger"
"github.com/rglonek/sbs"
)

type variableQuery struct {
Expand All @@ -36,7 +37,7 @@ func (p *Plugin) handleVariable(w http.ResponseWriter, r *http.Request) {
responseError(w, http.StatusBadRequest, "Failed to read body (remote:%s) (error:%s)", r.RemoteAddr, err)
return
}
logger.Detail("(remote:%s) (payload:%s)", r.RemoteAddr, string(body))
logger.Detail("(remote:%s) (payload:%s)", r.RemoteAddr, sbs.ByteSliceToString(body))
query := new(variableQuery)
err = json.Unmarshal(body, query)
if err != nil {
Expand All @@ -57,8 +58,8 @@ func (p *Plugin) handleVariable(w http.ResponseWriter, r *http.Request) {
w.Header().Set("Content-Type", "application/json")
w.WriteHeader(200)
json.NewEncoder(w).Encode([]*variableResponse{{
Text: string(fc),
Value: string(fc),
Text: sbs.ByteSliceToString(fc),
Value: sbs.ByteSliceToString(fc),
}})
return
}
Expand All @@ -68,7 +69,7 @@ func (p *Plugin) handleVariable(w http.ResponseWriter, r *http.Request) {
clusterNames := []string{}
if len(q) > 1 {
cn := strings.Join(q[1:], "@")
err = json.Unmarshal([]byte(cn), &clusterNames)
err = json.Unmarshal(sbs.StringToByteSlice(cn), &clusterNames)
if err != nil {
responseError(w, http.StatusBadRequest, "Failed to unmarshal json request cluster names (remote:%s) (error:%s)", r.RemoteAddr, err)
p.cache.lock.RUnlock()
Expand Down
7 changes: 4 additions & 3 deletions src/plugin/queryTimeseries.go
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ import (
"github.com/aerospike/aerospike-client-go/v6"
"github.com/bestmethod/inslice"
"github.com/bestmethod/logger"
"github.com/rglonek/sbs"
)

type timeseriesResponse struct {
Expand Down Expand Up @@ -272,17 +273,17 @@ func (p *Plugin) handleQueryTimeseries(req *queryRequest, i int, remote string,
dpGroups := make([]string, 0, len(dp.groups)+1)
if p.config.TimeseriesDisplayNameFirst && k != "" {
dpGroups = append(dpGroups, k)
groupHash.Write([]byte(k))
groupHash.Write(sbs.StringToByteSlice(k))
}
for _, g := range dp.groups {
if g.value != "" {
dpGroups = append(dpGroups, g.value)
groupHash.Write([]byte(g.value))
groupHash.Write(sbs.StringToByteSlice(g.value))
}
}
if !p.config.TimeseriesDisplayNameFirst && k != "" {
dpGroups = append(dpGroups, k)
groupHash.Write([]byte(k))
groupHash.Write(sbs.StringToByteSlice(k))
}
grHash := groupHash.Sum(nil)
found := -1
Expand Down
28 changes: 28 additions & 0 deletions src/vendor/github.com/rglonek/sbs/LICENSE

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

48 changes: 48 additions & 0 deletions src/vendor/github.com/rglonek/sbs/README.md

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

24 changes: 24 additions & 0 deletions src/vendor/github.com/rglonek/sbs/sbs.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

3 changes: 3 additions & 0 deletions src/vendor/modules.txt
Original file line number Diff line number Diff line change
Expand Up @@ -219,6 +219,9 @@ github.com/rglonek/envconfig
# github.com/rglonek/jeddevdk-goflags v2.0.0+incompatible
## explicit
github.com/rglonek/jeddevdk-goflags
# github.com/rglonek/sbs v1.0.0
## explicit; go 1.21.3
github.com/rglonek/sbs
# github.com/rivo/uniseg v0.4.4
## explicit; go 1.18
github.com/rivo/uniseg
Expand Down

0 comments on commit 6cbaa7f

Please sign in to comment.