From e1c65a52dd2509502ac33a28c4a7f77daa503c6a Mon Sep 17 00:00:00 2001 From: Claudia Agache Date: Wed, 29 Apr 2020 13:25:51 +0300 Subject: [PATCH 1/4] Get alfresco logs for all nodes from a cluster --- .../rest/rm/community/util/DockerHelper.java | 30 ++++++++++++------- 1 file changed, 20 insertions(+), 10 deletions(-) diff --git a/rm-automation/rm-automation-community-rest-api/src/main/java/org/alfresco/rest/rm/community/util/DockerHelper.java b/rm-automation/rm-automation-community-rest-api/src/main/java/org/alfresco/rest/rm/community/util/DockerHelper.java index 41a066809b..2583064b61 100644 --- a/rm-automation/rm-automation-community-rest-api/src/main/java/org/alfresco/rest/rm/community/util/DockerHelper.java +++ b/rm-automation/rm-automation-community-rest-api/src/main/java/org/alfresco/rest/rm/community/util/DockerHelper.java @@ -30,7 +30,7 @@ package org.alfresco.rest.rm.community.util; import java.util.ArrayList; import java.util.Collections; import java.util.List; -import java.util.Optional; +import java.util.stream.Collectors; import com.github.dockerjava.api.DockerClient; import com.github.dockerjava.api.command.LogContainerCmd; @@ -80,13 +80,12 @@ public class DockerHelper * Method for returning logs of docker container * * @param containerId - ID of the container + * @param timeStamp - get the logs since a specific timestamp * @return list of strings, where every string is log line */ - private List getDockerLogs(String containerId) + private List getDockerLogs(String containerId, int timeStamp) { final List logs = new ArrayList<>(); - // get the logs since current time - 10 seconds - final int timeStamp = (int) (System.currentTimeMillis() / 1000) - 10; final LogContainerCmd logContainerCmd = getDockerClient().logContainerCmd(containerId); logContainerCmd.withStdOut(true) @@ -121,22 +120,33 @@ public class DockerHelper */ public List getAlfrescoLogs() { - final Optional alfrescoContainer = findContainerByImageName(REPO_IMAGE_NAME); - return (alfrescoContainer.isPresent()) ? getDockerLogs(alfrescoContainer.get().getId()) : Collections.emptyList(); + final List alfrescoContainers = findContainersByImageName(REPO_IMAGE_NAME); + if (alfrescoContainers.isEmpty()) + { + return Collections.emptyList(); + } + else + { + List alfrescoLogs = new ArrayList<>(); + // get the logs since current time - 10 seconds + final int timeStamp = (int) (System.currentTimeMillis() / 1000) - 10; + alfrescoContainers.forEach(alfrescoContainer -> alfrescoLogs.addAll(getDockerLogs(alfrescoContainer.getId(), timeStamp))); + return alfrescoLogs; + } } /** - * Method for finding a docker container after the image name + * Method for finding docker containers after the image name * * @param imageName - the name of the image used by container - * @return the container + * @return the containers */ - private Optional findContainerByImageName(String imageName) + private List findContainersByImageName(String imageName) { final List containers = getDockerClient().listContainersCmd().withShowAll(true).exec(); return containers.stream() .filter(container -> container.getImage().contains(imageName)) - .findFirst(); + .collect(Collectors.toList()); } } From dac9bade014d0370daa4c55201ef069ce9a95f98 Mon Sep 17 00:00:00 2001 From: Claudia Agache Date: Wed, 29 Apr 2020 14:02:02 +0300 Subject: [PATCH 2/4] Update ACS version to 6.2.1-A4 because it contains the fix for the license issue ACS-105 --- pom.xml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pom.xml b/pom.xml index de4488d61c..ab5a9320fe 100644 --- a/pom.xml +++ b/pom.xml @@ -531,7 +531,7 @@ alfresco org.alfresco share - 8.2 + 7.13 6.3.0 0.0 From 589b4a117e817322eb47b40d3d296f4e0cb8521a Mon Sep 17 00:00:00 2001 From: Tom Page Date: Wed, 8 Apr 2020 09:27:53 +0100 Subject: [PATCH 3/4] Merge pull request #1119 from Alfresco/feature/FallbackToDeleteAllImages If deleting specified images fails then try deleting all images instead. --- scripts/cleanImages.sh | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/scripts/cleanImages.sh b/scripts/cleanImages.sh index b0607ba391..8d58cfdc02 100755 --- a/scripts/cleanImages.sh +++ b/scripts/cleanImages.sh @@ -10,5 +10,10 @@ if [ "$docker_images_list" == "" ]; then echo "No docker images on the agent" else echo "Clearing images: $docker_images_list" - docker rmi -f $docker_images_list + if docker rmi -f $docker_images_list ; then + echo "Deleting images was successful." + else + echo "Deleting specified images failed, so falling back to delete ALL images on system." + docker rmi -f $(docker images -aq) + fi fi From ff88ea3a3e891c1c85545908eee898b12581c8ad Mon Sep 17 00:00:00 2001 From: Claudia Agache Date: Wed, 29 Apr 2020 16:51:45 +0300 Subject: [PATCH 4/4] revert the change --- pom.xml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pom.xml b/pom.xml index ab5a9320fe..de4488d61c 100644 --- a/pom.xml +++ b/pom.xml @@ -531,7 +531,7 @@ alfresco org.alfresco share - 7.13 + 8.2 6.3.0 0.0