Skip to content
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

[COST-3607] add node arch to reporting_ocp_node table #4960

Draft
wants to merge 4 commits into
base: main
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 6 additions & 6 deletions dev/scripts/nise_ymls/ocp/ocp_on_premise.yml
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ generators:
nodes:
- node:
node_name: compute_1
node_labels: label_instance-type:medium
node_labels: label_instance-type:medium|label_kubernetes_io_arch:amd64
cpu_cores: 4
memory_gig: 16
namespaces:
Expand Down Expand Up @@ -56,7 +56,7 @@ generators:
capacity_gig: 20
- node:
node_name: compute_2
node_labels: label_instance-type:small
node_labels: label_instance-type:small|label_kubernetes_io_arch:arm64
cpu_cores: 4
memory_gig: 16
namespaces:
Expand Down Expand Up @@ -106,7 +106,7 @@ generators:
capacity_gig: 20
- node:
node_name: compute_3
node_labels: label_nodeclass:compute|label_node_role_kubernetes_io:infra|label_instance-type:xsmall
node_labels: label_nodeclass:compute|label_node_role_kubernetes_io:infra|label_instance-type:xsmall|label_kubernetes_io_arch:s390x
cpu_cores: 4
memory_gig: 16
namespaces:
Expand Down Expand Up @@ -156,7 +156,7 @@ generators:
capacity_gig: 20
- node:
node_name: compute_4
node_labels: label_instance-type:large
node_labels: label_instance-type:large|label_kubernetes_io_arch:amd64
cpu_cores: 4
memory_gig: 16
namespaces:
Expand Down Expand Up @@ -206,7 +206,7 @@ generators:
capacity_gig: 20
- node:
node_name: compute_5
node_labels: label_instance-type:xlarge
node_labels: label_instance-type:xlarge|label_kubernetes_io_arch:ppc64le
cpu_cores: 4
memory_gig: 16
namespaces:
Expand Down Expand Up @@ -256,7 +256,7 @@ generators:
capacity_gig: 20
- node:
node_name: compute_6
node_labels: label_instance-type:xxlarge
node_labels: label_instance-type:xxlarge|label_kubernetes_io_arch:amd64
cpu_cores: 4
memory_gig: 16
namespaces:
Expand Down
12 changes: 9 additions & 3 deletions koku/masu/database/ocp_report_db_accessor.py
Original file line number Diff line number Diff line change
Expand Up @@ -904,12 +904,17 @@ def populate_node_table(self, cluster, nodes):
resource_id=node[1],
node_capacity_cpu_cores=node[2],
node_role=node[3],
architecture=node[4],
cluster=cluster,
)
# if the node entry already exists but does not have a role assigned, update the node role
elif not tmp_node.node_role:
if not tmp_node.node_role:
tmp_node.node_role = node[3]
tmp_node.save()
tmp_node.save(update_fields=["node_role"])
# if the node entry already exists but does not have an architecture, update the architecture
if not tmp_node.architecture:
tmp_node.architecture = node[4]
tmp_node.save(update_fields=["architecture"])

def populate_pvc_table(self, cluster, pvcs):
"""Get or create an entry in the OCP cluster table."""
Expand All @@ -933,7 +938,8 @@ def get_nodes_trino(self, source_uuid, start_date, end_date):
WHEN contains(array_agg(DISTINCT ocp.namespace), 'openshift-kube-apiserver') THEN 'master'
WHEN any_match(array_agg(DISTINCT nl.node_labels), element -> element like '%"node_role_kubernetes_io": "infra"%') THEN 'infra'
ELSE 'worker'
END) as node_role
END) as node_role,
lower(json_extract_scalar(max(node_labels), '$.kubernetes_io_arch')) as arch
FROM hive.{self.schema}.openshift_pod_usage_line_items_daily as ocp
LEFT JOIN hive.{self.schema}.openshift_node_labels_line_items_daily as nl
ON ocp.node = nl.node
Expand Down
17 changes: 17 additions & 0 deletions koku/reporting/migrations/0320_ocpnode_arch.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
# Generated by Django 4.2.10 on 2024-03-07 01:09
from django.db import migrations
from django.db import models


class Migration(migrations.Migration):
dependencies = [
("reporting", "0319_node_network_costs"),
]

operations = [
migrations.AddField(
model_name="ocpnode",
name="architecture",
field=models.TextField(null=True),
),
]
1 change: 1 addition & 0 deletions koku/reporting/provider/ocp/models.py
Original file line number Diff line number Diff line change
Expand Up @@ -268,6 +268,7 @@ class Meta:
node_capacity_cpu_cores = models.DecimalField(max_digits=18, decimal_places=2, null=True)
cluster = models.ForeignKey("OCPCluster", on_delete=models.CASCADE)
node_role = models.TextField(null=True)
architecture = models.TextField(null=True)


class OCPNetworkSummaryP(models.Model):
Expand Down
Loading