Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Set up path-based routes for job-monitor ingress #222

Merged
merged 2 commits into from
Nov 8, 2024
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
22 changes: 13 additions & 9 deletions src/FSLibrary/MissionHistoryPubnetParallelCatchupV2.fs
Original file line number Diff line number Diff line change
Expand Up @@ -26,8 +26,9 @@ let valuesFilePath = helmChartPath + "/values.yaml"
let jobMonitorHostName = "ssc-job-monitor.services.stellar-ops.com"
let jobMonitorStatusEndPoint = "/status"
let jobMonitorMetricsEndPoint = "/metrics"
let jobMonitorStatusCheckIntervalSecs = 300
let jobMonitorMetricsCheckIntervalSecs = 300
let jobMonitorLoggingIntervalSecs = 300 // frequency of job monitor's internal information gathering (querying core endpoint and redis metrics) and logging
let jobMonitorStatusCheckIntervalSecs = 300 // frequency of us querying job monitor's `/status` end point
let jobMonitorMetricsCheckIntervalSecs = 300 // frequency of us querying job monitor's `/metrics` end point
let jobMonitorStatusCheckTimeOutSecs = 600
let mutable toPerformCleanup = true

Expand Down Expand Up @@ -72,6 +73,8 @@ let installProject (context: MissionContext) =

setOptions.Add(sprintf "range_generator.params.latest_ledger_num=%d" endLedger)
setOptions.Add(sprintf "monitor.hostname=%s" jobMonitorHostName)
setOptions.Add(sprintf "monitor.path=/%s/(.*)" context.namespaceProperty)
setOptions.Add(sprintf "monitor.logging_interval_seconds=%d" jobMonitorLoggingIntervalSecs)

// comment out the line below when doing local testing
Environment.SetEnvironmentVariable("KUBECONFIG", context.kubeCfg)
Expand Down Expand Up @@ -111,13 +114,13 @@ Console.CancelKeyPress.Add
cleanup ()
Environment.Exit(0))

let getJobMonitorStatus (endPoint: String) =
let queryJobMonitor (path: String, endPoint: String) =
try
use client = new HttpClient()
let url = "http://" + jobMonitorHostName + path + endPoint
let response = client.GetStringAsync(url).Result

let response = client.GetStringAsync("http://" + jobMonitorHostName + endPoint).Result

LogInfo "job monitor '%s': %s" endPoint response
LogInfo "job monitor query '%s', got response: %s" url response
let json = JObject.Parse(response)
Some(json)
with ex ->
Expand Down Expand Up @@ -146,10 +149,11 @@ let historyPubnetParallelCatchupV2 (context: MissionContext) =
let mutable allJobsFinished = false
let mutable timeoutLeft = jobMonitorStatusCheckTimeOutSecs
let mutable timeBeforeNextMetricsCheck = jobMonitorMetricsCheckIntervalSecs
let jobMonitorPath = "/" + context.namespaceProperty

while not allJobsFinished do
Thread.Sleep(jobMonitorStatusCheckIntervalSecs * 1000)
let statusOpt = getJobMonitorStatus (jobMonitorStatusEndPoint)
let statusOpt = queryJobMonitor (jobMonitorPath, jobMonitorStatusEndPoint)

try
match statusOpt with
Expand All @@ -169,7 +173,7 @@ let historyPubnetParallelCatchupV2 (context: MissionContext) =

if remainSize = 0 && JobsInProgress.Count = 0 then
// perform a final get for the metrics
getJobMonitorStatus (jobMonitorMetricsEndPoint) |> ignore
queryJobMonitor (jobMonitorPath, jobMonitorMetricsEndPoint) |> ignore

// check all workers are down
let allWorkersDown =
Expand All @@ -186,7 +190,7 @@ let historyPubnetParallelCatchupV2 (context: MissionContext) =
timeBeforeNextMetricsCheck <- timeBeforeNextMetricsCheck - jobMonitorStatusCheckIntervalSecs

if timeBeforeNextMetricsCheck <= 0 then
getJobMonitorStatus (jobMonitorMetricsEndPoint) |> ignore
queryJobMonitor (jobMonitorPath, jobMonitorMetricsEndPoint) |> ignore
timeBeforeNextMetricsCheck <- jobMonitorMetricsCheckIntervalSecs

| None ->
Expand Down
1 change: 1 addition & 0 deletions src/FSLibrary/StellarCoreCfg.fs
Original file line number Diff line number Diff line change
Expand Up @@ -207,6 +207,7 @@ type StellarCoreCfg =
t.Add("PREFERRED_PEERS_ONLY", self.preferredPeersOnly) |> ignore
t.Add("COMMANDS", logLevelCommands) |> ignore
t.Add("CATCHUP_COMPLETE", self.catchupMode = CatchupComplete) |> ignore

if self.network.missionContext.enableBackggroundOverlay then
t.Add("EXPERIMENTAL_BACKGROUND_OVERLAY_PROCESSING", true) |> ignore

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,14 +3,15 @@ kind: Ingress
metadata:
name: job-monitor-ingress
annotations:
nginx.ingress.kubernetes.io/rewrite-target: /
nginx.ingress.kubernetes.io/use-regex: "true"
nginx.ingress.kubernetes.io/rewrite-target: /$1
spec:
ingressClassName: "{{ .Values.monitor.ingress_class_name}}"
rules:
- host: "{{ .Values.monitor.hostname}}"
http:
paths:
- path: /
- path: "{{ .Values.monitor.path}}"
pathType: Prefix
backend:
service:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@ worker:
monitor:
ingress_class_name: "private"
hostname: "ssc-job-monitor.services.stellar-ops.com"
path: "/default/(.*)"
logging_interval_seconds: 300
logging_level: "INFO" # 'DEBUG', 'INFO', 'WARNING', 'ERROR', 'CRITICAL'
resources:
Expand Down
Loading