Search in sources :

Example 1 with StackGresPoolingConfigStatus

use of io.stackgres.common.crd.sgpooling.StackGresPoolingConfigStatus in project stackgres by ongres.

the class PgBouncerDefaultStateMutator method mutate.

@Override
public List<JsonPatchOperation> mutate(PoolingReview review) {
    List<JsonPatchOperation> operations = new ArrayList<>();
    StackGresPoolingConfig pgBouncerConfig = review.getRequest().getObject();
    if (pgBouncerConfig.getStatus() == null) {
        pgBouncerConfig.setStatus(new StackGresPoolingConfigStatus());
        operations.add(buildAddOperation(PG_BOUNCER_DEFAULT_PARAMETERS_POINTER.parent().parent(), MAPPER.createObjectNode()));
    }
    if (pgBouncerConfig.getStatus().getPgBouncer() == null) {
        pgBouncerConfig.getStatus().setPgBouncer(new StackGresPoolingConfigPgBouncerStatus());
        operations.add(buildAddOperation(PG_BOUNCER_DEFAULT_PARAMETERS_POINTER.parent(), MAPPER.createObjectNode()));
    }
    operations.addAll(mutate(PG_BOUNCER_DEFAULT_PARAMETERS_POINTER, pgBouncerConfig));
    return operations;
}
Also used : StackGresPoolingConfig(io.stackgres.common.crd.sgpooling.StackGresPoolingConfig) ArrayList(java.util.ArrayList) StackGresPoolingConfigPgBouncerStatus(io.stackgres.common.crd.sgpooling.StackGresPoolingConfigPgBouncerStatus) JsonPatchOperation(com.github.fge.jsonpatch.JsonPatchOperation) StackGresPoolingConfigStatus(io.stackgres.common.crd.sgpooling.StackGresPoolingConfigStatus)

Example 2 with StackGresPoolingConfigStatus

use of io.stackgres.common.crd.sgpooling.StackGresPoolingConfigStatus in project stackgres by ongres.

the class PoolingConfigTransformer method getResourceStatus.

private PoolingConfigStatus getResourceStatus(List<String> clusters, StackGresPoolingConfigStatus source, StackGresPoolingConfigSpec sourceSpec) {
    PoolingConfigStatus transformation = new PoolingConfigStatus();
    transformation.setClusters(clusters);
    transformation.setPgBouncer(new PoolingConfigPgBouncerStatus());
    transformation.getPgBouncer().setParameters(Seq.seq(sourceSpec.getPgBouncer().getPgbouncerIni().getParameters()).map(t -> t.concat(new PgBouncerIniParameter())).peek(t -> t.v3.setParameter(t.v1)).peek(t -> t.v3.setValue(t.v2)).map(Tuple3::v3).toList());
    if (source != null && source.getPgBouncer() != null) {
        transformation.getPgBouncer().setDefaultParameters(source.getPgBouncer().getDefaultParameters());
    }
    return transformation;
}
Also used : PoolingConfigPgBouncer(io.stackgres.apiweb.dto.pooling.PoolingConfigPgBouncer) PgBouncerIniParameter(io.stackgres.apiweb.dto.pooling.PgBouncerIniParameter) HashMap(java.util.HashMap) StackGresPoolingConfigStatus(io.stackgres.common.crd.sgpooling.StackGresPoolingConfigStatus) Seq(org.jooq.lambda.Seq) PoolingConfigPgBouncerStatus(io.stackgres.apiweb.dto.pooling.PoolingConfigPgBouncerStatus) StackGresPoolingConfigPgBouncer(io.stackgres.common.crd.sgpooling.StackGresPoolingConfigPgBouncer) Matcher(java.util.regex.Matcher) Tuple3(org.jooq.lambda.tuple.Tuple3) PoolingConfigDto(io.stackgres.apiweb.dto.pooling.PoolingConfigDto) Map(java.util.Map) SubnodeConfiguration(org.apache.commons.configuration2.SubnodeConfiguration) StackGresPoolingConfigSpec(io.stackgres.common.crd.sgpooling.StackGresPoolingConfigSpec) INIConfiguration(org.apache.commons.configuration2.INIConfiguration) Iterator(java.util.Iterator) StackGresPoolingConfigPgBouncerPgbouncerIni(io.stackgres.common.crd.sgpooling.StackGresPoolingConfigPgBouncerPgbouncerIni) StringWriter(java.io.StringWriter) Set(java.util.Set) IOException(java.io.IOException) StackGresPoolingConfig(io.stackgres.common.crd.sgpooling.StackGresPoolingConfig) Collectors(java.util.stream.Collectors) ConfigurationException(org.apache.commons.configuration2.ex.ConfigurationException) List(java.util.List) StringReader(java.io.StringReader) Entry(java.util.Map.Entry) Optional(java.util.Optional) ApplicationScoped(javax.enterprise.context.ApplicationScoped) Pattern(java.util.regex.Pattern) PoolingConfigStatus(io.stackgres.apiweb.dto.pooling.PoolingConfigStatus) PoolingConfigSpec(io.stackgres.apiweb.dto.pooling.PoolingConfigSpec) PgBouncerIniParameter(io.stackgres.apiweb.dto.pooling.PgBouncerIniParameter) StackGresPoolingConfigStatus(io.stackgres.common.crd.sgpooling.StackGresPoolingConfigStatus) PoolingConfigStatus(io.stackgres.apiweb.dto.pooling.PoolingConfigStatus) Tuple3(org.jooq.lambda.tuple.Tuple3) PoolingConfigPgBouncerStatus(io.stackgres.apiweb.dto.pooling.PoolingConfigPgBouncerStatus)

