Skip to content

Commit

Permalink
Unify check attempt data type to uint32 already used somewhere
Browse files Browse the repository at this point in the history
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).
  • Loading branch information
Al2Klimov committed Oct 10, 2023
1 parent 57f4f78 commit 855190f
Show file tree
Hide file tree
Showing 5 changed files with 6 additions and 6 deletions.
2 changes: 1 addition & 1 deletion cmd/icingadb-migrate/convert.go
Original file line number Diff line number Diff line change
Expand Up @@ -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),
Expand Down
2 changes: 1 addition & 1 deletion pkg/icingadb/v1/checkable.go
Original file line number Diff line number Diff line change
Expand Up @@ -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"`
Expand Down
2 changes: 1 addition & 1 deletion pkg/icingadb/v1/history/state.go
Original file line number Diff line number Diff line change
Expand Up @@ -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"`
Expand Down
2 changes: 1 addition & 1 deletion pkg/icingadb/v1/state.go
Original file line number Diff line number Diff line change
Expand Up @@ -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"`
Expand Down
4 changes: 2 additions & 2 deletions tests/object_sync_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -655,7 +655,7 @@ type Host struct {
Address string `icinga2:"address" icingadb:"address"`
Address6 string `icinga2:"address6" icingadb:"address6"`
CheckCommandName string `icinga2:"check_command" icingadb:"checkcommand_name"`
MaxCheckAttempts float64 `icinga2:"max_check_attempts" icingadb:"max_check_attempts"`
MaxCheckAttempts uint32 `icinga2:"max_check_attempts" icingadb:"max_check_attempts"`
CheckPeriodName string `icinga2:"check_period" icingadb:"check_timeperiod_name"`
CheckTimeout float64 `icinga2:"check_timeout" icingadb:"check_timeout"`
CheckInterval float64 `icinga2:"check_interval" icingadb:"check_interval"`
Expand Down Expand Up @@ -747,7 +747,7 @@ type Service struct {
DisplayName string `icinga2:"display_name" icingadb:"display_name"`
HostName *string `icinga2:"host_name,nomodify" icingadb:"host.name"`
CheckCommandName string `icinga2:"check_command" icingadb:"checkcommand_name"`
MaxCheckAttempts float64 `icinga2:"max_check_attempts" icingadb:"max_check_attempts"`
MaxCheckAttempts uint32 `icinga2:"max_check_attempts" icingadb:"max_check_attempts"`
CheckPeriodName string `icinga2:"check_period" icingadb:"check_timeperiod_name"`
CheckTimeout float64 `icinga2:"check_timeout" icingadb:"check_timeout"`
CheckInterval float64 `icinga2:"check_interval" icingadb:"check_interval"`
Expand Down

0 comments on commit 855190f

Please sign in to comment.