Skip to content

Commit 3fc1113

Browse files
committed
Merge branch '20250212-fixes' into 'main-1.15'
Release 1.15.1 fixes See merge request ongresinc/stackgres!1652
2 parents df0e95c + a48c2eb commit 3fc1113

66 files changed

Lines changed: 955 additions & 181 deletions

File tree

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

stackgres-k8s/install/helm/stackgres-operator/templates/check-upgrade.yaml

Lines changed: 21 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -9,36 +9,40 @@
99
{{ $version := $deployment.metadata.labels.version }}
1010
{{ if not .Values.forceUpgradeFromUnsupportedVersion }}
1111
{{ if or (not (regexMatch "^(1\\.13|1\\.14|1\\.15)\\." $version)) (and (not (eq $version $chart.Version)) (regexMatch "(-alpha[0-9]|-beta[0-9])" $version)) }}
12-
{{ fail (print "Upgrading from version " $version " version is not supported. You may force upgrading from an unsupported version setting the parameter \"forceUpgradeFromUnsupportedVersion\" to \"true\". If you do so do it at your own risk. It has not been tested and some functionality may break. If you are conscious of the risk of such a dangerous action we recommend to perform security upgrades of all your SGCluster and SGShardedCluster as soon as possible after upgrading from an unsupported version of the operator upgrade") }}
12+
{{ fail (print "Upgrading from version " $version " version is not supported. You may force upgrading from an unsupported version setting the parameter \"forceUpgradeFromUnsupportedVersion\" to \"true\". If you do so do it at your own risk. It has not been tested and some or all functionalities may break. Note that after proceeding you will have to change the value of `stackgres.io/operatorVersion` annotation of all your SGClusters and SGShardedClusters to the target operator version you want to upgrade to and, as soon as possible perform a restart SGDbOps or SGShardedDbOps of all your SGClusters and SGShardedClusters. Before assuming the risk of such a dangerous action we strongly recommend to perform this operation in a staging environment as close as possible to your production environment.") }}
1313
{{ end }}
1414
{{ end }}
1515
{{ end }}
1616
{{ end }}
1717
{{ end }}
18-
{{ $clusters := lookup "stackgres.io/v1" "SGCluster" "" "" }}
19-
{{ if $clusters }}
20-
{{ if $clusters.items }}
21-
{{ range $cluster := $clusters.items }}
22-
{{ if $cluster.metadata.annotations }}
23-
{{ if (index $cluster.metadata.annotations "stackgres.io/operatorVersion") }}
24-
{{ $version := (index $cluster.metadata.annotations "stackgres.io/operatorVersion") }}
18+
{{ $shardedclusters := lookup "stackgres.io/v1alpha1" "SGShardedCluster" "" "" }}
19+
{{ if $shardedclusters }}
20+
{{ if $shardedclusters.items }}
21+
{{ range $shardedcluster := $shardedclusters.items }}
22+
{{ if $shardedcluster.metadata.annotations }}
23+
{{ if (index $shardedcluster.metadata.annotations "stackgres.io/operatorVersion") }}
24+
{{ $version := (index $shardedcluster.metadata.annotations "stackgres.io/operatorVersion") }}
2525
{{ if (not (regexMatch "^(1\\.13|1\\.14|1\\.15)\\." $version)) }}
26-
{{ fail (print "Can not upgrade due to some SGCluster still at version " $version ". You have to run a SGDbOps of type securityUpgrade on those SGClusters first.") }}
26+
{{ if not .Values.forceUpgradeFromUnsupportedVersion }}
27+
{{ fail (print "Can not upgrade due to some SGShardedCluster still at version " $version ". You have to run a SGShardedDbOps of type securityUpgrade on those SGShardedClusters first.") }}
28+
{{ end }}
2729
{{ end }}
2830
{{ end }}
2931
{{ end }}
3032
{{ end }}
3133
{{ end }}
3234
{{ end }}
33-
{{ $shardedclusters := lookup "stackgres.io/v1" "SGShardedCluster" "" "" }}
34-
{{ if $shardedclusters }}
35-
{{ if $shardedclusters.items }}
36-
{{ range $shardedcluster := $shardedclusters.items }}
37-
{{ if $shardedcluster.metadata.annotations }}
38-
{{ if (index $shardedcluster.metadata.annotations "stackgres.io/operatorVersion") }}
39-
{{ $version := (index $shardedcluster.metadata.annotations "stackgres.io/operatorVersion") }}
35+
{{ $clusters := lookup "stackgres.io/v1" "SGCluster" "" "" }}
36+
{{ if $clusters }}
37+
{{ if $clusters.items }}
38+
{{ range $cluster := $clusters.items }}
39+
{{ if $cluster.metadata.annotations }}
40+
{{ if (index $cluster.metadata.annotations "stackgres.io/operatorVersion") }}
41+
{{ $version := (index $cluster.metadata.annotations "stackgres.io/operatorVersion") }}
4042
{{ if (not (regexMatch "^(1\\.13|1\\.14|1\\.15)\\." $version)) }}
41-
{{ fail (print "Can not upgrade due to some SGShardedCluster still at version " $version ". You have to run a SGShardedDbOps of type securityUpgrade on those SGShardedClusters first.") }}
43+
{{ if not .Values.forceUpgradeFromUnsupportedVersion }}
44+
{{ fail (print "Can not upgrade due to some SGCluster still at version " $version ". You have to run a SGDbOps of type securityUpgrade on those SGClusters first.") }}
45+
{{ end }}
4246
{{ end }}
4347
{{ end }}
4448
{{ end }}