Example 3 with StackGresPoolingConfigStatus

use of io.stackgres.common.crd.sgpooling.StackGresPoolingConfigStatus in project stackgres by ongres.

the class ClusterRequiredResourcesGeneratorTest method setUp.

@BeforeEach
void setUp() {
    cluster = JsonUtil.readFromJson("stackgres_cluster/default.json", StackGresCluster.class);
    cluster.getSpec().getPostgres().setVersion(StackGresComponent.POSTGRESQL.findLatestVersion());
    final String namespace = cluster.getMetadata().getNamespace();
    backupConfig = JsonUtil.readFromJson("backup_config/default.json", StackGresBackupConfig.class);
    setNamespace(backupConfig);
    postgresConfig = JsonUtil.readFromJson("postgres_config/default_postgres.json", StackGresPostgresConfig.class);
    postgresConfig.getSpec().setPostgresVersion(StackGresComponent.POSTGRESQL.findLatestMajorVersion());
    setNamespace(postgresConfig);
    postgresConfig.setStatus(new StackGresPostgresConfigStatus());
    postgresConfig.getStatus().setDefaultParameters(PostgresDefaultValues.getDefaultValues());
    poolingConfig = JsonUtil.readFromJson("pooling_config/default.json", StackGresPoolingConfig.class);
    setNamespace(poolingConfig);
    poolingConfig.setStatus(new StackGresPoolingConfigStatus());
    poolingConfig.getStatus().setPgBouncer(new StackGresPoolingConfigPgBouncerStatus());
    poolingConfig.getStatus().getPgBouncer().setDefaultParameters(PgBouncerDefaultValues.getDefaultValues());
    instanceProfile = JsonUtil.readFromJson("stackgres_profiles/size-s.json", StackGresProfile.class);
    instanceProfile.getMetadata().setNamespace(namespace);
    setNamespace(instanceProfile);
    backups = JsonUtil.readFromJson("backup/list.json", StackGresBackupList.class).getItems();
    backups.forEach(this::setNamespace);
    minioSecret = JsonUtil.readFromJson("secret/minio.json", Secret.class);
}
Also used : Secret(io.fabric8.kubernetes.api.model.Secret) StackGresCluster(io.stackgres.common.crd.sgcluster.StackGresCluster) StackGresPoolingConfig(io.stackgres.common.crd.sgpooling.StackGresPoolingConfig) StackGresProfile(io.stackgres.common.crd.sgprofile.StackGresProfile) StackGresPoolingConfigPgBouncerStatus(io.stackgres.common.crd.sgpooling.StackGresPoolingConfigPgBouncerStatus) StackGresBackupConfig(io.stackgres.common.crd.sgbackupconfig.StackGresBackupConfig) StackGresPostgresConfig(io.stackgres.common.crd.sgpgconfig.StackGresPostgresConfig) StackGresPostgresConfigStatus(io.stackgres.common.crd.sgpgconfig.StackGresPostgresConfigStatus) StackGresPoolingConfigStatus(io.stackgres.common.crd.sgpooling.StackGresPoolingConfigStatus) BeforeEach(org.junit.jupiter.api.BeforeEach)

Aggregations

StackGresPoolingConfig (io.stackgres.common.crd.sgpooling.StackGresPoolingConfig)3 StackGresPoolingConfigStatus (io.stackgres.common.crd.sgpooling.StackGresPoolingConfigStatus)3 StackGresPoolingConfigPgBouncerStatus (io.stackgres.common.crd.sgpooling.StackGresPoolingConfigPgBouncerStatus)2 JsonPatchOperation (com.github.fge.jsonpatch.JsonPatchOperation)1 Secret (io.fabric8.kubernetes.api.model.Secret)1 PgBouncerIniParameter (io.stackgres.apiweb.dto.pooling.PgBouncerIniParameter)1 PoolingConfigDto (io.stackgres.apiweb.dto.pooling.PoolingConfigDto)1 PoolingConfigPgBouncer (io.stackgres.apiweb.dto.pooling.PoolingConfigPgBouncer)1 PoolingConfigPgBouncerStatus (io.stackgres.apiweb.dto.pooling.PoolingConfigPgBouncerStatus)1 PoolingConfigSpec (io.stackgres.apiweb.dto.pooling.PoolingConfigSpec)1 PoolingConfigStatus (io.stackgres.apiweb.dto.pooling.PoolingConfigStatus)1 StackGresBackupConfig (io.stackgres.common.crd.sgbackupconfig.StackGresBackupConfig)1 StackGresCluster (io.stackgres.common.crd.sgcluster.StackGresCluster)1 StackGresPostgresConfig (io.stackgres.common.crd.sgpgconfig.StackGresPostgresConfig)1 StackGresPostgresConfigStatus (io.stackgres.common.crd.sgpgconfig.StackGresPostgresConfigStatus)1 StackGresPoolingConfigPgBouncer (io.stackgres.common.crd.sgpooling.StackGresPoolingConfigPgBouncer)1 StackGresPoolingConfigPgBouncerPgbouncerIni (io.stackgres.common.crd.sgpooling.StackGresPoolingConfigPgBouncerPgbouncerIni)1 StackGresPoolingConfigSpec (io.stackgres.common.crd.sgpooling.StackGresPoolingConfigSpec)1 StackGresProfile (io.stackgres.common.crd.sgprofile.StackGresProfile)1 IOException (java.io.IOException)1