Skip to content

Commit

Permalink
Merge pull request #520 from vshn/fix-billing-cronjobs
Browse files Browse the repository at this point in the history
Fix billing query
  • Loading branch information
zugao authored Oct 28, 2024
2 parents eed0d48 + 96a8b6b commit ba33c2f
Show file tree
Hide file tree
Showing 6 changed files with 85 additions and 76 deletions.
7 changes: 4 additions & 3 deletions component/billing.jsonnet
Original file line number Diff line number Diff line change
Expand Up @@ -148,7 +148,8 @@ local backfillCJ = function(name, query, sla, type)
},
},
},
failedJobsHistoryLimit: 10,
failedJobsHistoryLimit: 3,
successfulJobsHistoryLimit: 0,
},
};

Expand All @@ -157,8 +158,8 @@ local generateCloudAndManaged = function(name)
// For postgresql we have a missmatch between the label and the name in our definition.
local queryName = if name == 'postgres' then name + 'ql' else name;

local managedQuery = 'sum_over_time(appcat:metering{label_appuio_io_billing_name="appcat-' + queryName + '",label_appcat_vshn_io_sla="%s", tenant_name!="APPUiO"}[59:1])/60';
local cloudQuery = 'sum_over_time(appcat:metering{label_appuio_io_billing_name="appcat-' + queryName + '",label_appcat_vshn_io_sla="%s", tenant_name="APPUiO"} * on(label_appuio_io_organization) group_left(sales_order) label_replace(appuio_control_organization_info{namespace="appuio-control-api-production"}, "label_appuio_io_organization", "$1", "organization", "(.*)")[59:1])/60';
local managedQuery = 'sum_over_time(appcat:metering{label_appuio_io_billing_name="appcat-' + queryName + '",label_appcat_vshn_io_sla="%s", tenant_name!="APPUiO"}[59m:1m])/60';
local cloudQuery = 'sum_over_time(appcat:metering{label_appuio_io_billing_name="appcat-' + queryName + '",label_appcat_vshn_io_sla="%s", tenant_name="APPUiO"} * on(label_appuio_io_organization) group_left(sales_order) label_replace(appuio_control_organization_info{namespace="appuio-control-api-production"}, "label_appuio_io_organization", "$1", "organization", "(.*)")[59m:1m])/60';

local permutations = [
{
Expand Down
7 changes: 6 additions & 1 deletion component/main.jsonnet
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ local slos = import 'slos.libsonnet';
local inv = kap.inventory();
local params = inv.parameters.appcat;
local pgParams = params.services.vshn.postgres;
local appuioManaged = inv.parameters.appcat.appuioManaged;

local xrdBrowseRole = kube.ClusterRole('appcat:browse') + {
metadata+: {
Expand Down Expand Up @@ -85,7 +86,11 @@ local ns = kube.Namespace(params.namespace) {
labels+: {
'openshift.io/cluster-monitoring': 'true',
} + params.namespaceLabels,
annotations+: params.namespaceAnnotations,
annotations+:
if !appuioManaged then {
'resourcequota.appuio.io/organization-objects.jobs': '300',
} + params.namespaceAnnotations
else params.namespaceAnnotations,
},
};

Expand Down
Loading

0 comments on commit ba33c2f

Please sign in to comment.