diff --git a/onyxia-api/pom.xml b/onyxia-api/pom.xml
index e66d0f18..5f1bbb7f 100644
--- a/onyxia-api/pom.xml
+++ b/onyxia-api/pom.xml
@@ -72,11 +72,6 @@
0.0.1-SNAPSHOT
-
- io.micrometer
- micrometer-registry-prometheus
-
-
org.springframework.boot
spring-boot-starter-actuator
diff --git a/onyxia-api/src/main/java/fr/insee/onyxia/api/configuration/metrics/CustomMetrics.java b/onyxia-api/src/main/java/fr/insee/onyxia/api/configuration/metrics/CustomMetrics.java
deleted file mode 100644
index f4db5bff..00000000
--- a/onyxia-api/src/main/java/fr/insee/onyxia/api/configuration/metrics/CustomMetrics.java
+++ /dev/null
@@ -1,26 +0,0 @@
-package fr.insee.onyxia.api.configuration.metrics;
-
-import io.micrometer.core.instrument.Counter;
-import io.micrometer.core.instrument.MeterRegistry;
-import io.micrometer.core.instrument.binder.MeterBinder;
-import org.springframework.stereotype.Service;
-
-@Service
-public class CustomMetrics implements MeterBinder {
-
- private static Counter counter;
-
- public void plusUn() {
- counter.increment();
- }
-
- @Override
- public void bindTo(MeterRegistry registry) {
- counter =
- Counter.builder("servicespopes")
- .description("Nombre de services popes")
- .tags("services", "nombre")
- .baseUnit("services")
- .register(registry);
- }
-}
diff --git a/onyxia-api/src/main/java/fr/insee/onyxia/api/controller/api/mylab/MyLabController.java b/onyxia-api/src/main/java/fr/insee/onyxia/api/controller/api/mylab/MyLabController.java
index 519d3635..8451c222 100644
--- a/onyxia-api/src/main/java/fr/insee/onyxia/api/controller/api/mylab/MyLabController.java
+++ b/onyxia-api/src/main/java/fr/insee/onyxia/api/controller/api/mylab/MyLabController.java
@@ -232,7 +232,7 @@ private void suspendOrResume(Region region, Project project, String serviceId, b
CatalogWrapper catalog = elligibleCatalogs.getFirst();
catalogId = catalog.getId();
}
- Optional catalog = catalogService.getCatalogById(catalogId);
+ Optional catalog = catalogService.getCatalogById(catalogId, user);
if (catalog.isEmpty()) {
throw new IllegalStateException(
"Catalog " + catalogId + " is not available anymore");
diff --git a/onyxia-api/src/main/java/fr/insee/onyxia/api/controller/api/mylab/QuotaController.java b/onyxia-api/src/main/java/fr/insee/onyxia/api/controller/api/mylab/QuotaController.java
index c184d0db..ca393943 100644
--- a/onyxia-api/src/main/java/fr/insee/onyxia/api/controller/api/mylab/QuotaController.java
+++ b/onyxia-api/src/main/java/fr/insee/onyxia/api/controller/api/mylab/QuotaController.java
@@ -76,10 +76,8 @@ public QuotaUsage getQuota(
}
final QuotaUsage quotaUsage = new QuotaUsage();
- final Quota spec = new Quota();
- final Quota usage = new Quota();
- mapKubQuotaToQuota(resourceQuota.getStatus().getHard(), spec);
- mapKubQuotaToQuota(resourceQuota.getStatus().getUsed(), usage);
+ final Quota spec = kubQuotaToQuota(resourceQuota.getStatus().getHard());
+ final Quota usage = kubQuotaToQuota(resourceQuota.getStatus().getUsed());
quotaUsage.setSpec(spec);
quotaUsage.setUsage(usage);
@@ -199,10 +197,10 @@ private Owner getOwner(Region region, Project project) {
return owner;
}
- private void mapKubQuotaToQuota(Map resourceQuota, Quota quota) {
+ private Quota kubQuotaToQuota(Map resourceQuota) {
final Map rawData = new HashMap<>();
- resourceQuota.entrySet().forEach(e -> rawData.put(e.getKey(), e.getValue().toString()));
- quota.loadFromMap(rawData);
+ resourceQuota.forEach((key, value) -> rawData.put(key, value.toString()));
+ return Quota.from(rawData);
}
public KubernetesService getKubernetesService() {
diff --git a/onyxia-api/src/main/java/fr/insee/onyxia/api/dao/universe/CatalogLoader.java b/onyxia-api/src/main/java/fr/insee/onyxia/api/dao/universe/CatalogLoader.java
index 173b03e1..5eaa802a 100644
--- a/onyxia-api/src/main/java/fr/insee/onyxia/api/dao/universe/CatalogLoader.java
+++ b/onyxia-api/src/main/java/fr/insee/onyxia/api/dao/universe/CatalogLoader.java
@@ -10,11 +10,7 @@
import fr.insee.onyxia.model.catalog.Pkg;
import fr.insee.onyxia.model.helm.Chart;
import fr.insee.onyxia.model.helm.Repository;
-import java.io.ByteArrayOutputStream;
-import java.io.IOException;
-import java.io.InputStream;
-import java.io.InputStreamReader;
-import java.io.Reader;
+import java.io.*;
import java.util.Iterator;
import java.util.List;
import java.util.Optional;
@@ -173,38 +169,32 @@ private void refreshPackage(CatalogWrapper cw, Pkg pkg)
}
public void extractDataFromTgz(InputStream in, Chart chart) throws IOException {
- GzipCompressorInputStream gzipIn = new GzipCompressorInputStream(in);
- // HelmConfig config = null;
- try (TarArchiveInputStream tarIn = new TarArchiveInputStream(gzipIn)) {
+ String chartName = chart.getName();
+
+ try (GzipCompressorInputStream gzipIn = new GzipCompressorInputStream(in);
+ TarArchiveInputStream tarIn = new TarArchiveInputStream(gzipIn)) {
+
TarArchiveEntry entry;
while ((entry = tarIn.getNextEntry()) != null) {
- if (entry.getName().endsWith(chart.getName() + "/values.schema.json")
- && !entry.getName()
- .endsWith("charts/" + chart.getName() + "/values.schema.json")) {
+ String entryName = entry.getName();
+ if (entryName.endsWith(chartName + "/values.schema.json")
+ && !entryName.endsWith("charts/" + chartName + "/values.schema.json")) {
// TODO : mutualize objectmapper
ObjectMapper mapper = new ObjectMapper();
mapper.configure(JsonParser.Feature.AUTO_CLOSE_SOURCE, false);
mapper.configure(DeserializationFeature.FAIL_ON_UNKNOWN_PROPERTIES, false);
- ByteArrayOutputStream baos = new ByteArrayOutputStream();
- byte[] buffer = new byte[1024];
- int len;
- while ((len = tarIn.read(buffer)) != -1) {
- baos.write(buffer, 0, len);
+
+ try (ByteArrayOutputStream baos = new ByteArrayOutputStream()) {
+ tarIn.transferTo(baos);
+ chart.setConfig(mapper.readTree(baos.toString(UTF_8)));
}
- chart.setConfig(mapper.readTree(baos.toString("UTF-8")));
- }
- if (entry.getName().endsWith(chart.getName() + "/values.yaml")
- && !entry.getName()
- .endsWith("charts/" + chart.getName() + "/values.yaml")) {
- ByteArrayOutputStream baos = new ByteArrayOutputStream();
- byte[] buffer = new byte[1024];
- int len;
- while ((len = tarIn.read(buffer)) != -1) {
- baos.write(buffer, 0, len);
+ } else if (entryName.endsWith(chartName + "/values.yaml")
+ && !entryName.endsWith("charts/" + chartName + "/values.yaml")) {
+ try (ByteArrayOutputStream baos = new ByteArrayOutputStream()) {
+ tarIn.transferTo(baos);
+ chart.setDefaultValues(baos.toString());
}
- byte[] fileContent = baos.toByteArray();
- chart.setDefaultValues(new String(fileContent));
}
}
}
diff --git a/onyxia-api/src/main/java/fr/insee/onyxia/api/services/impl/HelmAppsService.java b/onyxia-api/src/main/java/fr/insee/onyxia/api/services/impl/HelmAppsService.java
index bcd95952..5be9b072 100644
--- a/onyxia-api/src/main/java/fr/insee/onyxia/api/services/impl/HelmAppsService.java
+++ b/onyxia-api/src/main/java/fr/insee/onyxia/api/services/impl/HelmAppsService.java
@@ -38,7 +38,6 @@
import java.util.*;
import java.util.concurrent.CompletableFuture;
import java.util.concurrent.TimeoutException;
-import java.util.stream.Collectors;
import org.apache.commons.lang3.StringUtils;
import org.apache.commons.lang3.time.FastDateFormat;
import org.slf4j.Logger;
@@ -67,6 +66,10 @@ public class HelmAppsService implements AppsService {
final OnyxiaEventPublisher onyxiaEventPublisher;
public static final String ONYXIA_SECRET_PREFIX = "sh.onyxia.release.v1.";
+ private static final String CATALOG = "catalog";
+ private static final String OWNER = "owner";
+ private static final String FRIENDLY_NAME = "friendlyName";
+ private static final String SHARE = "share";
@Autowired
public HelmAppsService(
@@ -131,13 +134,12 @@ public Collection