From f26ecbf6daf199a452e988f9117e14528008b5fe Mon Sep 17 00:00:00 2001 From: "Alexander A. Klimov" Date: Tue, 10 Oct 2023 11:45:43 +0200 Subject: [PATCH] Unify check attempt data type to uint32 already used somewhere A float isn't necessary as in Icinga 2 Checkable#max_check_attempts and check_attempt are ints. But uint8 isn't enough for e.g. 1 check/s to get HARD after 5m (300s > 255). --- cmd/icingadb-migrate/convert.go | 2 +- pkg/icingadb/v1/checkable.go | 2 +- pkg/icingadb/v1/history/state.go | 2 +- pkg/icingadb/v1/state.go | 2 +- 4 files changed, 4 insertions(+), 4 deletions(-) diff --git a/cmd/icingadb-migrate/convert.go b/cmd/icingadb-migrate/convert.go index e14746e46..4767d86cc 100644 --- a/cmd/icingadb-migrate/convert.go +++ b/cmd/icingadb-migrate/convert.go @@ -813,7 +813,7 @@ func convertStateRows( HardState: row.LastHardState, PreviousSoftState: row.LastState, PreviousHardState: previousHardState, - CheckAttempt: uint8(row.CurrentCheckAttempt), + CheckAttempt: uint32(row.CurrentCheckAttempt), Output: icingadbTypes.String{NullString: row.Output}, LongOutput: icingadbTypes.String{NullString: row.LongOutput}, MaxCheckAttempts: uint32(row.MaxCheckAttempts), diff --git a/pkg/icingadb/v1/checkable.go b/pkg/icingadb/v1/checkable.go index dbb114cbc..4b1efeb9c 100644 --- a/pkg/icingadb/v1/checkable.go +++ b/pkg/icingadb/v1/checkable.go @@ -30,7 +30,7 @@ type Checkable struct { IconImageAlt string `json:"icon_image_alt"` IconImageId types.Binary `json:"icon_image_id"` IsVolatile types.Bool `json:"is_volatile"` - MaxCheckAttempts float64 `json:"max_check_attempts"` + MaxCheckAttempts uint32 `json:"max_check_attempts"` Notes string `json:"notes"` NotesUrlId types.Binary `json:"notes_url_id"` NotificationsEnabled types.Bool `json:"notifications_enabled"` diff --git a/pkg/icingadb/v1/history/state.go b/pkg/icingadb/v1/history/state.go index dec13b042..6320b738a 100644 --- a/pkg/icingadb/v1/history/state.go +++ b/pkg/icingadb/v1/history/state.go @@ -14,7 +14,7 @@ type StateHistory struct { HardState uint8 `json:"hard_state"` PreviousSoftState uint8 `json:"previous_soft_state"` PreviousHardState uint8 `json:"previous_hard_state"` - CheckAttempt uint8 `json:"check_attempt"` + CheckAttempt uint32 `json:"check_attempt"` Output types.String `json:"output"` LongOutput types.String `json:"long_output"` MaxCheckAttempts uint32 `json:"max_check_attempts"` diff --git a/pkg/icingadb/v1/state.go b/pkg/icingadb/v1/state.go index bad8f28c5..983b14d5a 100644 --- a/pkg/icingadb/v1/state.go +++ b/pkg/icingadb/v1/state.go @@ -9,7 +9,7 @@ type State struct { EnvironmentMeta `json:",inline"` AcknowledgementCommentId types.Binary `json:"acknowledgement_comment_id"` LastCommentId types.Binary `json:"last_comment_id"` - CheckAttempt uint8 `json:"check_attempt"` + CheckAttempt uint32 `json:"check_attempt"` CheckCommandline types.String `json:"check_commandline"` CheckSource types.String `json:"check_source"` SchedulingSource types.String `json:"scheduling_source"`