Skip to content

Commit

Permalink
Sync init containers
Browse files Browse the repository at this point in the history
  • Loading branch information
jhoxhaa committed Sep 25, 2024
1 parent d9225fe commit 394fc98
Show file tree
Hide file tree
Showing 2 changed files with 29 additions and 9 deletions.
21 changes: 12 additions & 9 deletions pkg/schema/v1/pod.go
Original file line number Diff line number Diff line change
Expand Up @@ -37,15 +37,16 @@ type Pod struct {
Qos sql.NullString
RestartPolicy string
Yaml string
Conditions []PodCondition `db:"-"`
Containers []*Container `db:"-"`
Owners []PodOwner `db:"-"`
Labels []Label `db:"-"`
PodLabels []PodLabel `db:"-"`
Annotations []Annotation `db:"-"`
PodAnnotations []PodAnnotation `db:"-"`
Pvcs []PodPvc `db:"-"`
Volumes []PodVolume `db:"-"`
Conditions []PodCondition `db:"-"`
Containers []*Container `db:"-"`
InitContainers []*InitContainer `db:"-"`
Owners []PodOwner `db:"-"`
Labels []Label `db:"-"`
PodLabels []PodLabel `db:"-"`
Annotations []Annotation `db:"-"`
PodAnnotations []PodAnnotation `db:"-"`
Pvcs []PodPvc `db:"-"`
Volumes []PodVolume `db:"-"`
factory *PodFactory
}

Expand Down Expand Up @@ -137,6 +138,7 @@ func (p *Pod) Obtain(k8s kmetav1.Object) {
}

p.Containers = NewContainers[Container](p, pod.Spec.Containers, pod.Status.ContainerStatuses, NewContainer)
p.InitContainers = NewContainers[InitContainer](p, pod.Spec.InitContainers, pod.Status.InitContainerStatuses, NewInitContainer)

p.IcingaState, p.IcingaStateReason = p.getIcingaState(pod)

Expand Down Expand Up @@ -399,6 +401,7 @@ func (p *Pod) Relations() []database.Relation {
return []database.Relation{
database.HasMany(p.Conditions, fk),
database.HasMany(p.Containers, database.WithoutCascadeDelete()),
database.HasMany(p.InitContainers, database.WithoutCascadeDelete()),
database.HasMany(p.Owners, fk),
database.HasMany(p.Labels, database.WithoutCascadeDelete()),
database.HasMany(p.PodLabels, fk),
Expand Down
17 changes: 17 additions & 0 deletions schema/mysql/schema.sql
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,23 @@ CREATE TABLE container (
PRIMARY KEY (uuid)
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_bin;

CREATE TABLE init_container (
uuid binary(16) NOT NULL,
pod_uuid binary(16) NOT NULL,
name varchar(63) COLLATE utf8mb4_unicode_ci NOT NULL,
image varchar(255) COLLATE utf8mb4_unicode_ci NOT NULL,
image_pull_policy enum('Always', 'Never', 'IfNotPresent') COLLATE utf8mb4_unicode_ci NULL DEFAULT NULL,
cpu_limits bigint unsigned NULL DEFAULT NULL,
cpu_requests bigint unsigned NULL DEFAULT NULL,
memory_limits bigint unsigned NULL DEFAULT NULL,
memory_requests bigint unsigned NULL DEFAULT NULL,
state enum('Waiting', 'Running', 'Terminated') COLLATE utf8mb4_unicode_ci NULL DEFAULT NULL,
state_details longtext NULL DEFAULT NULL,
icinga_state enum('unknown', 'pending', 'ok', 'warning', 'critical') COLLATE utf8mb4_unicode_ci NOT NULL,
icinga_state_reason text NULL DEFAULT NULL,
PRIMARY KEY (uuid)
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_bin;

CREATE TABLE container_device (
container_uuid binary(16) NOT NULL,
pod_uuid binary(16) NOT NULL,
Expand Down

0 comments on commit 394fc98

Please sign in to comment.