From 14abb6a8b116e036f44bdacb852f49d3f6fe53e4 Mon Sep 17 00:00:00 2001 From: Jonada Hoxha Date: Tue, 28 May 2024 22:50:41 +0200 Subject: [PATCH] Drop IDs in favor of UUIDs --- cmd/icinga-kubernetes/main.go | 2 +- pkg/schema/v1/config_map.go | 30 ++- pkg/schema/v1/container.go | 62 +++--- pkg/schema/v1/cron_job.go | 17 +- pkg/schema/v1/daemon_set.go | 21 +- pkg/schema/v1/data.go | 6 +- pkg/schema/v1/deployment.go | 22 +- pkg/schema/v1/endpoint.go | 95 +++++---- pkg/schema/v1/event.go | 3 - pkg/schema/v1/ingress.go | 115 ++++++----- pkg/schema/v1/job.go | 21 +- pkg/schema/v1/label.go | 6 +- pkg/schema/v1/namespace.go | 21 +- pkg/schema/v1/node.go | 25 +-- pkg/schema/v1/persistent_volume.go | 21 +- pkg/schema/v1/pod.go | 61 +++--- pkg/schema/v1/pvc.go | 21 +- pkg/schema/v1/replica_set.go | 31 ++- pkg/schema/v1/secret.go | 29 ++- pkg/schema/v1/selector.go | 6 +- pkg/schema/v1/service.go | 37 ++-- pkg/schema/v1/stateful_set.go | 42 ++-- schema/mysql/schema.sql | 312 ++++++++++++++--------------- 23 files changed, 481 insertions(+), 525 deletions(-) diff --git a/cmd/icinga-kubernetes/main.go b/cmd/icinga-kubernetes/main.go index 008c6281..886c3480 100644 --- a/cmd/icinga-kubernetes/main.go +++ b/cmd/icinga-kubernetes/main.go @@ -185,7 +185,7 @@ func main() { _, err := db.CleanupOlderThan( ctx, database.CleanupStmt{ Table: "event", - PK: "id", + PK: "uuid", Column: "created", }, 5000, olderThan, ) diff --git a/pkg/schema/v1/config_map.go b/pkg/schema/v1/config_map.go index afeb181b..6e40a02c 100644 --- a/pkg/schema/v1/config_map.go +++ b/pkg/schema/v1/config_map.go @@ -2,7 +2,6 @@ package v1 import ( "github.com/icinga/icinga-go-library/types" - "github.com/icinga/icinga-go-library/utils" "github.com/icinga/icinga-kubernetes/pkg/database" kcorev1 "k8s.io/api/core/v1" kmetav1 "k8s.io/apimachinery/pkg/apis/meta/v1" @@ -11,7 +10,6 @@ import ( type ConfigMap struct { Meta - Id types.Binary Immutable types.Bool Data []Data `db:"-"` ConfigMapsData []ConfigMapData `db:"-"` @@ -20,13 +18,13 @@ type ConfigMap struct { } type ConfigMapData struct { - ConfigMapId types.Binary - DataId types.Binary + ConfigMapUuid types.UUID + DataUuid types.UUID } type ConfigMapLabel struct { - ConfigMapId types.Binary - LabelId types.Binary + ConfigMapUuid types.UUID + LabelUuid types.UUID } func NewConfigMap() Resource { @@ -38,8 +36,6 @@ func (c *ConfigMap) Obtain(k8s kmetav1.Object) { configMap := k8s.(*kcorev1.ConfigMap) - c.Id = utils.Checksum(configMap.Namespace + "/" + configMap.Name) - var immutable bool if configMap.Immutable != nil { immutable = *configMap.Immutable @@ -50,34 +46,34 @@ func (c *ConfigMap) Obtain(k8s kmetav1.Object) { } for dataName, dataValue := range configMap.Data { - dataId := utils.Checksum(dataName + ":" + dataValue) + dataUuid := NewUUID(c.Uuid, strings.ToLower(dataName+":"+dataValue)) c.Data = append(c.Data, Data{ - Id: dataId, + Uuid: dataUuid, Name: dataName, Value: dataValue, }) c.ConfigMapsData = append(c.ConfigMapsData, ConfigMapData{ - ConfigMapId: c.Id, - DataId: dataId, + ConfigMapUuid: c.Uuid, + DataUuid: dataUuid, }) } for labelName, labelValue := range configMap.Labels { - labelId := utils.Checksum(strings.ToLower(labelName + ":" + labelValue)) + labelUuid := NewUUID(c.Uuid, strings.ToLower(labelName+":"+labelValue)) c.Labels = append(c.Labels, Label{ - Id: labelId, + Uuid: labelUuid, Name: labelName, Value: labelValue, }) c.ConfigMapLabels = append(c.ConfigMapLabels, ConfigMapLabel{ - ConfigMapId: c.Id, - LabelId: labelId, + ConfigMapUuid: c.Uuid, + LabelUuid: labelUuid, }) } } func (c *ConfigMap) Relations() []database.Relation { - fk := database.WithForeignKey("config_map_id") + fk := database.WithForeignKey("config_map_uuid") return []database.Relation{ database.HasMany(c.Labels, database.WithoutCascadeDelete()), diff --git a/pkg/schema/v1/container.go b/pkg/schema/v1/container.go index 1c8c92e4..249a479d 100644 --- a/pkg/schema/v1/container.go +++ b/pkg/schema/v1/container.go @@ -32,8 +32,8 @@ const ( ) type ContainerMeta struct { - Id types.Binary `db:"id"` - PodId types.Binary `db:"pod_id"` + Uuid types.UUID `db:"uuid"` + PodUuid types.UUID `db:"pod_uuid"` } type Container struct { @@ -68,19 +68,19 @@ func (c *Container) Relations() []database.Relation { } type ContainerDevice struct { - ContainerId types.Binary - PodId types.Binary - Name string - Path string + ContainerUuid types.UUID + PodUuid types.UUID + Name string + Path string } type ContainerMount struct { - ContainerId types.Binary - PodId types.Binary - VolumeName string - Path string - SubPath sql.NullString - ReadOnly types.Bool + ContainerUuid types.UUID + PodUuid types.UUID + VolumeName string + Path string + SubPath sql.NullString + ReadOnly types.Bool } type ContainerLogMeta struct { @@ -89,8 +89,8 @@ type ContainerLogMeta struct { } type ContainerLog struct { - PodId types.Binary `db:"pod_id"` - ContainerId types.Binary `db:"container_id"` + PodUuid types.UUID `db:"pod_uuid"` + ContainerUuid types.UUID `db:"container_uuid"` ContainerLogMeta Namespace string `db:"-"` @@ -163,24 +163,24 @@ func SyncContainers(ctx context.Context, db *database.Database, g *errgroup.Grou scheduler.StartAsync() defer scheduler.Stop() - query := db.BuildSelectStmt(&Container{}, ContainerMeta{}) + ` WHERE pod_id=:pod_id` + query := db.BuildSelectStmt(&Container{}, ContainerMeta{}) + ` WHERE pod_uuid=:pod_uuid` for { select { case <-ctx.Done(): return ctx.Err() - case podId, ok := <-deletePods: + case podUuid, ok := <-deletePods: if !ok { return nil } - meta := &ContainerMeta{PodId: podId.([]byte)} - if _, ok := deletedPodIds[meta.PodId.String()]; ok { + meta := &ContainerMeta{PodUuid: podUuid.(types.UUID)} + if _, ok := deletedPodIds[meta.PodUuid.String()]; ok { // Due to the recursive relation resolution in the `DB#DeleteStreamed()` method, we may get the // same pod ID multiple times since they all share the same `on success` handler. break } - deletedPodIds[meta.PodId.String()] = true + deletedPodIds[meta.PodUuid.String()] = true entities, errs := db.YieldAll(ctx, func() (interface{}, error) { return &Container{}, nil @@ -201,18 +201,18 @@ func SyncContainers(ctx context.Context, db *database.Database, g *errgroup.Grou container := e.(*Container) select { - case containerIds <- container.Id: + case containerIds <- container.Uuid: case <-ctx.Done(): return ctx.Err() } - err := scheduler.RemoveByTag(container.Id.String()) + err := scheduler.RemoveByTag(container.Uuid.String()) if err != nil && !errors.Is(err, gocron.ErrJobNotFoundWithTag) { return err } containerLogsMu.Lock() - delete(containerLogs, container.Id.String()) + delete(containerLogs, container.Uuid.String()) containerLogsMu.Unlock() } } @@ -224,42 +224,42 @@ func SyncContainers(ctx context.Context, db *database.Database, g *errgroup.Grou pod := e.(*Pod) - delete(deletedPodIds, pod.Id.String()) + delete(deletedPodIds, pod.Uuid.String()) for _, container := range pod.Containers { - _, err := scheduler.FindJobsByTag(container.Id.String()) + _, err := scheduler.FindJobsByTag(container.Uuid.String()) if err != nil && !errors.Is(err, gocron.ErrJobNotFoundWithTag) { return err } if container.Started.Bool && err != nil { containerLog := &ContainerLog{ - ContainerId: container.Id, - PodId: container.PodId, + ContainerUuid: container.Uuid, + PodUuid: container.PodUuid, ContainerName: container.Name, Namespace: pod.Namespace, PodName: pod.Name, } containerLogsMu.Lock() - if cl, ok := containerLogs[container.Id.String()]; ok { + if cl, ok := containerLogs[container.Uuid.String()]; ok { containerLog.Logs = cl.Logs } containerLogsMu.Unlock() - scheduler.Every(ScheduleInterval.String()).Tag(container.Id.String()) + scheduler.Every(ScheduleInterval.String()).Tag(container.Uuid.String()) _, err = scheduler.Do(containerLog.syncContainerLogs, ctx, pod.factory.clientset, db) if err != nil { return err } } else if err == nil { - err := scheduler.RemoveByTag(container.Id.String()) + err := scheduler.RemoveByTag(container.Uuid.String()) if err != nil { return err } containerLogsMu.Lock() - delete(containerLogs, container.Id.String()) + delete(containerLogs, container.Uuid.String()) containerLogsMu.Unlock() } } @@ -293,7 +293,7 @@ func warmup(ctx context.Context, db *database.Database) error { } containerLog := e.(*ContainerLog) - containerLogs[containerLog.ContainerId.String()] = *containerLog + containerLogs[containerLog.ContainerUuid.String()] = *containerLog } } }) diff --git a/pkg/schema/v1/cron_job.go b/pkg/schema/v1/cron_job.go index e982422e..37a73be2 100644 --- a/pkg/schema/v1/cron_job.go +++ b/pkg/schema/v1/cron_job.go @@ -2,7 +2,6 @@ package v1 import ( "github.com/icinga/icinga-go-library/types" - "github.com/icinga/icinga-go-library/utils" "github.com/icinga/icinga-kubernetes/pkg/database" kbatchv1 "k8s.io/api/batch/v1" kmetav1 "k8s.io/apimachinery/pkg/apis/meta/v1" @@ -11,7 +10,6 @@ import ( type CronJob struct { Meta - Id types.Binary Schedule string Timezone string StartingDeadlineSeconds int64 @@ -27,8 +25,8 @@ type CronJob struct { } type CronJobLabel struct { - CronJobId types.Binary - LabelId types.Binary + CronJobUuid types.UUID + LabelUuid types.UUID } func NewCronJob() Resource { @@ -68,7 +66,6 @@ func (c *CronJob) Obtain(k8s kmetav1.Object) { c.LastSuccessfulTime = types.UnixMilli(cronJob.Status.LastSuccessfulTime.Time) } - c.Id = utils.Checksum(c.Namespace + "/" + c.Name) c.Schedule = cronJob.Spec.Schedule c.Timezone = timeZone c.StartingDeadlineSeconds = startingDeadlineSeconds @@ -79,21 +76,21 @@ func (c *CronJob) Obtain(k8s kmetav1.Object) { c.Active = int32(len(cronJob.Status.Active)) for labelName, labelValue := range cronJob.Labels { - labelId := utils.Checksum(strings.ToLower(labelName + ":" + labelValue)) + labelUuid := NewUUID(c.Uuid, strings.ToLower(labelName+":"+labelValue)) c.Labels = append(c.Labels, Label{ - Id: labelId, + Uuid: labelUuid, Name: labelName, Value: labelValue, }) c.CronJobLabels = append(c.CronJobLabels, CronJobLabel{ - CronJobId: c.Id, - LabelId: labelId, + CronJobUuid: c.Uuid, + LabelUuid: labelUuid, }) } } func (c *CronJob) Relations() []database.Relation { - fk := database.WithForeignKey("cron_job_id") + fk := database.WithForeignKey("cron_job_uuid") return []database.Relation{ database.HasMany(c.Labels, database.WithoutCascadeDelete()), diff --git a/pkg/schema/v1/daemon_set.go b/pkg/schema/v1/daemon_set.go index 14eed285..70787cf4 100644 --- a/pkg/schema/v1/daemon_set.go +++ b/pkg/schema/v1/daemon_set.go @@ -2,7 +2,6 @@ package v1 import ( "github.com/icinga/icinga-go-library/types" - "github.com/icinga/icinga-go-library/utils" "github.com/icinga/icinga-kubernetes/pkg/database" "github.com/icinga/icinga-kubernetes/pkg/strcase" kappsv1 "k8s.io/api/apps/v1" @@ -12,7 +11,6 @@ import ( type DaemonSet struct { Meta - Id types.Binary UpdateStrategy string MinReadySeconds int32 DesiredNumberScheduled int32 @@ -28,7 +26,7 @@ type DaemonSet struct { } type DaemonSetCondition struct { - DaemonSetId types.Binary + DaemonSetUuid types.UUID Type string Status string LastTransition types.UnixMilli @@ -37,8 +35,8 @@ type DaemonSetCondition struct { } type DaemonSetLabel struct { - DaemonSetId types.Binary - LabelId types.Binary + DaemonSetUuid types.UUID + LabelUuid types.UUID } func NewDaemonSet() Resource { @@ -50,7 +48,6 @@ func (d *DaemonSet) Obtain(k8s kmetav1.Object) { daemonSet := k8s.(*kappsv1.DaemonSet) - d.Id = utils.Checksum(daemonSet.Namespace + "/" + daemonSet.Name) d.UpdateStrategy = strcase.Snake(string(daemonSet.Spec.UpdateStrategy.Type)) d.MinReadySeconds = daemonSet.Spec.MinReadySeconds d.DesiredNumberScheduled = daemonSet.Status.DesiredNumberScheduled @@ -63,7 +60,7 @@ func (d *DaemonSet) Obtain(k8s kmetav1.Object) { for _, condition := range daemonSet.Status.Conditions { d.Conditions = append(d.Conditions, DaemonSetCondition{ - DaemonSetId: d.Id, + DaemonSetUuid: d.Uuid, Type: string(condition.Type), Status: string(condition.Status), LastTransition: types.UnixMilli(condition.LastTransitionTime.Time), @@ -73,21 +70,21 @@ func (d *DaemonSet) Obtain(k8s kmetav1.Object) { } for labelName, labelValue := range daemonSet.Labels { - labelId := utils.Checksum(strings.ToLower(labelName + ":" + labelValue)) + labelUuid := NewUUID(d.Uuid, strings.ToLower(labelName+":"+labelValue)) d.Labels = append(d.Labels, Label{ - Id: labelId, + Uuid: labelUuid, Name: labelName, Value: labelValue, }) d.DaemonSetLabels = append(d.DaemonSetLabels, DaemonSetLabel{ - DaemonSetId: d.Id, - LabelId: labelId, + DaemonSetUuid: d.Uuid, + LabelUuid: labelUuid, }) } } func (d *DaemonSet) Relations() []database.Relation { - fk := database.WithForeignKey("daemon_set_id") + fk := database.WithForeignKey("daemon_set_uuid") return []database.Relation{ database.HasMany(d.Conditions, fk), diff --git a/pkg/schema/v1/data.go b/pkg/schema/v1/data.go index 500cf2e0..e0094b9d 100644 --- a/pkg/schema/v1/data.go +++ b/pkg/schema/v1/data.go @@ -1,9 +1,11 @@ package v1 -import "github.com/icinga/icinga-go-library/types" +import ( + "github.com/icinga/icinga-go-library/types" +) type Data struct { - Id types.Binary + Uuid types.UUID Name string Value string } diff --git a/pkg/schema/v1/deployment.go b/pkg/schema/v1/deployment.go index 31183638..fb34e579 100644 --- a/pkg/schema/v1/deployment.go +++ b/pkg/schema/v1/deployment.go @@ -2,7 +2,6 @@ package v1 import ( "github.com/icinga/icinga-go-library/types" - "github.com/icinga/icinga-go-library/utils" "github.com/icinga/icinga-kubernetes/pkg/database" "github.com/icinga/icinga-kubernetes/pkg/strcase" kappsv1 "k8s.io/api/apps/v1" @@ -12,7 +11,6 @@ import ( type Deployment struct { Meta - Id types.Binary DesiredReplicas int32 Strategy string MinReadySeconds int32 @@ -29,7 +27,7 @@ type Deployment struct { } type DeploymentCondition struct { - DeploymentId types.Binary + DeploymentUuid types.UUID Type string Status string LastUpdate types.UnixMilli @@ -39,8 +37,8 @@ type DeploymentCondition struct { } type DeploymentLabel struct { - DeploymentId types.Binary - LabelId types.Binary + DeploymentUuid types.UUID + LabelUuid types.UUID } func NewDeployment() Resource { @@ -59,7 +57,7 @@ func (d *Deployment) Obtain(k8s kmetav1.Object) { if deployment.Spec.ProgressDeadlineSeconds != nil { progressDeadlineSeconds = *deployment.Spec.ProgressDeadlineSeconds } - d.Id = utils.Checksum(deployment.Namespace + "/" + deployment.Name) + d.DesiredReplicas = replicas d.Strategy = strcase.Snake(string(deployment.Spec.Strategy.Type)) d.MinReadySeconds = deployment.Spec.MinReadySeconds @@ -76,7 +74,7 @@ func (d *Deployment) Obtain(k8s kmetav1.Object) { for _, condition := range deployment.Status.Conditions { d.Conditions = append(d.Conditions, DeploymentCondition{ - DeploymentId: d.Id, + DeploymentUuid: d.Uuid, Type: strcase.Snake(string(condition.Type)), Status: string(condition.Status), LastUpdate: types.UnixMilli(condition.LastUpdateTime.Time), @@ -87,21 +85,21 @@ func (d *Deployment) Obtain(k8s kmetav1.Object) { } for labelName, labelValue := range deployment.Labels { - labelId := utils.Checksum(strings.ToLower(labelName + ":" + labelValue)) + labelUuid := NewUUID(d.Uuid, strings.ToLower(labelName+":"+labelValue)) d.Labels = append(d.Labels, Label{ - Id: labelId, + Uuid: labelUuid, Name: labelName, Value: labelValue, }) d.DeploymentLabels = append(d.DeploymentLabels, DeploymentLabel{ - DeploymentId: d.Id, - LabelId: labelId, + DeploymentUuid: d.Uuid, + LabelUuid: labelUuid, }) } } func (d *Deployment) Relations() []database.Relation { - fk := database.WithForeignKey("deployment_id") + fk := database.WithForeignKey("deployment_uuid") return []database.Relation{ database.HasMany(d.Conditions, fk), diff --git a/pkg/schema/v1/endpoint.go b/pkg/schema/v1/endpoint.go index 9e07aa89..8b3c69e5 100644 --- a/pkg/schema/v1/endpoint.go +++ b/pkg/schema/v1/endpoint.go @@ -3,7 +3,6 @@ package v1 import ( "database/sql" "github.com/icinga/icinga-go-library/types" - "github.com/icinga/icinga-go-library/utils" "github.com/icinga/icinga-kubernetes/pkg/database" v1 "k8s.io/api/core/v1" kdiscoveryv1 "k8s.io/api/discovery/v1" @@ -14,7 +13,6 @@ import ( type EndpointSlice struct { Meta - Id types.Binary AddressType string Endpoints []Endpoint `db:"-"` Labels []Label `db:"-"` @@ -23,33 +21,33 @@ type EndpointSlice struct { } type EndpointSliceLabel struct { - EndpointSliceId types.Binary - LabelId types.Binary + EndpointSliceUuid types.UUID + LabelUuid types.UUID } type Endpoint struct { - Id types.Binary - EndpointSliceId types.Binary - HostName string - NodeName string - Ready types.Bool - Serving types.Bool - Terminating types.Bool - Address string - PortName string - Protocol string - Port int32 - AppProtocol string + Uuid types.UUID + EndpointSliceUuid types.UUID + HostName string + NodeName string + Ready types.Bool + Serving types.Bool + Terminating types.Bool + Address string + PortName string + Protocol string + Port int32 + AppProtocol string } type EndpointTargetRef struct { - EndpointSliceId types.Binary - Kind sql.NullString - Namespace string - Name string - Uid ktypes.UID - ApiVersion string - ResourceVersion string + EndpointSliceUuid types.UUID + Kind sql.NullString + Namespace string + Name string + Uid ktypes.UID + ApiVersion string + ResourceVersion string } func NewEndpointSlice() Resource { @@ -61,19 +59,18 @@ func (e *EndpointSlice) Obtain(k8s kmetav1.Object) { endpointSlice := k8s.(*kdiscoveryv1.EndpointSlice) - e.Id = utils.Checksum(strings.ToLower(endpointSlice.Namespace + "/" + endpointSlice.Name)) e.AddressType = string(endpointSlice.AddressType) for labelName, labelValue := range endpointSlice.Labels { - labelId := utils.Checksum(strings.ToLower(labelName + ":" + labelValue)) + labelUuid := NewUUID(e.Uuid, strings.ToLower(labelName+":"+labelValue)) e.Labels = append(e.Labels, Label{ - Id: labelId, + Uuid: labelUuid, Name: labelName, Value: labelValue, }) e.EndpointLabels = append(e.EndpointLabels, EndpointSliceLabel{ - EndpointSliceId: e.Id, - LabelId: labelId, + EndpointSliceUuid: e.Uuid, + LabelUuid: labelUuid, }) } @@ -114,20 +111,20 @@ func (e *EndpointSlice) Obtain(k8s kmetav1.Object) { appProtocol = *endpointPort.AppProtocol } for _, address := range endpoint.Addresses { - endpointId := utils.Checksum(e.Id.String() + name + address + string(port)) + endpointUuid := NewUUID(e.Uuid, name+address+string(port)) e.Endpoints = append(e.Endpoints, Endpoint{ - Id: endpointId, - EndpointSliceId: e.Id, - HostName: hostName, - NodeName: nodeName, - Ready: ready, - Serving: serving, - Terminating: terminating, - PortName: name, - Protocol: protocol, - Port: port, - AppProtocol: appProtocol, - Address: address, + Uuid: endpointUuid, + EndpointSliceUuid: e.Uuid, + HostName: hostName, + NodeName: nodeName, + Ready: ready, + Serving: serving, + Terminating: terminating, + PortName: name, + Protocol: protocol, + Port: port, + AppProtocol: appProtocol, + Address: address, }) } } @@ -141,19 +138,19 @@ func (e *EndpointSlice) Obtain(k8s kmetav1.Object) { kind.Valid = true } e.EndpointTargetRefs = append(e.EndpointTargetRefs, EndpointTargetRef{ - EndpointSliceId: e.Id, - Kind: kind, - Namespace: targetRef.Namespace, - Name: targetRef.Name, - Uid: targetRef.UID, - ApiVersion: targetRef.APIVersion, - ResourceVersion: targetRef.ResourceVersion, + EndpointSliceUuid: e.Uuid, + Kind: kind, + Namespace: targetRef.Namespace, + Name: targetRef.Name, + Uid: targetRef.UID, + ApiVersion: targetRef.APIVersion, + ResourceVersion: targetRef.ResourceVersion, }) } } func (e *EndpointSlice) Relations() []database.Relation { - fk := database.WithForeignKey("endpoint_slice_id") + fk := database.WithForeignKey("endpoint_slice_uuid") return []database.Relation{ database.HasMany(e.Endpoints, fk), diff --git a/pkg/schema/v1/event.go b/pkg/schema/v1/event.go index db2754f7..44930800 100644 --- a/pkg/schema/v1/event.go +++ b/pkg/schema/v1/event.go @@ -2,14 +2,12 @@ package v1 import ( "github.com/icinga/icinga-go-library/types" - "github.com/icinga/icinga-go-library/utils" keventsv1 "k8s.io/api/events/v1" kmetav1 "k8s.io/apimachinery/pkg/apis/meta/v1" ) type Event struct { Meta - Id types.Binary ReportingController string ReportingInstance string Action string @@ -33,7 +31,6 @@ func (e *Event) Obtain(k8s kmetav1.Object) { event := k8s.(*keventsv1.Event) - e.Id = utils.Checksum(event.Namespace + "/" + event.Name) e.ReportingController = event.ReportingController e.ReportingInstance = event.ReportingInstance e.Action = event.Action diff --git a/pkg/schema/v1/ingress.go b/pkg/schema/v1/ingress.go index 50e72bea..5652be10 100644 --- a/pkg/schema/v1/ingress.go +++ b/pkg/schema/v1/ingress.go @@ -3,7 +3,6 @@ package v1 import ( "database/sql" "github.com/icinga/icinga-go-library/types" - "github.com/icinga/icinga-go-library/utils" "github.com/icinga/icinga-kubernetes/pkg/database" networkingv1 "k8s.io/api/networking/v1" kmetav1 "k8s.io/apimachinery/pkg/apis/meta/v1" @@ -11,7 +10,6 @@ import ( type Ingress struct { Meta - Id types.Binary IngressTls []IngressTls `db:"-"` IngressBackendService []IngressBackendService `db:"-"` IngressBackendResource []IngressBackendResource `db:"-"` @@ -19,36 +17,36 @@ type Ingress struct { } type IngressTls struct { - IngressId types.Binary - TlsHost string - TlsSecret string + IngressUuid types.UUID + TlsHost string + TlsSecret string } type IngressBackendService struct { - ServiceId types.Binary - IngressId types.Binary - IngressRuleId types.Binary + ServiceUuid types.UUID + IngressUuid types.UUID + IngressRuleUuid types.UUID ServiceName string ServicePortName string ServicePortNumber int32 } type IngressBackendResource struct { - ResourceId types.Binary - IngressId types.Binary - IngressRuleId types.Binary - ApiGroup sql.NullString - Kind string - Name string + ResourceUuid types.UUID + IngressUuid types.UUID + IngressRuleUuid types.UUID + ApiGroup sql.NullString + Kind string + Name string } type IngressRule struct { - Id types.Binary - BackendId types.Binary - IngressId types.Binary - Host string - Path string - PathType sql.NullString + Uuid types.UUID + BackendUuid types.UUID + IngressUuid types.UUID + Host string + Path string + PathType sql.NullString } func NewIngress() Resource { @@ -60,40 +58,39 @@ func (i *Ingress) Obtain(k8s kmetav1.Object) { ingress := k8s.(*networkingv1.Ingress) - i.Id = utils.Checksum(i.Namespace + "/" + i.Name) for _, tls := range ingress.Spec.TLS { for _, host := range tls.Hosts { i.IngressTls = append(i.IngressTls, IngressTls{ - IngressId: i.Id, - TlsHost: host, - TlsSecret: tls.SecretName, + IngressUuid: i.Uuid, + TlsHost: host, + TlsSecret: tls.SecretName, }) } } if ingress.Spec.DefaultBackend != nil { if ingress.Spec.DefaultBackend.Service != nil { - serviceId := utils.Checksum(i.Namespace + ingress.Spec.DefaultBackend.Service.Name + ingress.Spec.DefaultBackend.Service.Port.Name) + serviceUuid := NewUUID(i.Uuid, ingress.Spec.DefaultBackend.Service.Name+ingress.Spec.DefaultBackend.Service.Port.Name) i.IngressBackendService = append(i.IngressBackendService, IngressBackendService{ - ServiceId: serviceId, - IngressId: i.Id, + ServiceUuid: serviceUuid, + IngressUuid: i.Uuid, ServiceName: ingress.Spec.DefaultBackend.Service.Name, ServicePortName: ingress.Spec.DefaultBackend.Service.Port.Name, ServicePortNumber: ingress.Spec.DefaultBackend.Service.Port.Number, }) } if ingress.Spec.DefaultBackend.Resource != nil { - resourceId := utils.Checksum(i.Namespace + ingress.Spec.DefaultBackend.Resource.Kind + ingress.Spec.DefaultBackend.Resource.Name) + resourceUuid := NewUUID(i.Uuid, ingress.Spec.DefaultBackend.Resource.Kind+ingress.Spec.DefaultBackend.Resource.Name) var apiGroup sql.NullString if ingress.Spec.DefaultBackend.Resource.APIGroup != nil { apiGroup.String = *ingress.Spec.DefaultBackend.Resource.APIGroup apiGroup.Valid = true i.IngressBackendResource = append(i.IngressBackendResource, IngressBackendResource{ - ResourceId: resourceId, - IngressId: i.Id, - ApiGroup: apiGroup, - Kind: ingress.Spec.DefaultBackend.Resource.Kind, - Name: ingress.Spec.DefaultBackend.Resource.Name, + ResourceUuid: resourceUuid, + IngressUuid: i.Uuid, + ApiGroup: apiGroup, + Kind: ingress.Spec.DefaultBackend.Resource.Kind, + Name: ingress.Spec.DefaultBackend.Resource.Name, }) } } @@ -111,47 +108,47 @@ func (i *Ingress) Obtain(k8s kmetav1.Object) { pathType.Valid = true } if ruleValue.Backend.Service != nil { - ingressRuleId := utils.Checksum(string(i.Id) + rules.Host + ruleValue.Path + ruleValue.Backend.Service.Name) - serviceId := utils.Checksum(string(ingressRuleId) + i.Namespace + ruleValue.Backend.Service.Name) + ingressRuleUuid := NewUUID(i.Uuid, rules.Host+ruleValue.Path+ruleValue.Backend.Service.Name) + serviceUuid := NewUUID(ingressRuleUuid, ruleValue.Backend.Service.Name) i.IngressBackendService = append(i.IngressBackendService, IngressBackendService{ - ServiceId: serviceId, - IngressId: i.Id, - IngressRuleId: ingressRuleId, + ServiceUuid: serviceUuid, + IngressUuid: i.Uuid, + IngressRuleUuid: ingressRuleUuid, ServiceName: ruleValue.Backend.Service.Name, ServicePortName: ruleValue.Backend.Service.Port.Name, ServicePortNumber: ruleValue.Backend.Service.Port.Number, }) i.IngressRule = append(i.IngressRule, IngressRule{ - Id: ingressRuleId, - BackendId: serviceId, - IngressId: i.Id, - Host: rules.Host, - Path: ruleValue.Path, - PathType: pathType, + Uuid: ingressRuleUuid, + BackendUuid: serviceUuid, + IngressUuid: i.Uuid, + Host: rules.Host, + Path: ruleValue.Path, + PathType: pathType, }) } else if ruleValue.Backend.Resource != nil { - ingressRuleId := utils.Checksum(string(i.Id) + rules.Host + ruleValue.Path + ruleValue.Backend.Resource.Name) - resourceId := utils.Checksum(string(ingressRuleId) + i.Namespace + ruleValue.Backend.Resource.Name) + ingressRuleUuid := NewUUID(i.Uuid, rules.Host+ruleValue.Path+ruleValue.Backend.Resource.Name) + resourceUuid := NewUUID(ingressRuleUuid, ruleValue.Backend.Resource.Name) var apiGroup sql.NullString if ruleValue.Backend.Resource.APIGroup != nil { apiGroup.String = *ruleValue.Backend.Resource.APIGroup apiGroup.Valid = true } i.IngressBackendResource = append(i.IngressBackendResource, IngressBackendResource{ - ResourceId: resourceId, - IngressId: i.Id, - IngressRuleId: ingressRuleId, - ApiGroup: apiGroup, - Kind: ruleValue.Backend.Resource.Kind, - Name: ruleValue.Backend.Resource.Name, + ResourceUuid: resourceUuid, + IngressUuid: i.Uuid, + IngressRuleUuid: ingressRuleUuid, + ApiGroup: apiGroup, + Kind: ruleValue.Backend.Resource.Kind, + Name: ruleValue.Backend.Resource.Name, }) i.IngressRule = append(i.IngressRule, IngressRule{ - Id: ingressRuleId, - IngressId: i.Id, - BackendId: resourceId, - Host: rules.Host, - Path: ruleValue.Path, - PathType: pathType, + Uuid: ingressRuleUuid, + IngressUuid: i.Uuid, + BackendUuid: resourceUuid, + Host: rules.Host, + Path: ruleValue.Path, + PathType: pathType, }) } } @@ -160,7 +157,7 @@ func (i *Ingress) Obtain(k8s kmetav1.Object) { } func (i *Ingress) Relations() []database.Relation { - fk := database.WithForeignKey("ingress_id") + fk := database.WithForeignKey("ingress_uuid") return []database.Relation{ database.HasMany(i.IngressTls, fk), diff --git a/pkg/schema/v1/job.go b/pkg/schema/v1/job.go index f4e0b810..ffcf418a 100644 --- a/pkg/schema/v1/job.go +++ b/pkg/schema/v1/job.go @@ -3,7 +3,6 @@ package v1 import ( "database/sql" "github.com/icinga/icinga-go-library/types" - "github.com/icinga/icinga-go-library/utils" "github.com/icinga/icinga-kubernetes/pkg/database" "github.com/icinga/icinga-kubernetes/pkg/strcase" kbatchv1 "k8s.io/api/batch/v1" @@ -13,7 +12,6 @@ import ( type Job struct { Meta - Id types.Binary Parallelism sql.NullInt32 Completions sql.NullInt32 ActiveDeadlineSeconds sql.NullInt64 @@ -32,7 +30,7 @@ type Job struct { } type JobCondition struct { - JobId types.Binary + JobUuid types.UUID Type string Status string LastProbe types.UnixMilli @@ -42,8 +40,8 @@ type JobCondition struct { } type JobLabel struct { - JobId types.Binary - LabelId types.Binary + JobUuid types.UUID + LabelUuid types.UUID } func NewJob() Resource { @@ -99,7 +97,6 @@ func (j *Job) Obtain(k8s kmetav1.Object) { completionTime = *job.Status.CompletionTime } - j.Id = utils.Checksum(j.Namespace + "/" + j.Name) j.Parallelism = parallelism j.Completions = completions j.ActiveDeadlineSeconds = activeDeadlineSeconds @@ -115,7 +112,7 @@ func (j *Job) Obtain(k8s kmetav1.Object) { for _, condition := range job.Status.Conditions { j.Conditions = append(j.Conditions, JobCondition{ - JobId: j.Id, + JobUuid: j.Uuid, Type: strcase.Snake(string(condition.Type)), Status: strcase.Snake(string(condition.Status)), LastProbe: types.UnixMilli(condition.LastProbeTime.Time), @@ -126,21 +123,21 @@ func (j *Job) Obtain(k8s kmetav1.Object) { } for labelName, labelValue := range job.Labels { - labelId := utils.Checksum(strings.ToLower(labelName + ":" + labelValue)) + labelUuid := NewUUID(j.Uuid, strings.ToLower(labelName+":"+labelValue)) j.Labels = append(j.Labels, Label{ - Id: labelId, + Uuid: labelUuid, Name: labelName, Value: labelValue, }) j.JobLabels = append(j.JobLabels, JobLabel{ - JobId: j.Id, - LabelId: labelId, + JobUuid: j.Uuid, + LabelUuid: labelUuid, }) } } func (j *Job) Relations() []database.Relation { - fk := database.WithForeignKey("job_id") + fk := database.WithForeignKey("job_uuid") return []database.Relation{ database.HasMany(j.Conditions, fk), diff --git a/pkg/schema/v1/label.go b/pkg/schema/v1/label.go index be0535ae..37ae937f 100644 --- a/pkg/schema/v1/label.go +++ b/pkg/schema/v1/label.go @@ -1,9 +1,11 @@ package v1 -import "github.com/icinga/icinga-go-library/types" +import ( + "github.com/icinga/icinga-go-library/types" +) type Label struct { - Id types.Binary + Uuid types.UUID Name string Value string } diff --git a/pkg/schema/v1/namespace.go b/pkg/schema/v1/namespace.go index 6fe180f9..71fbbc3b 100644 --- a/pkg/schema/v1/namespace.go +++ b/pkg/schema/v1/namespace.go @@ -2,7 +2,6 @@ package v1 import ( "github.com/icinga/icinga-go-library/types" - "github.com/icinga/icinga-go-library/utils" "github.com/icinga/icinga-kubernetes/pkg/database" kcorev1 "k8s.io/api/core/v1" kmetav1 "k8s.io/apimachinery/pkg/apis/meta/v1" @@ -11,7 +10,6 @@ import ( type Namespace struct { Meta - Id types.Binary Phase string Conditions []NamespaceCondition `db:"-"` Labels []Label `db:"-"` @@ -19,7 +17,7 @@ type Namespace struct { } type NamespaceCondition struct { - NamespaceId types.Binary + NamespaceUuid types.UUID Type string Status string LastTransition types.UnixMilli @@ -28,8 +26,8 @@ type NamespaceCondition struct { } type NamespaceLabel struct { - NamespaceId types.Binary - LabelId types.Binary + NamespaceUuid types.UUID + LabelUuid types.UUID } func NewNamespace() Resource { @@ -41,12 +39,11 @@ func (n *Namespace) Obtain(k8s kmetav1.Object) { namespace := k8s.(*kcorev1.Namespace) - n.Id = utils.Checksum(namespace.Name) n.Phase = strings.ToLower(string(namespace.Status.Phase)) for _, condition := range namespace.Status.Conditions { n.Conditions = append(n.Conditions, NamespaceCondition{ - NamespaceId: n.Id, + NamespaceUuid: n.Uuid, Type: string(condition.Type), Status: string(condition.Status), LastTransition: types.UnixMilli(condition.LastTransitionTime.Time), @@ -56,21 +53,21 @@ func (n *Namespace) Obtain(k8s kmetav1.Object) { } for labelName, labelValue := range namespace.Labels { - labelId := utils.Checksum(strings.ToLower(labelName + ":" + labelValue)) + labelUuid := NewUUID(n.Uuid, strings.ToLower(labelName+":"+labelValue)) n.Labels = append(n.Labels, Label{ - Id: labelId, + Uuid: labelUuid, Name: labelName, Value: labelValue, }) n.NamespaceLabels = append(n.NamespaceLabels, NamespaceLabel{ - NamespaceId: n.Id, - LabelId: labelId, + NamespaceUuid: n.Uuid, + LabelUuid: labelUuid, }) } } func (n *Namespace) Relations() []database.Relation { - fk := database.WithForeignKey("namespace_id") + fk := database.WithForeignKey("namespace_uuid") return []database.Relation{ database.HasMany(n.Conditions, fk), diff --git a/pkg/schema/v1/node.go b/pkg/schema/v1/node.go index a6e2630c..d13c8ed7 100644 --- a/pkg/schema/v1/node.go +++ b/pkg/schema/v1/node.go @@ -2,7 +2,6 @@ package v1 import ( "github.com/icinga/icinga-go-library/types" - "github.com/icinga/icinga-go-library/utils" "github.com/icinga/icinga-kubernetes/pkg/database" "github.com/pkg/errors" kcorev1 "k8s.io/api/core/v1" @@ -14,7 +13,6 @@ import ( type Node struct { Meta - Id types.Binary PodCIDR string NumIps int64 Unschedulable types.Bool @@ -31,7 +29,7 @@ type Node struct { } type NodeCondition struct { - NodeId types.Binary + NodeUuid types.UUID Type string Status string LastHeartbeat types.UnixMilli @@ -41,15 +39,15 @@ type NodeCondition struct { } type NodeVolume struct { - NodeId types.Binary + NodeUuid types.UUID Name kcorev1.UniqueVolumeName DevicePath string Mounted types.Bool } type NodeLabel struct { - NodeId types.Binary - LabelId types.Binary + NodeUuid types.UUID + LabelUuid types.UUID } func NewNode() Resource { @@ -61,7 +59,6 @@ func (n *Node) Obtain(k8s kmetav1.Object) { node := k8s.(*kcorev1.Node) - n.Id = utils.Checksum(n.Namespace + "/" + n.Name) n.PodCIDR = node.Spec.PodCIDR if n.PodCIDR != "" { _, cidr, err := net.ParseCIDR(n.PodCIDR) @@ -86,7 +83,7 @@ func (n *Node) Obtain(k8s kmetav1.Object) { for _, condition := range node.Status.Conditions { n.Conditions = append(n.Conditions, NodeCondition{ - NodeId: n.Id, + NodeUuid: n.Uuid, Type: string(condition.Type), Status: string(condition.Status), LastHeartbeat: types.UnixMilli(condition.LastHeartbeatTime.Time), @@ -104,7 +101,7 @@ func (n *Node) Obtain(k8s kmetav1.Object) { for _, volume := range node.Status.VolumesAttached { _, mounted := volumesMounted[volume.Name] n.Volumes = append(n.Volumes, NodeVolume{ - NodeId: n.Id, + NodeUuid: n.Uuid, Name: volume.Name, DevicePath: volume.DevicePath, Mounted: types.Bool{ @@ -115,21 +112,21 @@ func (n *Node) Obtain(k8s kmetav1.Object) { } for labelName, labelValue := range node.Labels { - labelId := utils.Checksum(strings.ToLower(labelName + ":" + labelValue)) + labelUuid := NewUUID(n.Uuid, strings.ToLower(labelName+":"+labelValue)) n.Labels = append(n.Labels, Label{ - Id: labelId, + Uuid: labelUuid, Name: labelName, Value: labelValue, }) n.NodeLabels = append(n.NodeLabels, NodeLabel{ - NodeId: n.Id, - LabelId: labelId, + NodeUuid: n.Uuid, + LabelUuid: labelUuid, }) } } func (n *Node) Relations() []database.Relation { - fk := database.WithForeignKey("node_id") + fk := database.WithForeignKey("node_uuid") return []database.Relation{ database.HasMany(n.Conditions, fk), diff --git a/pkg/schema/v1/persistent_volume.go b/pkg/schema/v1/persistent_volume.go index a19df8a2..48e692e5 100644 --- a/pkg/schema/v1/persistent_volume.go +++ b/pkg/schema/v1/persistent_volume.go @@ -3,7 +3,6 @@ package v1 import ( "database/sql" "github.com/icinga/icinga-go-library/types" - "github.com/icinga/icinga-go-library/utils" "github.com/icinga/icinga-kubernetes/pkg/database" "github.com/icinga/icinga-kubernetes/pkg/strcase" kcorev1 "k8s.io/api/core/v1" @@ -13,7 +12,6 @@ import ( type PersistentVolume struct { Meta - Id types.Binary AccessModes Bitmask[kpersistentVolumeAccessModesSize] Capacity int64 ReclaimPolicy string @@ -28,10 +26,10 @@ type PersistentVolume struct { } type PersistentVolumeClaimRef struct { - PersistentVolumeId types.Binary - Kind string - Name string - Uid ktypes.UID + PersistentVolumeUuid types.UUID + Kind string + Name string + Uid ktypes.UID } func NewPersistentVolume() Resource { @@ -43,7 +41,6 @@ func (p *PersistentVolume) Obtain(k8s kmetav1.Object) { persistentVolume := k8s.(*kcorev1.PersistentVolume) - p.Id = utils.Checksum(persistentVolume.Namespace + "/" + persistentVolume.Name) p.AccessModes = persistentVolumeAccessModes.Bitmask(persistentVolume.Spec.AccessModes...) p.Capacity = persistentVolume.Spec.Capacity.Storage().MilliValue() p.ReclaimPolicy = strcase.Snake(string(persistentVolume.Spec.PersistentVolumeReclaimPolicy)) @@ -65,10 +62,10 @@ func (p *PersistentVolume) Obtain(k8s kmetav1.Object) { if persistentVolume.Spec.ClaimRef != nil { p.Claim = &PersistentVolumeClaimRef{ - PersistentVolumeId: p.Id, - Kind: persistentVolume.Spec.ClaimRef.Kind, - Name: persistentVolume.Spec.ClaimRef.Name, - Uid: persistentVolume.Spec.ClaimRef.UID, + PersistentVolumeUuid: p.Uuid, + Kind: persistentVolume.Spec.ClaimRef.Kind, + Name: persistentVolume.Spec.ClaimRef.Name, + Uid: persistentVolume.Spec.ClaimRef.UID, } } } @@ -78,7 +75,7 @@ func (p *PersistentVolume) Relations() []database.Relation { return []database.Relation{} } - fk := database.WithForeignKey("persistent_volume_id") + fk := database.WithForeignKey("persistent_volume_uuid") return []database.Relation{ database.HasOne(p.Claim, fk), diff --git a/pkg/schema/v1/pod.go b/pkg/schema/v1/pod.go index ab4c248b..c51bdc5c 100644 --- a/pkg/schema/v1/pod.go +++ b/pkg/schema/v1/pod.go @@ -3,7 +3,6 @@ package v1 import ( "database/sql" "github.com/icinga/icinga-go-library/types" - "github.com/icinga/icinga-go-library/utils" "github.com/icinga/icinga-kubernetes/pkg/database" "github.com/icinga/icinga-kubernetes/pkg/strcase" kcorev1 "k8s.io/api/core/v1" @@ -19,7 +18,6 @@ type PodFactory struct { type Pod struct { Meta - Id types.Binary NodeName string NominatedNodeName string Ip string @@ -43,7 +41,7 @@ type Pod struct { } type PodCondition struct { - PodId types.Binary + PodUuid types.UUID Type string Status string LastProbe types.UnixMilli @@ -53,12 +51,12 @@ type PodCondition struct { } type PodLabel struct { - PodId types.Binary - LabelId types.Binary + PodUuid types.UUID + LabelUuid types.UUID } type PodOwner struct { - PodId types.Binary + PodUuid types.UUID Kind string Name string Uid ktypes.UID @@ -67,14 +65,14 @@ type PodOwner struct { } type PodVolume struct { - PodId types.Binary + PodUuid types.UUID VolumeName string Type string Source string } type PodPvc struct { - PodId types.Binary + PodUuid types.UUID VolumeName string ClaimName string ReadOnly types.Bool @@ -95,7 +93,6 @@ func (p *Pod) Obtain(k8s kmetav1.Object) { pod := k8s.(*kcorev1.Pod) - p.Id = utils.Checksum(pod.Namespace + "/" + pod.Name) p.NodeName = pod.Spec.NodeName p.NominatedNodeName = pod.Status.NominatedNodeName p.Ip = pod.Status.PodIP @@ -107,7 +104,7 @@ func (p *Pod) Obtain(k8s kmetav1.Object) { for _, condition := range pod.Status.Conditions { p.Conditions = append(p.Conditions, PodCondition{ - PodId: p.Id, + PodUuid: p.Uuid, Type: string(condition.Type), Status: string(condition.Status), LastProbe: types.UnixMilli(condition.LastProbeTime.Time), @@ -138,8 +135,8 @@ func (p *Pod) Obtain(k8s kmetav1.Object) { container := Container{ ContainerMeta: ContainerMeta{ - Id: utils.Checksum(pod.Namespace + "/" + pod.Name + "/" + k8sContainer.Name), - PodId: p.Id, + Uuid: NewUUID(p.Uuid, k8sContainer.Name), + PodUuid: p.Uuid, }, Name: k8sContainer.Name, Image: k8sContainer.Image, @@ -167,10 +164,10 @@ func (p *Pod) Obtain(k8s kmetav1.Object) { for _, device := range k8sContainer.VolumeDevices { container.Devices = append(container.Devices, ContainerDevice{ - ContainerId: container.Id, - PodId: p.Id, - Name: device.Name, - Path: device.DevicePath, + ContainerUuid: container.Uuid, + PodUuid: p.Uuid, + Name: device.Name, + Path: device.DevicePath, }) } @@ -181,11 +178,11 @@ func (p *Pod) Obtain(k8s kmetav1.Object) { subPath.Valid = true } container.Mounts = append(container.Mounts, ContainerMount{ - ContainerId: container.Id, - PodId: p.Id, - VolumeName: mount.Name, - Path: mount.MountPath, - SubPath: subPath, + ContainerUuid: container.Uuid, + PodUuid: p.Uuid, + VolumeName: mount.Name, + Path: mount.MountPath, + SubPath: subPath, ReadOnly: types.Bool{ Bool: mount.ReadOnly, Valid: true, @@ -197,15 +194,15 @@ func (p *Pod) Obtain(k8s kmetav1.Object) { } for labelName, labelValue := range pod.Labels { - labelId := utils.Checksum(strings.ToLower(labelName + ":" + labelValue)) + labelUuid := NewUUID(p.Uuid, strings.ToLower(labelName+":"+labelValue)) p.Labels = append(p.Labels, Label{ - Id: labelId, + Uuid: labelUuid, Name: labelName, Value: labelValue, }) p.PodLabels = append(p.PodLabels, PodLabel{ - PodId: p.Id, - LabelId: labelId, + PodUuid: p.Uuid, + LabelUuid: labelUuid, }) } @@ -218,10 +215,10 @@ func (p *Pod) Obtain(k8s kmetav1.Object) { controller = *ownerReference.Controller } p.Owners = append(p.Owners, PodOwner{ - PodId: p.Id, - Kind: strcase.Snake(ownerReference.Kind), - Name: ownerReference.Name, - Uid: ownerReference.UID, + PodUuid: p.Uuid, + Kind: strcase.Snake(ownerReference.Kind), + Name: ownerReference.Name, + Uid: ownerReference.UID, BlockOwnerDeletion: types.Bool{ Bool: blockOwnerDeletion, Valid: true, @@ -246,7 +243,7 @@ func (p *Pod) Obtain(k8s kmetav1.Object) { for _, volume := range pod.Spec.Volumes { if volume.PersistentVolumeClaim != nil { p.Pvcs = append(p.Pvcs, PodPvc{ - PodId: p.Id, + PodUuid: p.Uuid, VolumeName: volume.Name, ClaimName: volume.PersistentVolumeClaim.ClaimName, ReadOnly: types.Bool{ @@ -261,7 +258,7 @@ func (p *Pod) Obtain(k8s kmetav1.Object) { } p.Volumes = append(p.Volumes, PodVolume{ - PodId: p.Id, + PodUuid: p.Uuid, VolumeName: volume.Name, Type: t, Source: source, @@ -271,7 +268,7 @@ func (p *Pod) Obtain(k8s kmetav1.Object) { } func (p *Pod) Relations() []database.Relation { - fk := database.WithForeignKey("pod_id") + fk := database.WithForeignKey("pod_uuid") return []database.Relation{ database.HasMany(p.Conditions, fk), diff --git a/pkg/schema/v1/pvc.go b/pkg/schema/v1/pvc.go index 25f0cbbb..430a432d 100644 --- a/pkg/schema/v1/pvc.go +++ b/pkg/schema/v1/pvc.go @@ -3,7 +3,6 @@ package v1 import ( "database/sql" "github.com/icinga/icinga-go-library/types" - "github.com/icinga/icinga-go-library/utils" "github.com/icinga/icinga-kubernetes/pkg/database" "github.com/icinga/icinga-kubernetes/pkg/strcase" kcorev1 "k8s.io/api/core/v1" @@ -34,7 +33,6 @@ var persistentVolumeAccessModes = kpersistentVolumeAccessModes{ type Pvc struct { Meta - Id types.Binary DesiredAccessModes Bitmask[kpersistentVolumeAccessModesSize] ActualAccessModes Bitmask[kpersistentVolumeAccessModesSize] MinimumCapacity sql.NullInt64 @@ -49,7 +47,7 @@ type Pvc struct { } type PvcCondition struct { - PvcId types.Binary + PvcUuid types.UUID Type string Status string LastProbe types.UnixMilli @@ -59,8 +57,8 @@ type PvcCondition struct { } type PvcLabel struct { - PvcId types.Binary - LabelId types.Binary + PvcUuid types.UUID + LabelUuid types.UUID } func NewPvc() Resource { @@ -72,7 +70,6 @@ func (p *Pvc) Obtain(k8s kmetav1.Object) { pvc := k8s.(*kcorev1.PersistentVolumeClaim) - p.Id = utils.Checksum(pvc.Namespace + "/" + pvc.Name) p.DesiredAccessModes = persistentVolumeAccessModes.Bitmask(pvc.Spec.AccessModes...) p.ActualAccessModes = persistentVolumeAccessModes.Bitmask(pvc.Status.AccessModes...) if requestsStorage, ok := pvc.Spec.Resources.Requests[kcorev1.ResourceStorage]; ok { @@ -99,7 +96,7 @@ func (p *Pvc) Obtain(k8s kmetav1.Object) { for _, condition := range pvc.Status.Conditions { p.Conditions = append(p.Conditions, PvcCondition{ - PvcId: p.Id, + PvcUuid: p.Uuid, Type: strcase.Snake(string(condition.Type)), Status: string(condition.Status), LastProbe: types.UnixMilli(condition.LastProbeTime.Time), @@ -110,21 +107,21 @@ func (p *Pvc) Obtain(k8s kmetav1.Object) { } for labelName, labelValue := range pvc.Labels { - labelId := utils.Checksum(strings.ToLower(labelName + ":" + labelValue)) + labelUuid := NewUUID(p.Uuid, strings.ToLower(labelName+":"+labelValue)) p.Labels = append(p.Labels, Label{ - Id: labelId, + Uuid: labelUuid, Name: labelName, Value: labelValue, }) p.PvcLabels = append(p.PvcLabels, PvcLabel{ - PvcId: p.Id, - LabelId: labelId, + PvcUuid: p.Uuid, + LabelUuid: labelUuid, }) } } func (p *Pvc) Relations() []database.Relation { - fk := database.WithForeignKey("pvc_id") + fk := database.WithForeignKey("pvc_uuid") return []database.Relation{ database.HasMany(p.Conditions, fk), diff --git a/pkg/schema/v1/replica_set.go b/pkg/schema/v1/replica_set.go index 652cd8d7..e0471315 100644 --- a/pkg/schema/v1/replica_set.go +++ b/pkg/schema/v1/replica_set.go @@ -2,7 +2,6 @@ package v1 import ( "github.com/icinga/icinga-go-library/types" - "github.com/icinga/icinga-go-library/utils" "github.com/icinga/icinga-kubernetes/pkg/database" "github.com/icinga/icinga-kubernetes/pkg/strcase" kappsv1 "k8s.io/api/apps/v1" @@ -13,7 +12,6 @@ import ( type ReplicaSet struct { Meta - Id types.Binary DesiredReplicas int32 MinReadySeconds int32 ActualReplicas int32 @@ -27,7 +25,7 @@ type ReplicaSet struct { } type ReplicaSetCondition struct { - ReplicaSetId types.Binary + ReplicaSetUuid types.UUID Type string Status string LastTransition types.UnixMilli @@ -36,7 +34,7 @@ type ReplicaSetCondition struct { } type ReplicaSetOwner struct { - ReplicaSetId types.Binary + ReplicaSetUuid types.UUID Kind string Name string Uid ktypes.UID @@ -45,8 +43,8 @@ type ReplicaSetOwner struct { } type ReplicaSetLabel struct { - ReplicaSetId types.Binary - LabelId types.Binary + ReplicaSetUuid types.UUID + LabelUuid types.UUID } func NewReplicaSet() Resource { @@ -62,7 +60,6 @@ func (r *ReplicaSet) Obtain(k8s kmetav1.Object) { if replicaSet.Spec.Replicas != nil { desiredReplicas = *replicaSet.Spec.Replicas } - r.Id = utils.Checksum(r.Namespace + "/" + r.Name) r.DesiredReplicas = desiredReplicas r.MinReadySeconds = replicaSet.Spec.MinReadySeconds r.ActualReplicas = replicaSet.Status.Replicas @@ -72,7 +69,7 @@ func (r *ReplicaSet) Obtain(k8s kmetav1.Object) { for _, condition := range replicaSet.Status.Conditions { r.Conditions = append(r.Conditions, ReplicaSetCondition{ - ReplicaSetId: r.Id, + ReplicaSetUuid: r.Uuid, Type: strcase.Snake(string(condition.Type)), Status: string(condition.Status), LastTransition: types.UnixMilli(condition.LastTransitionTime.Time), @@ -90,10 +87,10 @@ func (r *ReplicaSet) Obtain(k8s kmetav1.Object) { controller = *ownerReference.Controller } r.Owners = append(r.Owners, ReplicaSetOwner{ - ReplicaSetId: r.Id, - Kind: strcase.Snake(ownerReference.Kind), - Name: ownerReference.Name, - Uid: ownerReference.UID, + ReplicaSetUuid: r.Uuid, + Kind: strcase.Snake(ownerReference.Kind), + Name: ownerReference.Name, + Uid: ownerReference.UID, BlockOwnerDeletion: types.Bool{ Bool: blockOwnerDeletion, Valid: true, @@ -106,21 +103,21 @@ func (r *ReplicaSet) Obtain(k8s kmetav1.Object) { } for labelName, labelValue := range replicaSet.Labels { - labelId := utils.Checksum(strings.ToLower(labelName + ":" + labelValue)) + labelUuid := NewUUID(r.Uuid, strings.ToLower(labelName+":"+labelValue)) r.Labels = append(r.Labels, Label{ - Id: labelId, + Uuid: labelUuid, Name: labelName, Value: labelValue, }) r.ReplicaSetLabels = append(r.ReplicaSetLabels, ReplicaSetLabel{ - ReplicaSetId: r.Id, - LabelId: labelId, + ReplicaSetUuid: r.Uuid, + LabelUuid: labelUuid, }) } } func (r *ReplicaSet) Relations() []database.Relation { - fk := database.WithForeignKey("replica_set_id") + fk := database.WithForeignKey("replica_set_uuid") return []database.Relation{ database.HasMany(r.Conditions, fk), diff --git a/pkg/schema/v1/secret.go b/pkg/schema/v1/secret.go index d55d23f7..396ad522 100644 --- a/pkg/schema/v1/secret.go +++ b/pkg/schema/v1/secret.go @@ -3,7 +3,6 @@ package v1 import ( b64 "encoding/base64" "github.com/icinga/icinga-go-library/types" - "github.com/icinga/icinga-go-library/utils" "github.com/icinga/icinga-kubernetes/pkg/database" kcorev1 "k8s.io/api/core/v1" kmetav1 "k8s.io/apimachinery/pkg/apis/meta/v1" @@ -12,7 +11,6 @@ import ( type Secret struct { Meta - Id types.Binary Type string Immutable types.Bool Data []Data `db:"-"` @@ -22,13 +20,13 @@ type Secret struct { } type SecretData struct { - SecretId types.Binary - DataId types.Binary + SecretUuid types.UUID + DataUuid types.UUID } type SecretLabel struct { - SecretId types.Binary - LabelId types.Binary + SecretUuid types.UUID + LabelUuid types.UUID } func NewSecret() Resource { @@ -40,7 +38,6 @@ func (s *Secret) Obtain(k8s kmetav1.Object) { secret := k8s.(*kcorev1.Secret) - s.Id = utils.Checksum(s.Namespace + "/" + s.Name) s.Type = string(secret.Type) var immutable bool @@ -62,34 +59,34 @@ func (s *Secret) Obtain(k8s kmetav1.Object) { value = string(dataValue[:n]) } - dataId := utils.Checksum(dataName + ":" + value) + dataUuid := NewUUID(s.Uuid, strings.ToLower(dataName+":"+value)) s.Data = append(s.Data, Data{ - Id: dataId, + Uuid: dataUuid, Name: dataName, Value: value, }) s.SecretData = append(s.SecretData, SecretData{ - SecretId: s.Id, - DataId: dataId, + SecretUuid: s.Uuid, + DataUuid: dataUuid, }) } for labelName, labelValue := range secret.Labels { - labelId := utils.Checksum(strings.ToLower(labelName + ":" + labelValue)) + labelUuid := NewUUID(s.Uuid, strings.ToLower(labelName+":"+labelValue)) s.Labels = append(s.Labels, Label{ - Id: labelId, + Uuid: labelUuid, Name: labelName, Value: labelValue, }) s.SecretLabels = append(s.SecretLabels, SecretLabel{ - SecretId: s.Id, - LabelId: labelId, + SecretUuid: s.Uuid, + LabelUuid: labelUuid, }) } } func (s *Secret) Relations() []database.Relation { - fk := database.WithForeignKey("secret_id") + fk := database.WithForeignKey("secret_uuid") return []database.Relation{ database.HasMany(s.Labels, database.WithoutCascadeDelete()), diff --git a/pkg/schema/v1/selector.go b/pkg/schema/v1/selector.go index b72bfa51..972570fa 100644 --- a/pkg/schema/v1/selector.go +++ b/pkg/schema/v1/selector.go @@ -1,9 +1,11 @@ package v1 -import "github.com/icinga/icinga-go-library/types" +import ( + "github.com/icinga/icinga-go-library/types" +) type Selector struct { - Id types.Binary + Uuid types.UUID Name string Value string } diff --git a/pkg/schema/v1/service.go b/pkg/schema/v1/service.go index 6dec586f..66da9aa1 100644 --- a/pkg/schema/v1/service.go +++ b/pkg/schema/v1/service.go @@ -3,7 +3,6 @@ package v1 import ( "database/sql" "github.com/icinga/icinga-go-library/types" - "github.com/icinga/icinga-go-library/utils" "github.com/icinga/icinga-kubernetes/pkg/database" "github.com/icinga/icinga-kubernetes/pkg/strcase" kcorev1 "k8s.io/api/core/v1" @@ -13,7 +12,6 @@ import ( type Service struct { Meta - Id types.Binary Type string ClusterIP string ClusterIPs string @@ -37,12 +35,12 @@ type Service struct { } type ServiceSelector struct { - ServiceId types.Binary - SelectorId types.Binary + ServiceUuid types.UUID + SelectorUuid types.UUID } type ServicePort struct { - ServiceId types.Binary + ServiceUuid types.UUID Name string Protocol string AppProtocol string @@ -52,7 +50,7 @@ type ServicePort struct { } type ServiceCondition struct { - ServiceId types.Binary + ServiceUuid types.UUID Type string Status string ObservedGeneration int64 @@ -62,8 +60,8 @@ type ServiceCondition struct { } type ServiceLabel struct { - ServiceId types.Binary - LabelId types.Binary + ServiceUuid types.UUID + LabelUuid types.UUID } func NewService() Resource { @@ -99,7 +97,6 @@ func (s *Service) Obtain(k8s kmetav1.Object) { internalTrafficPolicy = strcase.Snake(string(*service.Spec.InternalTrafficPolicy)) } - s.Id = utils.Checksum(service.Namespace + "/" + service.Name) s.Type = strcase.Snake(string(service.Spec.Type)) s.ClusterIP = service.Spec.ClusterIP for _, clusterIP := range service.Spec.ClusterIPs { @@ -128,15 +125,15 @@ func (s *Service) Obtain(k8s kmetav1.Object) { s.InternalTrafficPolicy = internalTrafficPolicy for selectorName, selectorValue := range service.Spec.Selector { - selectorId := utils.Checksum(strings.ToLower(selectorName + ":" + selectorValue)) + selectorUuid := NewUUID(s.Uuid, strings.ToLower(selectorName+":"+selectorValue)) s.Selectors = append(s.Selectors, Selector{ - Id: selectorId, + Uuid: selectorUuid, Name: selectorName, Value: selectorValue, }) s.ServiceSelectors = append(s.ServiceSelectors, ServiceSelector{ - ServiceId: s.Id, - SelectorId: selectorId, + ServiceUuid: s.Uuid, + SelectorUuid: selectorUuid, }) } @@ -146,7 +143,7 @@ func (s *Service) Obtain(k8s kmetav1.Object) { appProtocol = *port.AppProtocol } s.Ports = append(s.Ports, ServicePort{ - ServiceId: s.Id, + ServiceUuid: s.Uuid, Name: port.Name, Protocol: string(port.Protocol), AppProtocol: appProtocol, @@ -158,7 +155,7 @@ func (s *Service) Obtain(k8s kmetav1.Object) { for _, condition := range service.Status.Conditions { s.Conditions = append(s.Conditions, ServiceCondition{ - ServiceId: s.Id, + ServiceUuid: s.Uuid, Type: condition.Type, Status: strcase.Snake(string(condition.Status)), ObservedGeneration: condition.ObservedGeneration, @@ -169,21 +166,21 @@ func (s *Service) Obtain(k8s kmetav1.Object) { } for labelName, labelValue := range service.Labels { - labelId := utils.Checksum(strings.ToLower(labelName + ":" + labelValue)) + labelUuid := NewUUID(s.Uuid, strings.ToLower(labelName+":"+labelValue)) s.Labels = append(s.Labels, Label{ - Id: labelId, + Uuid: labelUuid, Name: labelName, Value: labelValue, }) s.ServiceLabels = append(s.ServiceLabels, ServiceLabel{ - ServiceId: s.Id, - LabelId: labelId, + ServiceUuid: s.Uuid, + LabelUuid: labelUuid, }) } } func (s *Service) Relations() []database.Relation { - fk := database.WithForeignKey("service_id") + fk := database.WithForeignKey("service_uuid") return []database.Relation{ database.HasMany(s.Conditions, fk), diff --git a/pkg/schema/v1/stateful_set.go b/pkg/schema/v1/stateful_set.go index ecf2dcd5..96a6ad45 100644 --- a/pkg/schema/v1/stateful_set.go +++ b/pkg/schema/v1/stateful_set.go @@ -2,7 +2,6 @@ package v1 import ( "github.com/icinga/icinga-go-library/types" - "github.com/icinga/icinga-go-library/utils" "github.com/icinga/icinga-kubernetes/pkg/database" "github.com/icinga/icinga-kubernetes/pkg/strcase" kappsv1 "k8s.io/api/apps/v1" @@ -12,7 +11,6 @@ import ( type StatefulSet struct { Meta - Id types.Binary DesiredReplicas int32 ServiceName string PodManagementPolicy string @@ -32,17 +30,17 @@ type StatefulSet struct { } type StatefulSetCondition struct { - StatefulSetId types.Binary - Type string - Status string - LastTransition types.UnixMilli - Reason string - Message string + StatefulSetUuid types.UUID + Type string + Status string + LastTransition types.UnixMilli + Reason string + Message string } type StatefulSetLabel struct { - StatefulSetId types.Binary - LabelId types.Binary + StatefulSetUuid types.UUID + LabelUuid types.UUID } func NewStatefulSet() Resource { @@ -68,7 +66,7 @@ func (s *StatefulSet) Obtain(k8s kmetav1.Object) { } else { pvcRetentionPolicyDeleted, pvcRetentionPolicyScaled = kappsv1.RetainPersistentVolumeClaimRetentionPolicyType, kappsv1.RetainPersistentVolumeClaimRetentionPolicyType } - s.Id = utils.Checksum(s.Namespace + "/" + s.Name) + s.DesiredReplicas = replicas s.ServiceName = statefulSet.Spec.ServiceName s.PodManagementPolicy = strcase.Snake(string(statefulSet.Spec.PodManagementPolicy)) @@ -86,31 +84,31 @@ func (s *StatefulSet) Obtain(k8s kmetav1.Object) { for _, condition := range statefulSet.Status.Conditions { s.Conditions = append(s.Conditions, StatefulSetCondition{ - StatefulSetId: s.Id, - Type: string(condition.Type), - Status: string(condition.Status), - LastTransition: types.UnixMilli(condition.LastTransitionTime.Time), - Reason: condition.Reason, - Message: condition.Message, + StatefulSetUuid: s.Uuid, + Type: string(condition.Type), + Status: string(condition.Status), + LastTransition: types.UnixMilli(condition.LastTransitionTime.Time), + Reason: condition.Reason, + Message: condition.Message, }) } for labelName, labelValue := range statefulSet.Labels { - labelId := utils.Checksum(strings.ToLower(labelName + ":" + labelValue)) + labelUuid := NewUUID(s.Uuid, strings.ToLower(labelName+":"+labelValue)) s.Labels = append(s.Labels, Label{ - Id: labelId, + Uuid: labelUuid, Name: labelName, Value: labelValue, }) s.StatefulSetLabels = append(s.StatefulSetLabels, StatefulSetLabel{ - StatefulSetId: s.Id, - LabelId: labelId, + StatefulSetUuid: s.Uuid, + LabelUuid: labelUuid, }) } } func (s *StatefulSet) Relations() []database.Relation { - fk := database.WithForeignKey("stateful_set_id") + fk := database.WithForeignKey("stateful_set_uuid") return []database.Relation{ database.HasMany(s.Conditions, fk), diff --git a/schema/mysql/schema.sql b/schema/mysql/schema.sql index e0245f18..a4b4cf4c 100644 --- a/schema/mysql/schema.sql +++ b/schema/mysql/schema.sql @@ -1,26 +1,26 @@ CREATE TABLE namespace ( - id binary(20) NOT NULL COMMENT 'sha1(name)', + uuid binary(16) NOT NULL COMMENT 'sha1(name)', namespace varchar(63) COLLATE utf8mb4_unicode_ci NOT NULL, /* TODO: Remove. A namespace does not have a namespace. */ name varchar(63) COLLATE utf8mb4_unicode_ci NOT NULL, uid varchar(255) COLLATE utf8mb4_unicode_ci NOT NULL, resource_version varchar(255) NOT NULL, phase enum('active', 'terminating') COLLATE utf8mb4_unicode_ci NOT NULL, created bigint unsigned NOT NULL, - PRIMARY KEY (id) + PRIMARY KEY (uuid) ) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_bin; CREATE TABLE namespace_condition ( - namespace_id binary(20) NOT NULL, + namespace_uuid binary(16) NOT NULL, type varchar(255) COLLATE utf8mb4_unicode_ci NOT NULL, status varchar(255) COLLATE utf8mb4_unicode_ci NOT NULL, last_transition bigint unsigned NOT NULL, reason varchar(255) COLLATE utf8mb4_unicode_ci NOT NULL, message text, - PRIMARY KEY (namespace_id, type) + PRIMARY KEY (namespace_uuid, type) ) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_bin; CREATE TABLE node ( - id binary(20) NOT NULL, + uuid binary(16) NOT NULL, namespace varchar(63) COLLATE utf8mb4_unicode_ci NOT NULL, name varchar(253) COLLATE utf8mb4_unicode_ci NOT NULL, uid varchar(255) COLLATE utf8mb4_unicode_ci NOT NULL, @@ -35,30 +35,30 @@ CREATE TABLE node ( memory_allocatable bigint unsigned NOT NULL, pod_capacity int unsigned NOT NULL, created bigint unsigned NOT NULL, - PRIMARY KEY (id) + PRIMARY KEY (uuid) ) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_bin; CREATE TABLE node_condition ( - node_id binary(20) NOT NULL, + node_uuid binary(16) NOT NULL, type varchar(255) COLLATE utf8mb4_unicode_ci NOT NULL, status varchar(255) COLLATE utf8mb4_unicode_ci NOT NULL, last_heartbeat bigint unsigned NOT NULL, last_transition bigint unsigned NOT NULL, reason varchar(255) COLLATE utf8mb4_unicode_ci NOT NULL, message text, - PRIMARY KEY (node_id, type) + PRIMARY KEY (node_uuid, type) ) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_bin; CREATE TABLE node_volume ( - node_id binary(20) NOT NULL, + node_uuid binary(16) NOT NULL, name varchar(253) COLLATE utf8mb4_unicode_ci NOT NULL, device_path varchar(255) COLLATE utf8mb4_unicode_ci NOT NULL, mounted enum('n', 'y') COLLATE utf8mb4_unicode_ci NOT NULL, - PRIMARY KEY (node_id, name) + PRIMARY KEY (node_uuid, name) ) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_bin; CREATE TABLE pod ( - id binary(20) NOT NULL COMMENT 'sha1(namespace/name)', + uuid binary(16) NOT NULL, namespace varchar(63) COLLATE utf8mb4_unicode_ci NOT NULL, name varchar(253) COLLATE utf8mb4_unicode_ci NOT NULL, uid varchar(255) COLLATE utf8mb4_unicode_ci NOT NULL, @@ -76,49 +76,49 @@ CREATE TABLE pod ( message varchar(255) NULL DEFAULT NULL, qos enum('guaranteed', 'burstable', 'best_effort') COLLATE utf8mb4_unicode_ci NOT NULL, created bigint unsigned NOT NULL, - PRIMARY KEY (id) + PRIMARY KEY (uuid) ) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_bin; CREATE TABLE pod_condition ( - pod_id binary(20) NOT NULL, + pod_uuid binary(16) NOT NULL, type varchar(255) COLLATE utf8mb4_unicode_ci NOT NULL, status varchar(255) COLLATE utf8mb4_unicode_ci NOT NULL, last_probe bigint unsigned NULL DEFAULT NULL, last_transition bigint unsigned NOT NULL, reason varchar(255) COLLATE utf8mb4_unicode_ci NOT NULL, message text, - PRIMARY KEY (pod_id, type) + PRIMARY KEY (pod_uuid, type) ) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_bin; CREATE TABLE pod_owner ( - pod_id binary(20) NOT NULL, + pod_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_id, uid) + PRIMARY KEY (pod_uuid, uid) ) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_bin; CREATE TABLE pod_pvc ( - pod_id binary(20) NOT NULL, + pod_uuid binary(16) NOT NULL, volume_name varchar(253) COLLATE utf8mb4_unicode_ci NOT NULL, claim_name varchar(253) COLLATE utf8mb4_unicode_ci NOT NULL, read_only enum('n', 'y') COLLATE utf8mb4_unicode_ci NOT NULL, - PRIMARY KEY (pod_id, volume_name, claim_name) + PRIMARY KEY (pod_uuid, volume_name, claim_name) ) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_bin; CREATE TABLE pod_volume ( - pod_id binary(20) NOT NULL, + pod_uuid binary(16) NOT NULL, volume_name varchar(63) COLLATE utf8mb4_unicode_ci NOT NULL, type varchar(255) COLLATE utf8mb4_unicode_ci NOT NULL, source longtext NOT NULL, - PRIMARY KEY (pod_id, volume_name) + PRIMARY KEY (pod_uuid, volume_name) ) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_bin; CREATE TABLE container ( - id binary(20) NOT NULL COMMENT 'sha1(pod.namespace/pod.name/name)', - pod_id binary(20) NOT NULL, + uuid binary(16) NOT NULL COMMENT 'sha1(pod.namespace/pod.name/name)', + pod_uuid binary(16) NOT NULL, name varchar(63) COLLATE utf8mb4_unicode_ci NOT NULL, image varchar(255) COLLATE utf8mb4_unicode_ci NOT NULL, cpu_limits bigint unsigned NOT NULL, @@ -130,38 +130,38 @@ CREATE TABLE container ( ready enum('n', 'y') COLLATE utf8mb4_unicode_ci NOT NULL, started enum('n', 'y') COLLATE utf8mb4_unicode_ci NOT NULL, restart_count int unsigned NOT NULL, - PRIMARY KEY (id) + PRIMARY KEY (uuid) ) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_bin; CREATE TABLE container_device ( - container_id binary(20) NOT NULL, - pod_id binary(20) NOT NULL, + container_uuid binary(16) NOT NULL, + pod_uuid binary(16) NOT NULL, name varchar(253) COLLATE utf8mb4_unicode_ci NOT NULL, path varchar(255) COLLATE utf8mb4_unicode_ci NOT NULL, - PRIMARY KEY (container_id, name) + PRIMARY KEY (container_uuid, name) ) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_bin; CREATE TABLE container_mount ( - container_id binary(20) NOT NULL, - pod_id binary(20) NOT NULL, + container_uuid binary(16) NOT NULL, + pod_uuid binary(16) NOT NULL, volume_name varchar(63) COLLATE utf8mb4_unicode_ci NOT NULL, path varchar(255) COLLATE utf8mb4_unicode_ci NOT NULL, sub_path varchar(255) COLLATE utf8mb4_unicode_ci NULL DEFAULT NULL, read_only enum('n', 'y') COLLATE utf8mb4_unicode_ci NOT NULL, - PRIMARY KEY (container_id, volume_name) + PRIMARY KEY (container_uuid, volume_name) ) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_bin; CREATE TABLE container_log ( - container_id binary(20) NOT NULL, - pod_id binary(20) NOT NULL, + container_uuid binary(16) NOT NULL, + pod_uuid binary(16) NOT NULL, logs longtext NOT NULL, last_update bigint NOT NULL, - PRIMARY KEY (container_id, pod_id) + PRIMARY KEY (container_uuid, pod_uuid) ) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_bin; CREATE TABLE deployment ( - id binary(20) NOT NULL, + uuid binary(16) NOT NULL, namespace varchar(63) COLLATE utf8mb4_unicode_ci NOT NULL, name varchar(253) COLLATE utf8mb4_unicode_ci NOT NULL, uid varchar(255) COLLATE utf8mb4_unicode_ci NOT NULL, @@ -177,22 +177,22 @@ CREATE TABLE deployment ( available_replicas int unsigned NOT NULL, unavailable_replicas int unsigned NOT NULL, created bigint unsigned NOT NULL, - PRIMARY KEY (id) + PRIMARY KEY (uuid) ) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_bin; CREATE TABLE deployment_condition ( - deployment_id binary(20) NOT NULL, + deployment_uuid binary(16) NOT NULL, type enum('available', 'progressing', 'replica_failure') COLLATE utf8mb4_unicode_ci NOT NULL, status varchar(255) COLLATE utf8mb4_unicode_ci NOT NULL, last_update bigint unsigned NOT NULL, last_transition bigint unsigned NOT NULL, reason varchar(255) COLLATE utf8mb4_unicode_ci NOT NULL, message text, - PRIMARY KEY (deployment_id, type) + PRIMARY KEY (deployment_uuid, type) ) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_bin; CREATE TABLE service ( - id binary(20) NOT NULL, + uuid binary(16) NOT NULL, namespace varchar(63) COLLATE utf8mb4_unicode_ci NOT NULL, name varchar(253) COLLATE utf8mb4_unicode_ci NOT NULL, uid varchar(255) COLLATE utf8mb4_unicode_ci NOT NULL, @@ -212,58 +212,58 @@ CREATE TABLE service ( load_balancer_class varchar(255) COLLATE utf8mb4_unicode_ci NOT NULL, internal_traffic_policy enum('cluster', 'local') COLLATE utf8mb4_unicode_ci NOT NULL, created bigint unsigned NOT NULL, - PRIMARY KEY (id) + PRIMARY KEY (uuid) ) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_bin; CREATE TABLE selector ( - id binary(20) NOT NULL, + uuid binary(16) NOT NULL, name varchar(63) COLLATE utf8mb4_unicode_ci NOT NULL, value varchar(255) COLLATE utf8mb4_unicode_ci NOT NULL, - PRIMARY KEY (id) + PRIMARY KEY (uuid) ) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_bin; CREATE TABLE service_selector ( - service_id binary(20) NOT NULL, - selector_id binary(20) NOT NULL, - PRIMARY KEY (service_id, selector_id) + service_uuid binary(16) NOT NULL, + selector_uuid binary(16) NOT NULL, + PRIMARY KEY (service_uuid, selector_uuid) ) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_bin; CREATE TABLE service_condition ( - service_id binary(20) NOT NULL, + service_uuid binary(16) NOT NULL, type varchar(255) COLLATE utf8mb4_unicode_ci NOT NULL, status enum('true', 'false', 'unknown') COLLATE utf8mb4_unicode_ci NOT NULL, observed_generation bigint unsigned NULL DEFAULT NULL, last_transition bigint unsigned NULL DEFAULT NULL, reason varchar(255) COLLATE utf8mb4_unicode_ci NOT NULL, message text, - PRIMARY KEY (service_id, type) + PRIMARY KEY (service_uuid, type) ) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_bin; CREATE TABLE service_port ( - service_id binary(20) NOT NULL, + service_uuid binary(16) NOT NULL, name varchar(255) COLLATE utf8mb4_unicode_ci NOT NULL, protocol enum('TCP', 'UDP', 'SCTP') COLLATE utf8mb4_general_ci NOT NULL, app_protocol varchar(255) COLLATE utf8mb4_unicode_ci NOT NULL, port int unsigned NOT NULL, target_port varchar(15) COLLATE utf8mb4_unicode_ci NOT NULL, node_port int unsigned NOT NULL, - PRIMARY KEY (service_id, name) + PRIMARY KEY (service_uuid, name) ) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_bin; CREATE TABLE endpoint_slice ( - id binary(20) NOT NULL, + uuid binary(16) NOT NULL, namespace varchar(63) COLLATE utf8mb4_unicode_ci NOT NULL, name varchar(253) COLLATE utf8mb4_unicode_ci NOT NULL, uid varchar(255) COLLATE utf8mb4_unicode_ci NOT NULL, resource_version varchar(255) NOT NULL, address_type enum('IPv4', 'IPv6', 'FQDN') COLLATE utf8mb4_general_ci NOT NULL, created bigint unsigned NOT NULL, - PRIMARY KEY (id) + PRIMARY KEY (uuid) ) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_bin; CREATE TABLE endpoint ( - id binary(20) NOT NULL, - endpoint_slice_id binary(20) NOT NULL, + uuid binary(16) NOT NULL, + endpoint_slice_uuid binary(16) NOT NULL, host_name varchar(253) COLLATE utf8mb4_unicode_ci NOT NULL, node_name varchar(253) COLLATE utf8mb4_unicode_ci NOT NULL, ready enum('n', 'y') COLLATE utf8mb4_unicode_ci NULL DEFAULT NULL, @@ -274,75 +274,75 @@ CREATE TABLE endpoint ( port int unsigned NOT NULL, port_name varchar(253) COLLATE utf8mb4_unicode_ci NOT NULL, app_protocol varchar(253) COLLATE utf8mb4_unicode_ci NOT NULL, - PRIMARY KEY (id) + PRIMARY KEY (uuid) ) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_bin; CREATE TABLE endpoint_target_ref ( - endpoint_slice_id binary(20) NOT NULL, + endpoint_slice_uuid binary(16) NOT NULL, kind enum('pod', 'node') COLLATE utf8mb4_unicode_ci NULL DEFAULT NULL, namespace varchar(63) COLLATE utf8mb4_unicode_ci NOT NULL, name varchar(255) COLLATE utf8mb4_unicode_ci NOT NULL, uid varchar(255) COLLATE utf8mb4_unicode_ci NOT NULL, api_version varchar(255) COLLATE utf8mb4_unicode_ci NOT NULL, resource_version varchar(255) COLLATE utf8mb4_unicode_ci NOT NULL, - PRIMARY KEY (endpoint_slice_id) + PRIMARY KEY (endpoint_slice_uuid) ) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_bin; CREATE TABLE endpoint_slice_label ( - endpoint_slice_id binary(20) NOT NULL, - label_id binary(20) NOT NULL, - PRIMARY KEY (endpoint_slice_id, label_id) + endpoint_slice_uuid binary(16) NOT NULL, + label_uuid binary(16) NOT NULL, + PRIMARY KEY (endpoint_slice_uuid, label_uuid) ) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_bin; CREATE TABLE ingress ( - id binary(20) NOT NULL, + uuid binary(16) NOT NULL, namespace varchar(63) COLLATE utf8mb4_unicode_ci NOT NULL, name varchar(63) COLLATE utf8mb4_unicode_ci NOT NULL, uid varchar(255) COLLATE utf8mb4_unicode_ci NOT NULL, resource_version varchar(255) NOT NULL, created bigint unsigned NOT NULL, - PRIMARY KEY (id) + PRIMARY KEY (uuid) ) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_bin; CREATE TABLE ingress_tls ( - ingress_id binary(20) NOT NULL, + ingress_uuid binary(16) NOT NULL, tls_host varchar(255) COLLATE utf8mb4_unicode_ci NOT NULL, tls_secret varchar(255) COLLATE utf8mb4_unicode_ci NULL DEFAULT NULL, - PRIMARY KEY (ingress_id) + PRIMARY KEY (ingress_uuid) ) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_bin; CREATE TABLE ingress_backend_service ( - service_id binary(20) NOT NULL, - ingress_id binary(20) NOT NULL, - ingress_rule_id binary(20) NULL DEFAULT NULL, + service_uuid binary(16) NOT NULL, + ingress_uuid binary(16) NOT NULL, + ingress_rule_uuid binary(16) NULL DEFAULT NULL, service_name varchar(255) COLLATE utf8mb4_unicode_ci NOT NULL, service_port_name varchar(255) COLLATE utf8mb4_unicode_ci NULL DEFAULT NULL, service_port_number int unsigned NULL DEFAULT NULL, - PRIMARY KEY (service_id, ingress_id) + PRIMARY KEY (service_uuid, ingress_uuid) ) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_bin; CREATE TABLE ingress_backend_resource ( - resource_id binary(20) NOT NULL, - ingress_id binary(20) NOT NULL, - ingress_rule_id binary(20) NULL DEFAULT NULL, + resource_uuid binary(16) NOT NULL, + ingress_uuid binary(16) NOT NULL, + ingress_rule_uuid binary(16) NULL DEFAULT NULL, api_group varchar(255) COLLATE utf8mb4_unicode_ci NULL DEFAULT NULL, kind varchar(255) COLLATE utf8mb4_unicode_ci NOT NULL, name varchar(255) COLLATE utf8mb4_unicode_ci NOT NULL, - PRIMARY KEY (resource_id, ingress_id) + PRIMARY KEY (resource_uuid, ingress_uuid) ) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_bin; CREATE TABLE ingress_rule ( - id binary(20) NOT NULL, - backend_id binary(20) NOT NULL, - ingress_id binary(20) NOT NULL, + uuid binary(16) NOT NULL, + backend_uuid binary(16) NOT NULL, + ingress_uuid binary(16) NOT NULL, host varchar(255) COLLATE utf8mb4_unicode_ci NOT NULL, path varchar(255) COLLATE utf8mb4_unicode_ci NULL DEFAULT NULL, path_type varchar(255) COLLATE utf8mb4_unicode_ci NULL DEFAULT NULL, - PRIMARY KEY (id) + PRIMARY KEY (uuid) ) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_bin; CREATE TABLE replica_set ( - id binary(20) NOT NULL, + uuid binary(16) NOT NULL, namespace varchar(63) COLLATE utf8mb4_unicode_ci NOT NULL, name varchar(253) COLLATE utf8mb4_unicode_ci NOT NULL, uid varchar(255) COLLATE utf8mb4_unicode_ci NOT NULL, @@ -354,31 +354,31 @@ CREATE TABLE replica_set ( ready_replicas int unsigned NOT NULL, available_replicas int unsigned NOT NULL, created bigint unsigned NOT NULL, - PRIMARY KEY (id) + PRIMARY KEY (uuid) ) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_bin; CREATE TABLE replica_set_condition ( - replica_set_id binary(20) NOT NULL, + replica_set_uuid binary(16) NOT NULL, type enum('replica_failure') COLLATE utf8mb4_unicode_ci NOT NULL, status varchar(255) COLLATE utf8mb4_unicode_ci NOT NULL, last_transition bigint unsigned NOT NULL, reason varchar(255) COLLATE utf8mb4_unicode_ci NOT NULL, message text, - PRIMARY KEY (replica_set_id, type) + PRIMARY KEY (replica_set_uuid, type) ) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_bin; CREATE TABLE replica_set_owner ( - replica_set_id binary(20) NOT NULL, + replica_set_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_id, uid) + PRIMARY KEY (replica_set_uuid, uid) ) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_bin; CREATE TABLE daemon_set ( - id binary(20) NOT NULL, + uuid binary(16) NOT NULL, namespace varchar(63) COLLATE utf8mb4_unicode_ci NOT NULL, name varchar(253) COLLATE utf8mb4_unicode_ci NOT NULL, uid varchar(255) COLLATE utf8mb4_unicode_ci NOT NULL, @@ -393,21 +393,21 @@ CREATE TABLE daemon_set ( number_available int unsigned NOT NULL, number_unavailable int unsigned NOT NULL, created bigint unsigned NOT NULL, - PRIMARY KEY (id) + PRIMARY KEY (uuid) ) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_bin; CREATE TABLE daemon_set_condition ( - daemon_set_id binary(20) NOT NULL, + daemon_set_uuid binary(16) NOT NULL, type varchar(255) COLLATE utf8mb4_unicode_ci NOT NULL, status varchar(255) COLLATE utf8mb4_unicode_ci NOT NULL, last_transition bigint unsigned NOT NULL, reason varchar(255) COLLATE utf8mb4_unicode_ci NOT NULL, message text, - PRIMARY KEY (daemon_set_id, type) + PRIMARY KEY (daemon_set_uuid, type) ) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_bin; CREATE TABLE stateful_set ( - id binary(20) NOT NULL, + uuid binary(16) NOT NULL, namespace varchar(63) COLLATE utf8mb4_unicode_ci NOT NULL, name varchar(253) COLLATE utf8mb4_unicode_ci NOT NULL, uid varchar(255) COLLATE utf8mb4_unicode_ci NOT NULL, @@ -426,21 +426,21 @@ CREATE TABLE stateful_set ( updated_replicas int unsigned NOT NULL, available_replicas int unsigned NOT NULL, created bigint unsigned NOT NULL, - PRIMARY KEY (id) + PRIMARY KEY (uuid) ) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_bin; CREATE TABLE stateful_set_condition ( - stateful_set_id binary(20) NOT NULL, + stateful_set_uuid binary(16) NOT NULL, type varchar(255) COLLATE utf8mb4_unicode_ci NOT NULL, status varchar(255) COLLATE utf8mb4_unicode_ci NOT NULL, last_transition bigint unsigned NOT NULL, reason varchar(255) COLLATE utf8mb4_unicode_ci NOT NULL, message text, - PRIMARY KEY (stateful_set_id, type) + PRIMARY KEY (stateful_set_uuid, type) ) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_bin; CREATE TABLE secret ( - id binary(20) NOT NULL, + uuid binary(16) NOT NULL, namespace varchar(63) COLLATE utf8mb4_unicode_ci NOT NULL, name varchar(253) COLLATE utf8mb4_unicode_ci NOT NULL, uid varchar(255) COLLATE utf8mb4_unicode_ci NOT NULL, @@ -448,114 +448,114 @@ CREATE TABLE secret ( type varchar(255) COLLATE utf8mb4_unicode_ci NOT NULL, immutable enum('n', 'y') COLLATE utf8mb4_unicode_ci NOT NULL, created bigint unsigned NOT NULL, - PRIMARY KEY (id) + PRIMARY KEY (uuid) ) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_bin; CREATE TABLE config_map ( - id binary(20) NOT NULL, + uuid binary(16) NOT NULL, namespace varchar(63) COLLATE utf8mb4_unicode_ci NOT NULL, name varchar(253) COLLATE utf8mb4_unicode_ci NOT NULL, uid varchar(255) COLLATE utf8mb4_unicode_ci NOT NULL, resource_version varchar(255) NOT NULL, immutable enum('n', 'y') COLLATE utf8mb4_unicode_ci NOT NULL, created bigint unsigned NOT NULL, - PRIMARY KEY (id) + PRIMARY KEY (uuid) ) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_bin; CREATE TABLE data ( - id binary(20) NOT NULL, + uuid binary(16) NOT NULL, name varchar(253) COLLATE utf8mb4_unicode_ci NOT NULL, value mediumblob NOT NULL, - PRIMARY KEY (id) + PRIMARY KEY (uuid) ) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_bin; CREATE TABLE secret_data ( - secret_id binary(20) NOT NULL, - data_id binary(20) NOT NULL, - PRIMARY KEY (secret_id, data_id) + secret_uuid binary(16) NOT NULL, + data_uuid binary(16) NOT NULL, + PRIMARY KEY (secret_uuid, data_uuid) ) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_bin; CREATE TABLE config_map_data ( - config_map_id binary(20) NOT NULL, - data_id binary(20) NOT NULL, - PRIMARY KEY (config_map_id, data_id) + config_map_uuid binary(16) NOT NULL, + data_uuid binary(16) NOT NULL, + PRIMARY KEY (config_map_uuid, data_uuid) ) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_bin; CREATE TABLE label ( - id binary(20) NOT NULL, + uuid binary(16) NOT NULL, name varchar(63) COLLATE utf8mb4_unicode_ci NOT NULL, value varchar(255) COLLATE utf8mb4_unicode_ci NOT NULL, - PRIMARY KEY (id) + PRIMARY KEY (uuid) ) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_bin; CREATE TABLE pod_label ( - pod_id binary(20) NOT NULL, - label_id binary(20) NOT NULL, - PRIMARY KEY (pod_id, label_id) + pod_uuid binary(16) NOT NULL, + label_uuid binary(16) NOT NULL, + PRIMARY KEY (pod_uuid, label_uuid) ) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_bin; CREATE TABLE replica_set_label ( - replica_set_id binary(20) NOT NULL, - label_id binary(20) NOT NULL, - PRIMARY KEY (replica_set_id, label_id) + replica_set_uuid binary(16) NOT NULL, + label_uuid binary(16) NOT NULL, + PRIMARY KEY (replica_set_uuid, label_uuid) ) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_bin; CREATE TABLE deployment_label ( - deployment_id binary(20) NOT NULL, - label_id binary(20) NOT NULL, - PRIMARY KEY (deployment_id, label_id) + deployment_uuid binary(16) NOT NULL, + label_uuid binary(16) NOT NULL, + PRIMARY KEY (deployment_uuid, label_uuid) ) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_bin; CREATE TABLE daemon_set_label ( - daemon_set_id binary(20) NOT NULL, - label_id binary(20) NOT NULL, - PRIMARY KEY (daemon_set_id, label_id) + daemon_set_uuid binary(16) NOT NULL, + label_uuid binary(16) NOT NULL, + PRIMARY KEY (daemon_set_uuid, label_uuid) ) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_bin; CREATE TABLE stateful_set_label ( - stateful_set_id binary(20) NOT NULL, - label_id binary(20) NOT NULL, - PRIMARY KEY (stateful_set_id, label_id) + stateful_set_uuid binary(16) NOT NULL, + label_uuid binary(16) NOT NULL, + PRIMARY KEY (stateful_set_uuid, label_uuid) ) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_bin; CREATE TABLE pvc_label ( - pvc_id binary(20) NOT NULL, - label_id binary(20) NOT NULL, - PRIMARY KEY (pvc_id, label_id) + pvc_uuid binary(16) NOT NULL, + label_uuid binary(16) NOT NULL, + PRIMARY KEY (pvc_uuid, label_uuid) ) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_bin; CREATE TABLE namespace_label ( - namespace_id binary(20) NOT NULL, - label_id binary(20) NOT NULL, - PRIMARY KEY (namespace_id, label_id) + namespace_uuid binary(16) NOT NULL, + label_uuid binary(16) NOT NULL, + PRIMARY KEY (namespace_uuid, label_uuid) ) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_bin; CREATE TABLE node_label ( - node_id binary(20) NOT NULL, - label_id binary(20) NOT NULL, - PRIMARY KEY (node_id, label_id) + node_uuid binary(16) NOT NULL, + label_uuid binary(16) NOT NULL, + PRIMARY KEY (node_uuid, label_uuid) ) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_bin; CREATE TABLE secret_label ( - secret_id binary(20) NOT NULL, - label_id binary(20) NOT NULL, - PRIMARY KEY (secret_id, label_id) + secret_uuid binary(16) NOT NULL, + label_uuid binary(16) NOT NULL, + PRIMARY KEY (secret_uuid, label_uuid) ) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_bin; CREATE TABLE config_map_label ( - config_map_id binary(20) NOT NULL, - label_id binary(20) NOT NULL, - PRIMARY KEY (config_map_id, label_id) + config_map_uuid binary(16) NOT NULL, + label_uuid binary(16) NOT NULL, + PRIMARY KEY (config_map_uuid, label_uuid) ) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_bin; CREATE TABLE service_label ( - service_id binary(20) NOT NULL, - label_id binary(20) NOT NULL, - PRIMARY KEY (service_id, label_id) + service_uuid binary(16) NOT NULL, + label_uuid binary(16) NOT NULL, + PRIMARY KEY (service_uuid, label_uuid) ) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_bin; CREATE TABLE event ( - id binary(20) NOT NULL, + uuid binary(16) NOT NULL, namespace varchar(63) NOT NULL, name varchar(270) NOT NULL, uid varchar(255) NOT NULL, @@ -573,7 +573,7 @@ CREATE TABLE event ( last_seen bigint unsigned NOT NULL, count int unsigned NOT NULL, created bigint unsigned NOT NULL, - PRIMARY KEY (id) + PRIMARY KEY (uuid) ) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_bin; CREATE TABLE pod_metrics ( @@ -590,7 +590,7 @@ CREATE TABLE pod_metrics ( ) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_bin; CREATE TABLE pvc ( - id binary(20) NOT NULL, + uuid binary(16) NOT NULL, namespace varchar(63) COLLATE utf8mb4_unicode_ci NOT NULL, name varchar(253) COLLATE utf8mb4_unicode_ci NOT NULL, uid varchar(255) COLLATE utf8mb4_unicode_ci NOT NULL, @@ -604,22 +604,22 @@ CREATE TABLE pvc ( volume_mode enum('block', 'filesystem') COLLATE utf8mb4_unicode_ci NULL DEFAULT NULL, storage_class varchar(255) COLLATE utf8mb4_unicode_ci NULL DEFAULT NULL, created bigint unsigned NOT NULL, - PRIMARY KEY (id) + PRIMARY KEY (uuid) ) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_bin; CREATE TABLE pvc_condition ( - pvc_id binary(20) NOT NULL, + pvc_uuid binary(16) NOT NULL, type varchar(255) COLLATE utf8mb4_unicode_ci NOT NULL, status varchar(255) COLLATE utf8mb4_unicode_ci NOT NULL, last_probe bigint unsigned NULL DEFAULT NULL, last_transition bigint unsigned NOT NULL, reason varchar(255) COLLATE utf8mb4_unicode_ci NOT NULL, message text, - PRIMARY KEY (pvc_id, type) + PRIMARY KEY (pvc_uuid, type) ) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_bin; CREATE TABLE persistent_volume ( - id binary(20) NOT NULL, + uuid binary(16) NOT NULL, namespace varchar(63) COLLATE utf8mb4_unicode_ci NOT NULL, name varchar(253) COLLATE utf8mb4_unicode_ci NOT NULL, uid varchar(255) COLLATE utf8mb4_unicode_ci NOT NULL, @@ -635,19 +635,19 @@ CREATE TABLE persistent_volume ( volume_source longtext NOT NULL, reclaim_policy enum('recycle', 'delete', 'retain') COLLATE utf8mb4_unicode_ci NOT NULL, created bigint unsigned NOT NULL, - PRIMARY KEY (id) + PRIMARY KEY (uuid) ) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_bin; CREATE TABLE persistent_volume_claim_ref ( - persistent_volume_id binary(20) NOT NULL, + persistent_volume_uuid binary(16) NOT NULL, kind varchar(255) COLLATE utf8mb4_unicode_ci NOT NULL, name varchar(253) COLLATE utf8mb4_unicode_ci NOT NULL, uid varchar(255) COLLATE utf8mb4_unicode_ci NOT NULL, - PRIMARY KEY (persistent_volume_id, uid) + PRIMARY KEY (persistent_volume_uuid, uid) ) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_bin; CREATE TABLE job ( - id binary(20) NOT NULL, + uuid binary(16) NOT NULL, namespace varchar(63) COLLATE utf8mb4_unicode_ci NOT NULL, name varchar(63) COLLATE utf8mb4_unicode_ci NOT NULL, uid varchar(255) COLLATE utf8mb4_unicode_ci NOT NULL, @@ -665,28 +665,28 @@ CREATE TABLE job ( succeeded int unsigned NOT NULL, failed int unsigned NOT NULL, created bigint unsigned NOT NULL, - PRIMARY KEY (id) + PRIMARY KEY (uuid) ) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_bin; CREATE TABLE job_condition ( - job_id binary(20) NOT NULL, + job_uuid binary(16) NOT NULL, type enum('suspended', 'complete', 'failed', 'failure_target') COLLATE utf8mb4_unicode_ci NOT NULL, status enum('true', 'false', 'unknown') COLLATE utf8mb4_unicode_ci NOT NULL, last_probe bigint unsigned NULL DEFAULT NULL, last_transition bigint unsigned NOT NULL, reason varchar(255) COLLATE utf8mb4_unicode_ci NOT NULL, message text, - PRIMARY KEY (job_id, type) + PRIMARY KEY (job_uuid, type) ) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_bin; CREATE TABLE job_label ( - job_id binary(20) NOT NULL, - label_id binary(20) NOT NULL, - PRIMARY KEY (job_id, label_id) + job_uuid binary(16) NOT NULL, + label_uuid binary(16) NOT NULL, + PRIMARY KEY (job_uuid, label_uuid) ) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_bin; CREATE TABLE cron_job ( - id binary(20) NOT NULL, + uuid binary(16) NOT NULL, namespace varchar(63) COLLATE utf8mb4_unicode_ci NOT NULL, name varchar(63) COLLATE utf8mb4_unicode_ci NOT NULL, uid varchar(255) COLLATE utf8mb4_unicode_ci NOT NULL, @@ -702,13 +702,13 @@ CREATE TABLE cron_job ( last_schedule_time bigint unsigned NULL DEFAULT NULL, last_successful_time bigint unsigned NULL DEFAULT NULL, created bigint unsigned NOT NULL, - PRIMARY KEY (id) + PRIMARY KEY (uuid) ) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_bin; CREATE TABLE cron_job_label ( - cron_job_id binary(20) NOT NULL, - label_id binary(20) NOT NULL, - PRIMARY KEY (cron_job_id, label_id) + cron_job_uuid binary(16) NOT NULL, + label_uuid binary(16) NOT NULL, + PRIMARY KEY (cron_job_uuid, label_uuid) ) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_bin; CREATE TABLE kubernetes_schema (