summaryrefslogtreecommitdiffstats
path: root/participant/participant-impl
diff options
context:
space:
mode:
authorLathish <lathishbabu.ganesan@est.tech>2022-02-01 15:28:14 +0530
committerLathish <lathishbabu.ganesan@est.tech>2022-02-01 17:33:07 +0530
commitc97a6c0428998103906472725d34b9951a0ff559 (patch)
treeaa19ece9c24e07b811fa642ad4668234c4e51fc5 /participant/participant-impl
parentdb1d572bc33f114820424a9a9c14c4aa354f8cfc (diff)
Fix K8s participant Error when helm repo is not configured
Issue-ID: POLICY-3874 Change-Id: Ib28e427b6f498c89b8ab5b1f5bf6c88e6c9fc919 Signed-off-by: Lathish <lathishbabu.ganesan@est.tech>
Diffstat (limited to 'participant/participant-impl')
-rw-r--r--participant/participant-impl/participant-impl-kubernetes/src/main/java/org/onap/policy/clamp/controlloop/participant/kubernetes/helm/HelmClient.java33
-rw-r--r--participant/participant-impl/participant-impl-kubernetes/src/main/resources/config/application.yaml6
2 files changed, 24 insertions, 15 deletions
diff --git a/participant/participant-impl/participant-impl-kubernetes/src/main/java/org/onap/policy/clamp/controlloop/participant/kubernetes/helm/HelmClient.java b/participant/participant-impl/participant-impl-kubernetes/src/main/java/org/onap/policy/clamp/controlloop/participant/kubernetes/helm/HelmClient.java
index 31fa62f1f..6133c7ebd 100644
--- a/participant/participant-impl/participant-impl-kubernetes/src/main/java/org/onap/policy/clamp/controlloop/participant/kubernetes/helm/HelmClient.java
+++ b/participant/participant-impl/participant-impl-kubernetes/src/main/java/org/onap/policy/clamp/controlloop/participant/kubernetes/helm/HelmClient.java
@@ -1,6 +1,6 @@
/*-
* ========================LICENSE_START=================================
- * Copyright (C) 2021 Nordix Foundation. All rights reserved.
+ * Copyright (C) 2021-2022 Nordix Foundation. All rights reserved.
* ======================================================================
* Modifications Copyright (C) 2021 AT&T Intellectual Property. All rights reserved.
* ======================================================================
@@ -93,18 +93,19 @@ public class HelmClient {
* @throws IOException in case of IO errors
*/
public String findChartRepository(ChartInfo chart) throws ServiceException, IOException {
- updateHelmRepo();
- String repository = verifyConfiguredRepo(chart);
- if (repository != null) {
- logger.info("Helm chart located in the repository {} ", repository);
- return repository;
+ if (updateHelmRepo()) {
+ String repository = verifyConfiguredRepo(chart);
+ if (repository != null) {
+ logger.info("Helm chart located in the repository {} ", repository);
+ return repository;
+ }
}
var localHelmChartDir = chartStore.getAppPath(chart.getChartId()).toString();
logger.info("Chart not found in helm repositories, verifying local repo {} ", localHelmChartDir);
if (verifyLocalHelmRepo(new File(localHelmChartDir + PATH_DELIMITER + chart.getChartId().getName()))) {
- repository = localHelmChartDir;
+ return localHelmChartDir;
}
- return repository;
+ return null;
}
/**
@@ -254,10 +255,18 @@ public class HelmClient {
}
- private void updateHelmRepo() throws ServiceException {
- logger.info("Updating local helm repositories before verifying the chart");
- executeCommand(new ProcessBuilder().command("helm", "repo", "update"));
- logger.debug("Helm repositories updated successfully");
+ private boolean updateHelmRepo() {
+ try {
+ logger.info("Updating local helm repositories before verifying the chart");
+ executeCommand(new ProcessBuilder().command("helm", "repo", "update"));
+ logger.debug("Helm repositories updated successfully");
+ } catch (ServiceException e) {
+ logger.error("Failed to update the helm repo: ", e);
+ return false;
+ }
+ return true;
+
+
}
private boolean verifyLocalHelmRepo(File localFile) {
diff --git a/participant/participant-impl/participant-impl-kubernetes/src/main/resources/config/application.yaml b/participant/participant-impl/participant-impl-kubernetes/src/main/resources/config/application.yaml
index f77153a25..8b9d7e496 100644
--- a/participant/participant-impl/participant-impl-kubernetes/src/main/resources/config/application.yaml
+++ b/participant/participant-impl/participant-impl-kubernetes/src/main/resources/config/application.yaml
@@ -13,10 +13,10 @@ participant:
reportingTimeIntervalMs: 120000
description: Participant Description
participantId:
- name: org.onap.k8s.controlloop.K8SControlLoopParticipant
- version: 2.3.4
+ name: K8sParticipant0
+ version: 1.0.0
participantType:
- name: org.onap.k8s.controlloop.K8SControlLoopParticipant
+ name: org.onap.k8s.controlloop.K8sControlLoopParticipant
version: 2.3.4
clampControlLoopTopics:
topicSources: