Skip to content

Commit 31a4a62

Browse files
Merge remote-tracking branch 'origin/develop' into feat/logs
2 parents fc0af47 + dae5ba9 commit 31a4a62

23 files changed

+1150
-136
lines changed

Dockerfile

+1-1
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ WORKDIR /app
33
COPY . ./
44
RUN apk update && apk add gcc musl-dev
55
ARG VERSION
6-
RUN CGO_ENABLED=0 GOOS=linux go build -ldflags="-X 'github.com/ddosify/alaz/datastore.tag=$VERSION'" -o alaz
6+
RUN GOOS=linux go build -ldflags="-X 'github.com/ddosify/alaz/datastore.tag=$VERSION'" -o alaz
77

88
FROM registry.access.redhat.com/ubi9/ubi-minimal:9.3-1552
99
RUN microdnf update -y && microdnf install procps ca-certificates -y && microdnf clean all

Dockerfile.default

+6-5
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,13 @@
1-
FROM golang:1.20-alpine as builder
1+
FROM golang:1.20.14-bullseye as builder
22
WORKDIR /app
33
COPY . ./
4-
RUN apk update && apk add gcc musl-dev
4+
RUN apt update
5+
56
ARG VERSION
6-
RUN CGO_ENABLED=0 GOOS=linux go build -ldflags="-X 'github.com/ddosify/alaz/datastore.tag=$VERSION'" -o alaz
7+
RUN GOOS=linux go build -ldflags="-X 'github.com/ddosify/alaz/datastore.tag=$VERSION'" -o alaz
78

8-
FROM alpine:3.18.3
9-
RUN apk --no-cache add ca-certificates
9+
FROM debian:12.5-slim
10+
RUN apt-get update && apt-get install -y procps ca-certificates && rm -rf /var/lib/apt/lists/*
1011

1112
COPY --chown=0:0 --from=builder /app/alaz ./bin/
1213
ENTRYPOINT ["alaz"]

README.md

+2-2
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@
1313
</p>
1414

1515
<h2 align="center">
16-
<a href="https://demo.ddosify.com/" target="_blank">Live Demo</a> •
16+
<a href="https://demo.ddosify.com/clusters/0ce2ef05-ef64-459d-90d9-7f2cbd65fff8" target="_blank">Live Demo</a> •
1717
<a href="https://docs.ddosify.com/" target="_blank">Documentation</a> •
1818
<a href="https://docs.ddosify.com/ddosify/deployment" target="_blank">Deployment</a> •
1919
<a href="https://docs.ddosify.com/ddosify/deployment" target="_blank">Discord</a>
@@ -119,7 +119,7 @@ MONITORING_ID=XXXXX
119119
BACKEND_HOST=XXXXX
120120
curl -sSL https://raw.githubusercontent.com/ddosify/alaz/master/resources/alaz.yaml -o alaz.yaml
121121
sed -i"" -e "s/<MONITORING_ID>/$MONITORING_ID/g" alaz.yaml
122-
sed -i"" -e "s/https:\/\/api.ddosify.com:443/http:\/\/$BACKEND_HOST\/api/g" alaz.yaml
122+
sed -i"" -e "s/https:\/\/api-alaz.ddosify.com:443/http:\/\/$BACKEND_HOST\/api/g" alaz.yaml
123123
kubectl create namespace ddosify
124124
kubectl apply -f alaz.yaml
125125
```

aggregator/data.go

+17-10
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,7 @@ import (
2222
"strconv"
2323
"strings"
2424
"sync"
25+
"sync/atomic"
2526
"syscall"
2627

2728
"golang.org/x/time/rate"
@@ -79,7 +80,7 @@ type Aggregator struct {
7980
rateLimitMu sync.RWMutex
8081

8182
// Used to find the correct mutex for the pid, some pids can share the same mutex
82-
muIndex int
83+
muIndex atomic.Uint64
8384
muArray []*sync.RWMutex
8485
}
8586

@@ -185,7 +186,7 @@ func NewAggregator(parentCtx context.Context, k8sChan <-chan interface{},
185186
liveProcesses: make(map[uint32]struct{}),
186187
rateLimiters: make(map[uint32]*rate.Limiter),
187188
pgStmts: make(map[string]string),
188-
muIndex: 0,
189+
muIndex: atomic.Uint64{},
189190
muArray: nil,
190191
}
191192

@@ -227,11 +228,10 @@ func NewAggregator(parentCtx context.Context, k8sChan <-chan interface{},
227228
a.muArray = make([]*sync.RWMutex, countMuArray)
228229

229230
// set distinct mutex for every live process
230-
a.muIndex = 0
231231
for pid := range a.liveProcesses {
232-
a.muArray[a.muIndex] = &sync.RWMutex{}
233-
sockMaps[pid].mu = a.muArray[a.muIndex]
234-
a.muIndex++
232+
a.muArray[a.muIndex.Load()] = &sync.RWMutex{}
233+
sockMaps[pid].mu = a.muArray[a.muIndex.Load()]
234+
a.muIndex.Add(1)
235235
a.getAlreadyExistingSockets(pid)
236236
}
237237

@@ -456,9 +456,16 @@ func (a *Aggregator) processExec(d *proc.ProcEvent) {
456456
a.liveProcesses[d.Pid] = struct{}{}
457457

458458
// create lock on demand
459-
a.muArray[a.muIndex%len(a.muArray)] = &sync.RWMutex{}
460-
a.muIndex++
461-
a.clusterInfo.SocketMaps[d.Pid].mu = a.muArray[a.muIndex%len(a.muArray)]
459+
a.muArray[(a.muIndex.Load())%uint64(len(a.muArray))] = &sync.RWMutex{}
460+
a.muIndex.Add(1)
461+
462+
// if duplicate exec event comes, underlying mutex will be changed
463+
// if first assigned mutex is locked and another exec event comes, mutex will be changed
464+
// and unlock of unlocked mutex now is a possibility
465+
// to avoid this case, if a socket map already has a mutex, don't change it
466+
if a.clusterInfo.SocketMaps[d.Pid].mu == nil {
467+
a.clusterInfo.SocketMaps[d.Pid].mu = a.muArray[(a.muIndex.Load())%uint64(len(a.muArray))]
468+
}
462469
}
463470

464471
func (a *Aggregator) processExit(pid uint32) {
@@ -1325,7 +1332,7 @@ func (a *Aggregator) parseSqlCommand(d *l7_req.L7Event) (string, error) {
13251332
a.pgStmtsMu.RLock()
13261333
query, ok := a.pgStmts[a.getPgStmtKey(d.Pid, d.Fd, stmtName)]
13271334
a.pgStmtsMu.RUnlock()
1328-
if !ok { // we don't have the query for the prepared statement
1335+
if !ok || query == "" { // we don't have the query for the prepared statement
13291336
// Execute (name of prepared statement) [(parameter)]
13301337
return fmt.Sprintf("EXECUTE %s *values*", stmtName), nil
13311338
}

config/db.go

+1
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@ type PostgresConfig struct {
1111
type BackendDSConfig struct {
1212
Host string
1313
MetricsExport bool
14+
GpuMetricsExport bool
1415
MetricsExportInterval int // in seconds
1516

1617
ReqBufferSize int

0 commit comments

Comments
 (0)