-
Notifications
You must be signed in to change notification settings - Fork 21
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
Sync dependencies #889
Open
yhabteab
wants to merge
18
commits into
main
Choose a base branch
from
init-dependency-sync
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Sync dependencies #889
Changes from all commits
Commits
Show all changes
18 commits
Select commit
Hold shift + click to select a range
2de80e5
schema/mysql: Add upgrade for dependency additions
nilmerg 2e083b1
add missing keys/fks
nilmerg 463e3c1
schema: add `last_state_change` to `redundancy_group_state`
nilmerg 028c570
mysql: Add affected_children and affects_children columns
nilmerg f9277dc
schema/mysql: add environment_id, remove duplicates
oxzi fb01132
schema/mysql: move dependency upgrades into schema.sql
oxzi df49a36
Dependency: Sync dependencies, redundancy group & their state
oxzi 8d2d369
Checkable: Add missing `total_children` field
yhabteab a3493c0
State: Add missing `affects_children` field
yhabteab 3d2c1e9
Schema: Refine all the changes & cleanup unnecessary indices & foreig…
yhabteab a647325
Schema: Add missing changes for PostgreSQL
yhabteab b440959
Enhance dependency syncs & add missing required fields
yhabteab 666aab7
Bump expected redis schema version to `6`
yhabteab 1edcd11
Bump expected mysql & psql schema version to `7` & `5`
yhabteab ae86b1a
schema: Set column of bytea20 storage type to `PLAIN`
yhabteab 9eb15d5
tests: Fix SLA tests
yhabteab b6beb30
Add integration tests for dependency syncs
yhabteab 277bb7b
Support dependency/redundancy group state checksum on the fly
yhabteab File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,97 @@ | ||
package v1 | ||
|
||
import ( | ||
"bytes" | ||
"github.com/google/go-cmp/cmp" | ||
"github.com/icinga/icinga-go-library/database" | ||
"github.com/icinga/icinga-go-library/types" | ||
) | ||
|
||
type Redundancygroup struct { | ||
EntityWithoutChecksum `json:",inline"` | ||
EnvironmentMeta `json:",inline"` | ||
DisplayName string `json:"display_name"` | ||
} | ||
|
||
// TableName implements [database.TableNamer]. | ||
func (r *Redundancygroup) TableName() string { | ||
return "redundancy_group" | ||
} | ||
|
||
type RedundancygroupState struct { | ||
EntityWithoutChecksum `json:",inline"` | ||
EnvironmentMeta `json:",inline"` | ||
RedundancyGroupId types.Binary `json:"redundancy_group_id"` | ||
Failed types.Bool `json:"failed"` | ||
IsReachable types.Bool `json:"is_reachable"` | ||
LastStateChange types.UnixMilli `json:"last_state_change"` | ||
} | ||
|
||
// TableName implements [database.TableNamer]. | ||
func (r *RedundancygroupState) TableName() string { | ||
return "redundancy_group_state" | ||
} | ||
|
||
// Equal implements the [contracts.Equaler] interface. | ||
func (r *RedundancygroupState) Equal(other any) bool { | ||
if other, ok := other.(*RedundancygroupState); ok { | ||
return bytes.Equal(r.RedundancyGroupId, other.RedundancyGroupId) && | ||
cmp.Equal(r.Failed, other.Failed) && | ||
cmp.Equal(r.IsReachable, other.IsReachable) && | ||
r.LastStateChange.Time().Equal(other.LastStateChange.Time()) | ||
} | ||
|
||
return false | ||
} | ||
|
||
type DependencyNode struct { | ||
EntityWithoutChecksum `json:",inline"` | ||
EnvironmentMeta `json:",inline"` | ||
HostId types.Binary `json:"host_id"` | ||
ServiceId types.Binary `json:"service_id"` | ||
RedundancyGroupId types.Binary `json:"redundancy_group_id"` | ||
} | ||
|
||
type DependencyEdgeState struct { | ||
EntityWithoutChecksum `json:",inline"` | ||
EnvironmentMeta `json:",inline"` | ||
Failed types.Bool `json:"failed"` | ||
} | ||
|
||
// Equal implements the [contracts.Equaler] interface. | ||
func (es *DependencyEdgeState) Equal(other any) bool { | ||
if other, ok := other.(*DependencyEdgeState); ok { | ||
return bytes.Equal(es.Id, other.Id) && cmp.Equal(es.Failed, other.Failed) | ||
} | ||
|
||
return false | ||
} | ||
|
||
type DependencyEdge struct { | ||
EntityWithoutChecksum `json:",inline"` | ||
EnvironmentMeta `json:",inline"` | ||
FromNodeId types.Binary `json:"from_node_id"` | ||
ToNodeId types.Binary `json:"to_node_id"` | ||
DependencyEdgeStateId types.Binary `json:"dependency_edge_state_id"` | ||
DisplayName string `json:"display_name"` | ||
} | ||
|
||
func NewRedundancygroup() database.Entity { | ||
return &Redundancygroup{} | ||
} | ||
|
||
func NewRedundancygroupState() database.Entity { | ||
return &RedundancygroupState{} | ||
} | ||
|
||
func NewDependencyNode() database.Entity { | ||
return &DependencyNode{} | ||
} | ||
|
||
func NewDependencyEdgeState() database.Entity { | ||
return &DependencyEdgeState{} | ||
} | ||
|
||
func NewDependencyEdge() database.Entity { | ||
return &DependencyEdge{} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'd rename this table to
redundancygroup
(andredundancygroup_state
respectively) for two reasons:icingadb/schema/mysql/schema.sql
Line 229 in a77498d
icingadb/schema/mysql/schema.sql
Line 395 in a77498d
icingadb/schema/mysql/schema.sql
Line 1027 in a77498d
icingadb/pkg/icingadb/v1/dependency.go
Lines 16 to 19 in 8fdf0a2
Footnotes
I presume that's currently necessary due to the inconsistency between Redis (
icinga:redundancygroup
, i.e. no separator inredundancygroup
) and SQL (redundancy_group
, i.e. with a separator), otherwise the Go type could also be namedRedundancyGroup
. ↩There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
No, it cannot! The Redis keys are generated dynamically based on the Go type name and that would result in
icinga:redundancy:group
which does not exist in Icinga 2.There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
"Otherwise" as in "if it actually was
icinga:redundancy:group
andredundancy_group
"