stackgres-k8s/install/helm/stackgres-operator/values.yaml

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -546,6 +546,12 @@ developer:
546546
# -- Pod's container volume mounts. See https://kubernetes.io/docs/reference/generated/kubernetes-api/v1.27/#volumemount-v1-core
547547
volumeMounts: []
548548
# Section to define volumes to be used by the distributedlogs controller container
549+
# Section to define volumes to be used by the stream container
550+
stream:
551+
# -- Pod volumes. See https://kubernetes.io/docs/reference/generated/kubernetes-api/v1.27/#volume-v1-core
552+
volumes: []
553+
# -- Pod's container volume mounts. See https://kubernetes.io/docs/reference/generated/kubernetes-api/v1.27/#volumemount-v1-core
554+
volumeMounts: []
549555
# -- The list of fields that are serialized into the spec of SGConfig
550556
specFields: [
551557
containerRegistry, imagePullPolicy, imagePullSecrets, allowedNamespaces, allowedNamespaceLabelSelector,
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
/*
2+
* Copyright (C) 2019 OnGres, Inc.
3+
* SPDX-License-Identifier: AGPL-3.0-or-later
4+
*/
5+
6+
package io.stackgres.cluster.configuration;
7+
8+
import javax.management.MalformedObjectNameException;
9+
10+
import io.stackgres.common.ClusterControllerProperty;
11+
import io.stackgres.common.metrics.AbstractJmxCollectorRegistry;
12+
import jakarta.inject.Singleton;
13+
14+
@Singleton
15+
public class ClusterControllerJmxCollectorRegistry extends AbstractJmxCollectorRegistry {
16+
17+
public ClusterControllerJmxCollectorRegistry() throws MalformedObjectNameException {
18+
super(ClusterControllerProperty.CLUSTER_CONTROLLER_JMX_COLLECTOR_YAML_CONFIG
19+
.get().orElse(""));
20+
}
21+
22+
}

stackgres-k8s/src/cluster-controller/src/main/resources/application.properties

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -38,3 +38,6 @@ quarkus.http.auth.basic=true
3838
org.jooq.no-logo=true
3939
quarkus.log.category."org.jooq.Constants".level=OFF
4040
quarkus.log.category."org.jooq.tools.LoggerListener".level=OFF
41+
42+
# Use custom micrometer producer
43+
quarkus.micrometer.export.prometheus.default-registry=false

stackgres-k8s/src/common/pom.xml

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -45,6 +45,14 @@
4545
<groupId>com.ongres</groupId>
4646
<artifactId>fluent-process</artifactId>
4747
</dependency>
48+
<dependency>
49+
<groupId>io.quarkus</groupId>
50+
<artifactId>quarkus-micrometer-registry-prometheus</artifactId>
51+
</dependency>
52+
<dependency>
53+
<groupId>io.prometheus.jmx</groupId>
54+
<artifactId>collector</artifactId>
55+
</dependency>
4856

4957
<dependency>
5058
<groupId>io.stackgres</groupId>

stackgres-k8s/src/common/src/main/java/io/stackgres/common/ClusterControllerProperty.java

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,9 @@ public enum ClusterControllerProperty implements StackGresPropertyReader {
2626
CLUSTER_CONTROLLER_RECONCILE_MANAGED_SQL(
2727
"stackgres.clusterReconcileManagedSql"),
2828
CLUSTER_CONTROLLER_RECONCILE_PATRONI_AFTER_MAJOR_VERSION_UPGRADE(
29-
"stackgres.clusterReconcilePatroniAfterMajorVersionUpgrade");
29+
"stackgres.clusterReconcilePatroniAfterMajorVersionUpgrade"),
30+
CLUSTER_CONTROLLER_JMX_COLLECTOR_YAML_CONFIG(
31+
"stackgres.cluster.controllerJmxCollectorYamlConfig");
3032

3133
private static final Properties APPLICATION_PROPERTIES =
3234
StackGresPropertyReader.readApplicationProperties(ClusterControllerProperty.class);

stackgres-k8s/src/common/src/main/java/io/stackgres/common/OperatorProperty.java

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -45,10 +45,15 @@ public enum OperatorProperty implements StackGresPropertyReader {
4545
CLUSTER_ROLE_DISABLED("stackgres.clusterRoleDisabled"),
4646
FORCE_UNLOCK_OPERATOR("stackgres.forceUnlockOperator"),
4747
STOP_AFTER_BOOTSTRAP("stackgres.stopAfterBootstrap"),
48+
RECONCILIATION_ENABLE_THREAD_POOL("stackgres.reconciliationEnableThreadPool"),
49+
RECONCILIATION_THREAD_POOL_METRICS_SCRAPE_INTERVAL("stackgres.reconciliationThreadPoolMetricsScrapeInterval"),
4850
RECONCILIATION_THREADS("stackgres.reconciliationThreads"),
51+
RECONCILIATION_LOW_PRIORITY_THREADS("stackgres.reconciliationLowPriorityThreads"),
52+
RECONCILIATION_PRIORITY_TIMEOUT("stackgres.reconciliationPriorityTimeout"),
4953
RECONCILIATION_INITIAL_BACKOFF("stackgres.reconciliationInitialBackoff"),
5054
RECONCILIATION_MAX_BACKOFF("stackgres.reconciliationMaxBackoff"),
51-
RECONCILIATION_BACKOFF_VARIATION("stackgres.reconciliationBackoffVariation");
55+
RECONCILIATION_BACKOFF_VARIATION("stackgres.reconciliationBackoffVariation"),
56+
JMX_COLLECTOR_YAML_CONFIG("stackgres.jmxCollectorYamlConfig");
5257

5358
private static final Properties APPLICATION_PROPERTIES =
5459
StackGresPropertyReader.readApplicationProperties(OperatorProperty.class);
Lines changed: 45 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,45 @@
1+
/*
2+
* Copyright (C) 2019 OnGres, Inc.
3+
* SPDX-License-Identifier: AGPL-3.0-or-later
4+
*/
5+
6+
package io.stackgres.common.metrics;
7+
8+
import java.io.ByteArrayOutputStream;
9+
import java.io.IOException;
10+
import java.io.OutputStreamWriter;
11+
import java.nio.charset.StandardCharsets;
12+
13+
import javax.management.MalformedObjectNameException;
14+
15+
import io.prometheus.jmx.JmxCollector;
16+
import io.prometheus.metrics.expositionformats.PrometheusTextFormatWriter;
17+
import io.prometheus.metrics.model.registry.PrometheusRegistry;
18+
import io.stackgres.common.CdiUtil;
19+
20+
public abstract class AbstractJmxCollectorRegistry {
21+
private final PrometheusRegistry collectorRegistry;
22+
private final PrometheusTextFormatWriter textFormatter = new PrometheusTextFormatWriter(true);
23+
24+
public AbstractJmxCollectorRegistry(String yamlConfig) throws MalformedObjectNameException {
25+
new JmxCollector(yamlConfig).register(PrometheusRegistry.defaultRegistry);
26+
this.collectorRegistry = PrometheusRegistry.defaultRegistry;
27+
}
28+
29+
public AbstractJmxCollectorRegistry() {
30+
CdiUtil.checkPublicNoArgsConstructorIsCalledToCreateProxy(getClass());
31+
this.collectorRegistry = null;
32+
}
33+
34+
public String scrape(String contentType) {
35+
try (
36+
ByteArrayOutputStream stream = new ByteArrayOutputStream();
37+
OutputStreamWriter writer = new OutputStreamWriter(stream, StandardCharsets.UTF_8)) {
38+
textFormatter.write(stream, collectorRegistry.scrape());
39+
return stream.toString(StandardCharsets.UTF_8);
40+
} catch (IOException e) {
41+
throw new RuntimeException(e);
42+
}
43+
}
44+
45+
}
Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,33 @@
1+
/*
2+
* Copyright (C) 2019 OnGres, Inc.
3+
* SPDX-License-Identifier: AGPL-3.0-or-later
4+
*/
5+
6+
package io.stackgres.common.metrics;
7+
8+
import io.micrometer.prometheus.PrometheusConfig;
9+
import io.micrometer.prometheus.PrometheusMeterRegistry;
10+
import jakarta.inject.Singleton;
11+
12+
@Singleton
13+
public class CustomPrometheusMeterRegistry extends PrometheusMeterRegistry {
14+
15+
private final AbstractJmxCollectorRegistry jmxCollectorRegistry;
16+
17+
public CustomPrometheusMeterRegistry(
18+
PrometheusConfig config,
19+
AbstractJmxCollectorRegistry jmxCollectorRegistry) {
20+
super(config);
21+
this.jmxCollectorRegistry = jmxCollectorRegistry;
22+
}
23+
24+
@Override
25+
public String scrape(String contentType) {
26+
StringBuilder sb = new StringBuilder();
27+
sb.append(super.scrape(contentType));
28+
if (jmxCollectorRegistry != null) {
29+
sb.append(jmxCollectorRegistry.scrape(contentType));
30+
}
31+
return sb.toString();
32+
}
33+
}

stackgres-k8s/src/jobs/src/main/java/io/stackgres/jobs/Main.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77

88
import io.quarkus.runtime.QuarkusApplication;
99
import io.quarkus.runtime.annotations.QuarkusMain;
10-
import io.stackgres.jobs.app.JobsProperty;
10+
import io.stackgres.jobs.configuration.JobsProperty;
1111
import io.stackgres.jobs.dbops.DbOpsLauncher;
1212
import jakarta.inject.Inject;
1313

0 commit comments

Comments
 (0)