-
Notifications
You must be signed in to change notification settings - Fork 214
feat(redfish): add redfish support #2263
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
Changes from all commits
0f343c4
00660f2
1d73b32
97bc1dc
ddd425e
c46806e
f194409
7d971ce
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -11,13 +11,15 @@ import ( | |
"syscall" | ||
|
||
"github.com/alecthomas/kingpin/v2" | ||
|
||
"github.com/sustainable-computing-io/kepler/config" | ||
"github.com/sustainable-computing-io/kepler/internal/device" | ||
"github.com/sustainable-computing-io/kepler/internal/exporter/prometheus" | ||
"github.com/sustainable-computing-io/kepler/internal/exporter/stdout" | ||
"github.com/sustainable-computing-io/kepler/internal/k8s/pod" | ||
"github.com/sustainable-computing-io/kepler/internal/logger" | ||
"github.com/sustainable-computing-io/kepler/internal/monitor" | ||
"github.com/sustainable-computing-io/kepler/internal/platform/redfish" | ||
"github.com/sustainable-computing-io/kepler/internal/resource" | ||
"github.com/sustainable-computing-io/kepler/internal/server" | ||
"github.com/sustainable-computing-io/kepler/internal/service" | ||
|
@@ -157,6 +159,8 @@ func createServices(logger *slog.Logger, cfg *config.Config) ([]service.Service, | |
monitor.WithMinTerminatedEnergyThreshold(monitor.Energy(cfg.Monitor.MinTerminatedEnergyThreshold)*monitor.Joule), | ||
) | ||
|
||
// Create Redfish service if enabled (experimental feature) | ||
|
||
apiServer := server.NewAPIServer( | ||
server.WithLogger(logger), | ||
server.WithListenAddress(cfg.Web.ListenAddresses), | ||
|
@@ -170,43 +174,69 @@ func createServices(logger *slog.Logger, cfg *config.Config) ([]service.Service, | |
pm, | ||
) | ||
|
||
// Add Redfish service if enabled | ||
var redfishService *redfish.Service | ||
if cfg.IsFeatureEnabled(config.ExperimentalRedfishFeature) { | ||
rs, err := createRedfishService(logger, cfg) | ||
if err != nil { | ||
return nil, fmt.Errorf("failed to create Redfish service: %w", err) | ||
} | ||
services = append(services, rs) | ||
redfishService = rs | ||
} | ||
|
||
// Add Prometheus exporter if enabled | ||
if *cfg.Exporter.Prometheus.Enabled { | ||
promExporter, err := createPrometheusExporter(logger, cfg, apiServer, pm) | ||
if cfg.IsFeatureEnabled(config.PrometheusFeature) { | ||
promExporter, err := createPrometheusExporter(logger, cfg, apiServer, pm, redfishService) | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. use Options to inject redfish There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. yes, that's how it is currently done in There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. what if there is no redfish, we are passing a nil pointer There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Correct, .. and createPrometheusExporter (local function) handles that. |
||
if err != nil { | ||
return nil, fmt.Errorf("failed to create Prometheus exporter: %w", err) | ||
} | ||
services = append(services, promExporter) | ||
} | ||
|
||
// Add pprof if enabled | ||
if *cfg.Debug.Pprof.Enabled { | ||
if cfg.IsFeatureEnabled(config.PprofFeature) { | ||
pprof := server.NewPprof(apiServer) | ||
services = append(services, pprof) | ||
} | ||
|
||
// Add stdout exporter if enabled | ||
if *cfg.Exporter.Stdout.Enabled { | ||
if cfg.IsFeatureEnabled(config.StdoutFeature) { | ||
stdoutExporter := stdout.NewExporter(pm, stdout.WithLogger(logger)) | ||
services = append(services, stdoutExporter) | ||
} | ||
|
||
return services, nil | ||
} | ||
|
||
func createPrometheusExporter(logger *slog.Logger, cfg *config.Config, apiServer *server.APIServer, pm *monitor.PowerMonitor) (*prometheus.Exporter, error) { | ||
func createRedfishService(logger *slog.Logger, cfg *config.Config) (*redfish.Service, error) { | ||
return redfish.NewService(cfg.Experimental.Platform.Redfish, logger, redfish.WithStaleness(cfg.Monitor.Staleness)) | ||
} | ||
|
||
func createPrometheusExporter( | ||
logger *slog.Logger, cfg *config.Config, | ||
apiServer *server.APIServer, pm *monitor.PowerMonitor, | ||
rs *redfish.Service, | ||
) (*prometheus.Exporter, error) { | ||
logger.Debug("Creating Prometheus exporter") | ||
|
||
// Use metrics level from configuration (already parsed) | ||
metricsLevel := cfg.Exporter.Prometheus.MetricsLevel | ||
|
||
collectors, err := prometheus.CreateCollectors( | ||
pm, | ||
var collectorOpts []prometheus.OptionFn | ||
collectorOpts = append(collectorOpts, | ||
prometheus.WithLogger(logger), | ||
prometheus.WithProcFSPath(cfg.Host.ProcFS), | ||
prometheus.WithNodeName(cfg.Kube.Node), | ||
prometheus.WithMetricsLevel(metricsLevel), | ||
) | ||
|
||
// Add platform data provider if Redfish service is available | ||
if rs != nil { | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. @vimalk78 .. here. Should we make it more abstract? |
||
collectorOpts = append(collectorOpts, prometheus.WithPlatformDataProvider(rs)) | ||
} | ||
|
||
collectors, err := prometheus.CreateCollectors(pm, collectorOpts...) | ||
if err != nil { | ||
return nil, fmt.Errorf("failed to create Prometheus collectors: %w", err) | ||
} | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
is redfish service, as configured in
configFile: /etc/kepler/redfish.yaml
, does not respond or is unavailable at the moment. should kepler shutdown?