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

feat: prevent rebooting too frequently #4

Merged
merged 1 commit into from
Dec 10, 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
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