Skip to content

Commit

Permalink
feat: prevent rebooting too frequently
Browse files Browse the repository at this point in the history
Introduce a new variable and a check to avoid machines from being rebooted too frequently.

Signed-off-by: Utku Ozdemir <[email protected]>
  • Loading branch information
utkuozdemir committed Dec 10, 2024
1 parent e6bfaa9 commit 4f52230
Show file tree
Hide file tree
Showing 8 changed files with 190 additions and 74 deletions.
143 changes: 82 additions & 61 deletions api/specs/specs.pb.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

7 changes: 7 additions & 0 deletions api/specs/specs.proto
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,8 @@ package baremetalproviderspecs;

option go_package = "github.com/siderolabs/omni-infra-provider-bare-metal/api/specs";

import "google/protobuf/timestamp.proto";

message PowerManagement {
message IPMI {
string address = 1;
Expand Down Expand Up @@ -46,4 +48,9 @@ message MachineStatusSpec {
//
// It is used to track if the machine needs to be wiped for an allocation.
string last_wipe_id = 4;

// LastRebootTimestamp is the timestamp of the last reboot (or power on) of the machine.
//
// It is used to track the last reboot time of the machine, and to enforce the MinRebootInterval.
google.protobuf.Timestamp last_reboot_timestamp = 5;
}
56 changes: 56 additions & 0 deletions api/specs/specs_vtproto.pb.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 2 additions & 0 deletions cmd/provider/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -135,6 +135,8 @@ func init() {
"Comma separated list of key=value pairs to be set to the machine. Example: key1=value1,key2,key3=value3")
rootCmd.Flags().BoolVar(&providerOptions.InsecureSkipTLSVerify, "insecure-skip-tls-verify", provider.DefaultOptions.InsecureSkipTLSVerify,
"Skip TLS verification when connecting to the Omni API.")
rootCmd.Flags().DurationVar(&providerOptions.MinRebootInterval, "min-reboot-interval", provider.DefaultOptions.MinRebootInterval,
"the minimum interval between reboots of the machine issued by the provider. This is to prevent the provider from issuing reboots too frequently.")

if constants.IsDebugBuild {
rootCmd.Flags().BoolVar(&providerOptions.ClearState, "clear-state", provider.DefaultOptions.ClearState, "Clear the state of the provider on startup.")
Expand Down
1 change: 1 addition & 0 deletions hack/test/integration.sh
Original file line number Diff line number Diff line change
Expand Up @@ -182,6 +182,7 @@ docker run -d --network host \
--agent-test-mode \
--api-power-mgmt-state-dir=/api-power-mgmt-state \
--ipmi-pxe-boot-mode=bios \
--min-reboot-interval=1m \
--debug

docker logs -f provider &
Expand Down
Loading

0 comments on commit 4f52230

Please sign in to comment.