Skip to content

Commit

Permalink
Merge pull request #84 from Icinga/add-owner-id
Browse files Browse the repository at this point in the history
Add owner_uuid
  • Loading branch information
lippserd authored Jun 3, 2024
2 parents 9c71f6a + cbee535 commit b282be0
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 6 deletions.
10 changes: 6 additions & 4 deletions pkg/schema/v1/pod.go
Original file line number Diff line number Diff line change
Expand Up @@ -68,6 +68,7 @@ type PodLabel struct {

type PodOwner struct {
PodUuid types.UUID
OwnerUuid types.UUID
Kind string
Name string
Uid ktypes.UID
Expand Down Expand Up @@ -226,10 +227,11 @@ func (p *Pod) Obtain(k8s kmetav1.Object) {
controller = *ownerReference.Controller
}
p.Owners = append(p.Owners, PodOwner{
PodUuid: p.Uuid,
Kind: strcase.Snake(ownerReference.Kind),
Name: ownerReference.Name,
Uid: ownerReference.UID,
PodUuid: p.Uuid,
OwnerUuid: EnsureUUID(p.Uid),
Kind: strcase.Snake(ownerReference.Kind),
Name: ownerReference.Name,
Uid: ownerReference.UID,
BlockOwnerDeletion: types.Bool{
Bool: blockOwnerDeletion,
Valid: true,
Expand Down
2 changes: 2 additions & 0 deletions pkg/schema/v1/replica_set.go
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,7 @@ type ReplicaSetCondition struct {

type ReplicaSetOwner struct {
ReplicaSetUuid types.UUID
OwnerUuid types.UUID
Kind string
Name string
Uid ktypes.UID
Expand Down Expand Up @@ -97,6 +98,7 @@ func (r *ReplicaSet) Obtain(k8s kmetav1.Object) {
}
r.Owners = append(r.Owners, ReplicaSetOwner{
ReplicaSetUuid: r.Uuid,
OwnerUuid: EnsureUUID(r.Uid),
Kind: strcase.Snake(ownerReference.Kind),
Name: ownerReference.Name,
Uid: ownerReference.UID,
Expand Down
6 changes: 4 additions & 2 deletions schema/mysql/schema.sql
Original file line number Diff line number Diff line change
Expand Up @@ -106,12 +106,13 @@ CREATE TABLE pod_condition (

CREATE TABLE pod_owner (
pod_uuid binary(16) NOT NULL,
owner_uuid binary(16) NOT NULL,
kind enum('daemon_set', 'node', 'replica_set', 'stateful_set', 'job') COLLATE utf8mb4_unicode_ci NOT NULL,
name varchar(253) COLLATE utf8mb4_unicode_ci NOT NULL,
uid varchar(255) COLLATE utf8mb4_unicode_ci NOT NULL,
controller enum('n', 'y') COLLATE utf8mb4_unicode_ci NOT NULL,
block_owner_deletion enum('n', 'y') COLLATE utf8mb4_unicode_ci NOT NULL,
PRIMARY KEY (pod_uuid, uid)
PRIMARY KEY (pod_uuid, owner_uuid)
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_bin;

CREATE TABLE pod_pvc (
Expand Down Expand Up @@ -391,12 +392,13 @@ CREATE TABLE replica_set_condition (

CREATE TABLE replica_set_owner (
replica_set_uuid binary(16) NOT NULL,
owner_uuid binary(16) NOT NULL,
kind enum('deployment') COLLATE utf8mb4_unicode_ci NOT NULL,
name varchar(253) COLLATE utf8mb4_unicode_ci NOT NULL,
uid varchar(255) COLLATE utf8mb4_unicode_ci NOT NULL,
controller enum('n', 'y') COLLATE utf8mb4_unicode_ci NOT NULL,
block_owner_deletion enum('n', 'y') COLLATE utf8mb4_unicode_ci NOT NULL,
PRIMARY KEY (replica_set_uuid, uid)
PRIMARY KEY (replica_set_uuid, owner_uuid)
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_bin;

CREATE TABLE daemon_set (
Expand Down

0 comments on commit b282be0

Please sign in to comment.