From 43fb6c9a683efb014c40d5736419cb0085556642 Mon Sep 17 00:00:00 2001 From: rameshiyer27 Date: Tue, 15 Jun 2021 18:22:04 +0100 Subject: Fix CLAMP build failure and kub-participant module startup issue. Initialising ParticipantK8sParameters in the constructor to fix Null pointer Exception in kub-participant module. Constructor cannot use autowired properties. Updated pfDao getFiltered method signature to align with latest code in policy models. Issue-ID: POLICY-3240 Signed-off-by: zrrmmua Change-Id: I9405c1e050b31b153ee53829ffece9f4be27818e --- .../participant/kubernetes/helm/HelmClient.java | 2 -- .../participant/kubernetes/service/ChartStore.java | 18 ++++++++++-------- .../resources/config/KubernetesParticipantConfig.json | 4 ++-- 3 files changed, 12 insertions(+), 12 deletions(-) (limited to 'participant') 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 456122f3d..1b7599ce9 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 @@ -113,8 +113,6 @@ public class HelmClient { static String executeCommand(ProcessBuilder processBuilder) throws ServiceException { var commandStr = toString(processBuilder); - processBuilder.redirectInput(ProcessBuilder.Redirect.DISCARD); - try { var process = processBuilder.start(); process.waitFor(); diff --git a/participant/participant-impl/participant-impl-kubernetes/src/main/java/org/onap/policy/clamp/controlloop/participant/kubernetes/service/ChartStore.java b/participant/participant-impl/participant-impl-kubernetes/src/main/java/org/onap/policy/clamp/controlloop/participant/kubernetes/service/ChartStore.java index 2d0ce7a83..041c0c810 100644 --- a/participant/participant-impl/participant-impl-kubernetes/src/main/java/org/onap/policy/clamp/controlloop/participant/kubernetes/service/ChartStore.java +++ b/participant/participant-impl/participant-impl-kubernetes/src/main/java/org/onap/policy/clamp/controlloop/participant/kubernetes/service/ChartStore.java @@ -51,8 +51,7 @@ public class ChartStore { private static final StandardCoder STANDARD_CODER = new StandardCoder(); - @Autowired - private ParticipantK8sParameters participantK8sParameters; + private final ParticipantK8sParameters participantK8sParameters; /** * The chartStore map contains chart name as key & ChartInfo as value. @@ -62,7 +61,8 @@ public class ChartStore { /** * Constructor method. */ - public ChartStore() { + public ChartStore(@Autowired ParticipantK8sParameters participantK8sParameters) { + this.participantK8sParameters = participantK8sParameters; this.restoreFromLocalFileSystem(); } @@ -177,12 +177,11 @@ public class ChartStore { } private synchronized void restoreFromLocalFileSystem() { - Path localChartDirectoryPath = Paths.get(participantK8sParameters.getLocalChartDirectory()); - try { + Path localChartDirectoryPath = Paths.get(participantK8sParameters.getLocalChartDirectory()); Files.createDirectories(localChartDirectoryPath); restoreFromLocalFileSystem(localChartDirectoryPath); - } catch (IOException ioe) { + } catch (Exception ioe) { LOGGER.warn("Could not restore charts from local file system: {}", ioe); } } @@ -194,8 +193,11 @@ public class ChartStore { @Override public FileVisitResult visitFile(Path localChartFile, BasicFileAttributes attrs) throws IOException { try { - ChartInfo chart = STANDARD_CODER.decode(localChartFile.toFile(), ChartInfo.class); - localChartMap.put(key(chart), chart); + // Decode only the json file excluding the helm charts + if (localChartFile.endsWith(participantK8sParameters.getInfoFileName())) { + ChartInfo chart = STANDARD_CODER.decode(localChartFile.toFile(), ChartInfo.class); + localChartMap.put(key(chart), chart); + } return FileVisitResult.CONTINUE; } catch (CoderException ce) { throw new IOException("Error decoding chart file", ce); diff --git a/participant/participant-impl/participant-impl-kubernetes/src/main/resources/config/KubernetesParticipantConfig.json b/participant/participant-impl/participant-impl-kubernetes/src/main/resources/config/KubernetesParticipantConfig.json index 620e05552..e854a9375 100644 --- a/participant/participant-impl/participant-impl-kubernetes/src/main/resources/config/KubernetesParticipantConfig.json +++ b/participant/participant-impl/participant-impl-kubernetes/src/main/resources/config/KubernetesParticipantConfig.json @@ -49,8 +49,8 @@ "implementation":"org.onap.policy.models.provider.impl.DatabasePolicyModelsProviderImpl", "databaseDriver":"org.mariadb.jdbc.Driver", "databaseUrl":"jdbc:mariadb://localhost:3306/controlloop", - "databaseUser":"admin", - "databasePassword":"passme", + "databaseUser":"policy", + "databasePassword":"P01icY", "persistenceUnit":"ToscaConceptTest" } } -- cgit 1.2.3-korg