refactor: enhance bird metrics polling with context support
CI / changes (push) Successful in 8s
CI / openapi (push) Has been skipped
CI / go (push) Successful in 40s
CI / docker-web (deploy/docker/evobgp-web/Dockerfile, , evobgp-web) (push) Has been skipped
CI / docker-web (deploy/docker/evobgp-web/Dockerfile, evobgp-all, evobgp-web-all) (push) Has been skipped
CI / docker-bird (push) Has been skipped
CI / bird2 (push) Successful in 15s
CI / docker-go-prime (push) Successful in 24s
CI / docker-go (deploy/docker/evobgp-agent/Dockerfile, , evobgp-agent) (push) Successful in 59s
CI / docker-go (evobgp-all, 1, deploy/docker/gobinary/Dockerfile, , evobgp-all) (push) Successful in 2m18s
CI / docker-go (evobgp-api, 1, deploy/docker/gobinary/Dockerfile, , evobgp-api) (push) Successful in 1m23s
CI / docker-go (evobgp-deploy, 0, deploy/docker/gobinary/Dockerfile, , evobgp-deploy) (push) Successful in 1m20s
CI / docker-go (evobgp-ingest, 0, deploy/docker/gobinary/Dockerfile, , evobgp-ingest) (push) Successful in 1m24s
CI / docker-go (evobgp-node, 0, deploy/docker/gobinary/Dockerfile, , evobgp-node) (push) Successful in 1m9s
CI / docker-go (evobgp-render, 0, deploy/docker/gobinary/Dockerfile, , evobgp-render) (push) Successful in 1m22s
CI / docker-go (evobgp-scheduler, 0, deploy/docker/gobinary/Dockerfile, , evobgp-scheduler) (push) Successful in 1m24s
CI / changes (push) Successful in 8s
CI / openapi (push) Has been skipped
CI / go (push) Successful in 40s
CI / docker-web (deploy/docker/evobgp-web/Dockerfile, , evobgp-web) (push) Has been skipped
CI / docker-web (deploy/docker/evobgp-web/Dockerfile, evobgp-all, evobgp-web-all) (push) Has been skipped
CI / docker-bird (push) Has been skipped
CI / bird2 (push) Successful in 15s
CI / docker-go-prime (push) Successful in 24s
CI / docker-go (deploy/docker/evobgp-agent/Dockerfile, , evobgp-agent) (push) Successful in 59s
CI / docker-go (evobgp-all, 1, deploy/docker/gobinary/Dockerfile, , evobgp-all) (push) Successful in 2m18s
CI / docker-go (evobgp-api, 1, deploy/docker/gobinary/Dockerfile, , evobgp-api) (push) Successful in 1m23s
CI / docker-go (evobgp-deploy, 0, deploy/docker/gobinary/Dockerfile, , evobgp-deploy) (push) Successful in 1m20s
CI / docker-go (evobgp-ingest, 0, deploy/docker/gobinary/Dockerfile, , evobgp-ingest) (push) Successful in 1m24s
CI / docker-go (evobgp-node, 0, deploy/docker/gobinary/Dockerfile, , evobgp-node) (push) Successful in 1m9s
CI / docker-go (evobgp-render, 0, deploy/docker/gobinary/Dockerfile, , evobgp-render) (push) Successful in 1m22s
CI / docker-go (evobgp-scheduler, 0, deploy/docker/gobinary/Dockerfile, , evobgp-scheduler) (push) Successful in 1m24s
Updated the `startBirdMetricsPoller` function to accept a context parameter, allowing for better control over the polling lifecycle. This change was applied in both `evobgp-all` and `evobgp-api` main files. Additionally, modified the `StartBirdProtocolsPoller` function to handle context cancellation, ensuring graceful shutdown of the polling routine. Introduced a new service in the Docker Compose configuration for logging runtime service outputs, improving observability during deployment.
This commit is contained in:
+37
-37
@@ -158,8 +158,8 @@ func (w *Worker) finishModuleRefreshSuccess(j *Job, rev string) {
|
||||
deferDeploy := w.Registry.CountOtherActiveModuleRefresh(j.TenantID, j.ID) > 0
|
||||
if deferDeploy {
|
||||
j.mergeMeta(map[string]any{
|
||||
"deploy_apply_deferred": true,
|
||||
"deploy_apply_defer_reason": "parallel_module_refresh",
|
||||
"deploy_apply_deferred": true,
|
||||
"deploy_apply_defer_reason": "parallel_module_refresh",
|
||||
})
|
||||
}
|
||||
j.Succeed()
|
||||
@@ -324,19 +324,6 @@ func (w *Worker) buildRevisionLogEntries(tenantID, revID string) ([]map[string]a
|
||||
return nil, 0, fmt.Errorf("store not configured")
|
||||
}
|
||||
commLabels := buildCommunityLabelMap(w.Store, tenantID)
|
||||
var all []store.PrefixRow
|
||||
cursor := ""
|
||||
for {
|
||||
rows, next, more := w.Store.ListRevisionPrefixes(tenantID, revID, cursor, 1000)
|
||||
all = append(all, rows...)
|
||||
if !more {
|
||||
break
|
||||
}
|
||||
cursor = next
|
||||
if strings.TrimSpace(cursor) == "" {
|
||||
break
|
||||
}
|
||||
}
|
||||
type agg struct {
|
||||
kind string
|
||||
source string
|
||||
@@ -345,22 +332,35 @@ func (w *Worker) buildRevisionLogEntries(tenantID, revID string) ([]map[string]a
|
||||
sample []string
|
||||
}
|
||||
groups := map[string]*agg{}
|
||||
for _, p := range all {
|
||||
src := strings.TrimSpace(p.Source)
|
||||
comm := "none"
|
||||
if p.CommunityID != nil && strings.TrimSpace(*p.CommunityID) != "" {
|
||||
comm = strings.TrimSpace(*p.CommunityID)
|
||||
total := 0
|
||||
cursor := ""
|
||||
for {
|
||||
rows, next, more := w.Store.ListRevisionPrefixes(tenantID, revID, cursor, 1000)
|
||||
for _, p := range rows {
|
||||
total++
|
||||
src := strings.TrimSpace(p.Source)
|
||||
comm := "none"
|
||||
if p.CommunityID != nil && strings.TrimSpace(*p.CommunityID) != "" {
|
||||
comm = strings.TrimSpace(*p.CommunityID)
|
||||
}
|
||||
kind, sourceName := classifySource(src)
|
||||
k := kind + "|" + sourceName + "|" + comm
|
||||
g, ok := groups[k]
|
||||
if !ok {
|
||||
g = &agg{kind: kind, source: sourceName, community: comm}
|
||||
groups[k] = g
|
||||
}
|
||||
g.count++
|
||||
if len(g.sample) < 5 {
|
||||
g.sample = append(g.sample, p.Prefix)
|
||||
}
|
||||
}
|
||||
kind, sourceName := classifySource(src)
|
||||
k := kind + "|" + sourceName + "|" + comm
|
||||
g, ok := groups[k]
|
||||
if !ok {
|
||||
g = &agg{kind: kind, source: sourceName, community: comm}
|
||||
groups[k] = g
|
||||
if !more {
|
||||
break
|
||||
}
|
||||
g.count++
|
||||
if len(g.sample) < 5 {
|
||||
g.sample = append(g.sample, p.Prefix)
|
||||
cursor = next
|
||||
if strings.TrimSpace(cursor) == "" {
|
||||
break
|
||||
}
|
||||
}
|
||||
keys := make([]string, 0, len(groups))
|
||||
@@ -374,16 +374,16 @@ func (w *Worker) buildRevisionLogEntries(tenantID, revID string) ([]map[string]a
|
||||
cl := resolveCommunityLabel(g.community, commLabels)
|
||||
msg := humanLogMessage(g.kind, g.source, g.count, cl, g.sample)
|
||||
out = append(out, map[string]any{
|
||||
"kind": g.kind,
|
||||
"source": g.source,
|
||||
"community": g.community,
|
||||
"community_label": cl,
|
||||
"prefix_count": g.count,
|
||||
"sample": g.sample,
|
||||
"message": msg,
|
||||
"kind": g.kind,
|
||||
"source": g.source,
|
||||
"community": g.community,
|
||||
"community_label": cl,
|
||||
"prefix_count": g.count,
|
||||
"sample": g.sample,
|
||||
"message": msg,
|
||||
})
|
||||
}
|
||||
return out, len(all), nil
|
||||
return out, total, nil
|
||||
}
|
||||
|
||||
func classifySource(src string) (kind, name string) {
|
||||
|
||||
Reference in New Issue
Block a user