Skip to content

Commit

Permalink
Make module Prometheus config create dir before templating
Browse files Browse the repository at this point in the history
  • Loading branch information
jclapis committed Jun 20, 2024
1 parent b79e387 commit 87184cf
Show file tree
Hide file tree
Showing 5 changed files with 21 additions and 15 deletions.
15 changes: 6 additions & 9 deletions go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ require (
github.com/ethereum/go-ethereum v1.14.3
github.com/gdamore/tcell/v2 v2.7.4
github.com/nodeset-org/hyperdrive-daemon v1.0.0
github.com/nodeset-org/hyperdrive-stakewise v1.0.0
github.com/nodeset-org/hyperdrive-stakewise v1.0.1
github.com/rivo/tview v0.0.0-20230208211350-7dfff1ce7854 // DO NOT UPGRADE
github.com/rocket-pool/node-manager-core v0.5.1-0.20240620041049-333f5150790e
golang.org/x/sync v0.7.0
Expand All @@ -24,6 +24,7 @@ require (
github.com/alessio/shellescape v1.4.2
github.com/bits-and-blooms/bitset v1.13.0 // indirect
github.com/btcsuite/btcd/btcec/v2 v2.3.2 // indirect
github.com/cenkalti/backoff/v4 v4.3.0 // indirect
github.com/cespare/cp v1.1.1 // indirect
github.com/consensys/bavard v0.1.13 // indirect
github.com/consensys/gnark-crypto v0.12.1 // indirect
Expand Down Expand Up @@ -67,6 +68,7 @@ require (
github.com/prysmaticlabs/go-bitfield v0.0.0-20210809151128-385d8c5e3fb7 // indirect
github.com/rivo/uniseg v0.4.7 // indirect
github.com/rocket-pool/batch-query v1.0.0 // indirect
github.com/rogpeppe/go-internal v1.12.0 // indirect
github.com/russross/blackfriday/v2 v2.1.0 // indirect
github.com/sethvargo/go-password v0.2.0 // indirect
github.com/shirou/gopsutil v3.21.11+incompatible // indirect
Expand All @@ -79,8 +81,11 @@ require (
github.com/yusufpapurcu/wmi v1.2.4 // indirect
go.opentelemetry.io/contrib/instrumentation/net/http/otelhttp v0.49.0 // indirect
go.opentelemetry.io/otel v1.27.0 // indirect
go.opentelemetry.io/otel/exporters/otlp/otlptrace v1.27.0 // indirect
go.opentelemetry.io/otel/metric v1.27.0 // indirect
go.opentelemetry.io/otel/sdk v1.27.0 // indirect
go.opentelemetry.io/otel/trace v1.27.0 // indirect
go.opentelemetry.io/proto/otlp v1.3.1 // indirect
golang.org/x/crypto v0.22.0 // indirect
golang.org/x/net v0.24.0 // indirect
golang.org/x/sys v0.20.0 // indirect
Expand All @@ -89,11 +94,3 @@ require (
gopkg.in/yaml.v3 v3.0.1 // indirect
rsc.io/tmplfunc v0.0.3 // indirect
)

require (
github.com/cenkalti/backoff/v4 v4.3.0 // indirect
github.com/rogpeppe/go-internal v1.12.0 // indirect
go.opentelemetry.io/otel/exporters/otlp/otlptrace v1.27.0 // indirect
go.opentelemetry.io/otel/sdk v1.27.0 // indirect
go.opentelemetry.io/proto/otlp v1.3.1 // indirect
)
4 changes: 2 additions & 2 deletions go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -173,8 +173,8 @@ github.com/morikuni/aec v1.0.0 h1:nP9CBfwrvYnBRgY6qfDQkygYDmYwOilePFkwzv4dU8A=
github.com/morikuni/aec v1.0.0/go.mod h1:BbKIizmSmc5MMPqRYbxO4ZU0S0+P200+tUnFx7PXmsc=
github.com/nodeset-org/hyperdrive-daemon v1.0.0 h1:gacaa2kP2wv1dBO4cpG03RGsdmCTiVRo2VvrhXb16zI=
github.com/nodeset-org/hyperdrive-daemon v1.0.0/go.mod h1:bkAacICyImNf7/nrHGiTuysDMCxtOq4wQ6dk1d2PbvI=
github.com/nodeset-org/hyperdrive-stakewise v1.0.0 h1:w+QDbk1hndR079IAGe2JZ81lfTn08+VQIPyR7mQTats=
github.com/nodeset-org/hyperdrive-stakewise v1.0.0/go.mod h1:exRKj9kwdtHODX9woOllW/ZSarzmopTnVOvLEMyw+OU=
github.com/nodeset-org/hyperdrive-stakewise v1.0.1 h1:/o51y+O2MfHOQyzqLQepes9Afho+49pEaIgCi9hmRTI=
github.com/nodeset-org/hyperdrive-stakewise v1.0.1/go.mod h1:exRKj9kwdtHODX9woOllW/ZSarzmopTnVOvLEMyw+OU=
github.com/olekukonko/tablewriter v0.0.5 h1:P2Ga83D34wi1o9J6Wh1mRuqd4mF/x/lgBS7N7AbDhec=
github.com/olekukonko/tablewriter v0.0.5/go.mod h1:hPp6KlRPjbx+hW8ykQs1w3UBbZlj6HuIJcUGPhkA7kY=
github.com/opencontainers/go-digest v1.0.0 h1:apOUWs51W5PlhuyGyz9FCeeBIOUDA/6nW8Oi/yOhh5U=
Expand Down
13 changes: 11 additions & 2 deletions hyperdrive-cli/client/compose.go
Original file line number Diff line number Diff line change
Expand Up @@ -272,15 +272,24 @@ func (c *HyperdriveClient) composeModule(global *GlobalConfig, module hdconfig.I
deployedContainers = append(deployedContainers, containers...)
}

// Deploy the Prometheus config if it exists
// Check if the module has a Prometheus config
prometheusConfigFilename := modulePrometheusSd + template.TemplateSuffix
_, err = os.Stat(filepath.Join(composePaths.TemplatePath, prometheusConfigFilename))
if os.IsNotExist(err) {
return deployedContainers, nil
}

// Make the modules dir
modulesDir := filepath.Join(hyperdriveDir, metricsDir, hdconfig.ModulesName)
err = os.MkdirAll(modulesDir, metricsDirMode)
if err != nil {
return []string{}, fmt.Errorf("error creating metrics module directory [%s]: %w", modulesDir, err)
}

// Deploy the Prometheus config
t := template.Template{
Src: filepath.Join(composePaths.TemplatePath, prometheusConfigFilename),
Dst: filepath.Join(hyperdriveDir, metricsDir, hdconfig.ModulesName, moduleName+template.ComposeFileSuffix),
Dst: filepath.Join(modulesDir, moduleName+template.ComposeFileSuffix),
}
err = t.Write(global)
if err != nil {
Expand Down
2 changes: 1 addition & 1 deletion hyperdrive-cli/client/service.go
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ const (
runtimeDir string = "runtime"
metricsDir string = "metrics"
extraScrapeJobsDir string = "extra-scrape-jobs"
modulePrometheusSd string = "prometheus_sd"
modulePrometheusSd string = "prometheus-sd"
)

// Install Hyperdrive
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,4 +2,4 @@
- labels:
job: "sw_vc"
targets:
- 'sw_vc:{{.StakeWise.VcCommon.MetricsPort}}'
- 'sw_vc:{{.Stakewise.VcCommon.MetricsPort}}'

0 comments on commit 87184cf

Please sign in to comment.