-
Notifications
You must be signed in to change notification settings - Fork 16
Automatically taint servers when receiving critical bmc events #692
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
base: main
Are you sure you want to change the base?
Changes from 44 commits
9333c7d
ecec4f8
ea45555
dbad795
4e40c37
62cbaf9
bbad483
a527b0a
388d742
dbe2b7f
f41134a
654d26f
77babc4
e15979d
0a0b668
fc2d83b
1546e65
0e80893
e907634
07c4ad7
7faf701
a7fa18c
2fd3316
9c5bb73
ce07ed8
b9f11c5
4e2f853
f521c13
71c96e3
1103dd1
354242a
85fe087
e16f7e5
8ec6768
8e2c76c
bb70235
95e8a50
96f2380
75ad8b1
9fe9af0
7bff181
dbc8edd
5a0108e
adca1ef
57b045b
4ca7a5d
cf04864
0480e34
9824b30
ac5069e
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
| Original file line number | Diff line number | Diff line change | ||||||||||||||||||||||||||||||||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
|
|
@@ -14,6 +14,7 @@ import ( | |||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||
| "github.com/ironcore-dev/controller-utils/conditionutils" | ||||||||||||||||||||||||||||||||||||||||||
| "github.com/ironcore-dev/metal-operator/internal/cmd/dns" | ||||||||||||||||||||||||||||||||||||||||||
| "github.com/ironcore-dev/metal-operator/internal/serverevents" | ||||||||||||||||||||||||||||||||||||||||||
| webhookv1alpha1 "github.com/ironcore-dev/metal-operator/internal/webhook/v1alpha1" | ||||||||||||||||||||||||||||||||||||||||||
| "sigs.k8s.io/controller-runtime/pkg/manager" | ||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||
|
|
@@ -76,6 +77,9 @@ func main() { // nolint: gocyclo | |||||||||||||||||||||||||||||||||||||||||
| registryPort int | ||||||||||||||||||||||||||||||||||||||||||
| registryProtocol string | ||||||||||||||||||||||||||||||||||||||||||
| registryURL string | ||||||||||||||||||||||||||||||||||||||||||
| eventPort int | ||||||||||||||||||||||||||||||||||||||||||
| eventURL string | ||||||||||||||||||||||||||||||||||||||||||
| eventProtocol string | ||||||||||||||||||||||||||||||||||||||||||
| registryResyncInterval time.Duration | ||||||||||||||||||||||||||||||||||||||||||
| webhookPort int | ||||||||||||||||||||||||||||||||||||||||||
| enforceFirstBoot bool | ||||||||||||||||||||||||||||||||||||||||||
|
|
@@ -125,6 +129,10 @@ func main() { // nolint: gocyclo | |||||||||||||||||||||||||||||||||||||||||
| flag.StringVar(®istryURL, "registry-url", "", "The URL of the registry.") | ||||||||||||||||||||||||||||||||||||||||||
| flag.StringVar(®istryProtocol, "registry-protocol", "http", "The protocol to use for the registry.") | ||||||||||||||||||||||||||||||||||||||||||
| flag.IntVar(®istryPort, "registry-port", 10000, "The port to use for the registry.") | ||||||||||||||||||||||||||||||||||||||||||
| flag.StringVar(&eventURL, "event-url", "", "The URL of the server events endpoint for alerts and metrics.") | ||||||||||||||||||||||||||||||||||||||||||
| flag.IntVar(&eventPort, "event-port", 10001, "The port to use for the server events endpoint for alerts and metrics.") | ||||||||||||||||||||||||||||||||||||||||||
| flag.StringVar(&eventProtocol, "event-protocol", "http", | ||||||||||||||||||||||||||||||||||||||||||
| "The protocol to use for the server events endpoint for alerts and metrics.") | ||||||||||||||||||||||||||||||||||||||||||
| flag.StringVar(&probeImage, "probe-image", "", "Image for the first boot probing of a Server.") | ||||||||||||||||||||||||||||||||||||||||||
| flag.StringVar(&probeOSImage, "probe-os-image", "", "OS image for the first boot probing of a Server.") | ||||||||||||||||||||||||||||||||||||||||||
| flag.StringVar(&managerNamespace, "manager-namespace", "default", "Namespace the manager is running in.") | ||||||||||||||||||||||||||||||||||||||||||
|
|
@@ -210,6 +218,17 @@ func main() { // nolint: gocyclo | |||||||||||||||||||||||||||||||||||||||||
| registryURL = fmt.Sprintf("%s://%s:%d", registryProtocol, registryAddr, registryPort) | ||||||||||||||||||||||||||||||||||||||||||
| } | ||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||
| // set the correct event URL by getting the address from the environment | ||||||||||||||||||||||||||||||||||||||||||
| var eventAddr string | ||||||||||||||||||||||||||||||||||||||||||
| if eventURL == "" { | ||||||||||||||||||||||||||||||||||||||||||
| eventAddr = os.Getenv("EVENT_ADDRESS") | ||||||||||||||||||||||||||||||||||||||||||
| if eventAddr == "" { | ||||||||||||||||||||||||||||||||||||||||||
| setupLog.Error(nil, "failed to set the event URL as no address is provided") | ||||||||||||||||||||||||||||||||||||||||||
| } else { | ||||||||||||||||||||||||||||||||||||||||||
| eventURL = fmt.Sprintf("%s://%s:%d", eventProtocol, eventAddr, eventPort) | ||||||||||||||||||||||||||||||||||||||||||
| } | ||||||||||||||||||||||||||||||||||||||||||
| } | ||||||||||||||||||||||||||||||||||||||||||
|
Comment on lines
+221
to
+230
Contributor
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. Inconsistent logging level: use Line 221 uses Suggested fix var eventAddr string
if eventURL == "" {
eventAddr = os.Getenv("EVENT_ADDRESS")
if eventAddr == "" {
- setupLog.Error(nil, "failed to set the event URL as no address is provided")
+ setupLog.Info("Event URL not configured, event subscriptions will be disabled")
} else {
eventURL = fmt.Sprintf("%s://%s:%d", eventProtocol, eventAddr, eventPort)
}
}📝 Committable suggestion
Suggested change
🤖 Prompt for AI Agents |
||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||
| // if the enable-http2 flag is false (the default), http/2 should be disabled | ||||||||||||||||||||||||||||||||||||||||||
| // due to its vulnerabilities. More specifically, disabling http/2 will | ||||||||||||||||||||||||||||||||||||||||||
| // prevent from being vulnerable to the HTTP/2 Stream Cancelation and | ||||||||||||||||||||||||||||||||||||||||||
|
|
@@ -355,6 +374,7 @@ func main() { // nolint: gocyclo | |||||||||||||||||||||||||||||||||||||||||
| BMCResetWaitTime: bmcResetWaitingInterval, | ||||||||||||||||||||||||||||||||||||||||||
| BMCClientRetryInterval: bmcResetResyncInterval, | ||||||||||||||||||||||||||||||||||||||||||
| ManagerNamespace: managerNamespace, | ||||||||||||||||||||||||||||||||||||||||||
| EventURL: eventURL, | ||||||||||||||||||||||||||||||||||||||||||
| DNSRecordTemplate: dnsRecordTemplate, | ||||||||||||||||||||||||||||||||||||||||||
| Conditions: conditionutils.NewAccessor(conditionutils.AccessorOptions{}), | ||||||||||||||||||||||||||||||||||||||||||
| BMCOptions: bmc.Options{ | ||||||||||||||||||||||||||||||||||||||||||
|
|
@@ -615,6 +635,26 @@ func main() { // nolint: gocyclo | |||||||||||||||||||||||||||||||||||||||||
| os.Exit(1) | ||||||||||||||||||||||||||||||||||||||||||
| } | ||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||
| if eventURL != "" { | ||||||||||||||||||||||||||||||||||||||||||
| if err := mgr.Add(manager.RunnableFunc(func(ctx context.Context) error { | ||||||||||||||||||||||||||||||||||||||||||
| setupLog.Info("starting event server for alerts and metrics", "EventURL", eventURL) | ||||||||||||||||||||||||||||||||||||||||||
| eventServer := serverevents.NewServer(setupLog, fmt.Sprintf(":%d", eventPort)) | ||||||||||||||||||||||||||||||||||||||||||
| eventServer.SetClient(mgr.GetClient()) | ||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||
| criticalEventHandler := serverevents.CreateCriticalEventHandler(mgr.GetClient(), setupLog) | ||||||||||||||||||||||||||||||||||||||||||
| eventServer.SetCriticalEventHandler(criticalEventHandler) | ||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||
| if err := eventServer.Start(ctx); err != nil { | ||||||||||||||||||||||||||||||||||||||||||
| return fmt.Errorf("unable to start event server: %w", err) | ||||||||||||||||||||||||||||||||||||||||||
| } | ||||||||||||||||||||||||||||||||||||||||||
| <-ctx.Done() | ||||||||||||||||||||||||||||||||||||||||||
| return nil | ||||||||||||||||||||||||||||||||||||||||||
| })); err != nil { | ||||||||||||||||||||||||||||||||||||||||||
| setupLog.Error(err, "unable to add event runnable to manager") | ||||||||||||||||||||||||||||||||||||||||||
| os.Exit(1) | ||||||||||||||||||||||||||||||||||||||||||
| } | ||||||||||||||||||||||||||||||||||||||||||
| } | ||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||
| setupLog.Info("Starting manager") | ||||||||||||||||||||||||||||||||||||||||||
| if err := mgr.Start(ctx); err != nil { | ||||||||||||||||||||||||||||||||||||||||||
| setupLog.Error(err, "Failed to run manager") | ||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||
Uh oh!
There was an error while loading. Please reload this page.