Merged with master

This commit is contained in:
cagache
2018-08-21 10:30:50 +03:00
10 changed files with 154 additions and 48 deletions

View File

@@ -4,7 +4,7 @@
<groupId>org.alfresco</groupId> <groupId>org.alfresco</groupId>
<artifactId>alfresco-governance-services</artifactId> <artifactId>alfresco-governance-services</artifactId>
<packaging>pom</packaging> <packaging>pom</packaging>
<version>3.0.0-SNAPSHOT</version> <version>3.1.0-SNAPSHOT</version>
<name>Alfresco Governance Services</name> <name>Alfresco Governance Services</name>
<url>http://www.alfresco.org/</url> <url>http://www.alfresco.org/</url>

View File

@@ -8,7 +8,7 @@
<parent> <parent>
<groupId>org.alfresco</groupId> <groupId>org.alfresco</groupId>
<artifactId>alfresco-governance-services</artifactId> <artifactId>alfresco-governance-services</artifactId>
<version>3.0.0-SNAPSHOT</version> <version>3.1.0-SNAPSHOT</version>
</parent> </parent>
<licenses> <licenses>

View File

@@ -8,7 +8,7 @@
<parent> <parent>
<groupId>org.alfresco</groupId> <groupId>org.alfresco</groupId>
<artifactId>alfresco-governance-services-automation</artifactId> <artifactId>alfresco-governance-services-automation</artifactId>
<version>3.0.0-SNAPSHOT</version> <version>3.1.0-SNAPSHOT</version>
</parent> </parent>
<properties> <properties>

View File

@@ -8,7 +8,7 @@
<parent> <parent>
<groupId>org.alfresco</groupId> <groupId>org.alfresco</groupId>
<artifactId>alfresco-governance-services</artifactId> <artifactId>alfresco-governance-services</artifactId>
<version>3.0.0-SNAPSHOT</version> <version>3.1.0-SNAPSHOT</version>
</parent> </parent>
<licenses> <licenses>

View File

@@ -2,14 +2,14 @@
<modelVersion>4.0.0</modelVersion> <modelVersion>4.0.0</modelVersion>
<artifactId>alfresco-governance-services-community-repo</artifactId> <artifactId>alfresco-governance-services-community-repo</artifactId>
<name>Alfresco Governance Services Community Repo</name> <name>AGS Repo</name>
<description>Alfresco Governance Services Community Repository Extension</description> <description>Alfresco Governance Services Repository Extension</description>
<packaging>amp</packaging> <packaging>amp</packaging>
<parent> <parent>
<groupId>org.alfresco</groupId> <groupId>org.alfresco</groupId>
<artifactId>alfresco-governance-services-community</artifactId> <artifactId>alfresco-governance-services-community</artifactId>
<version>3.0.0-SNAPSHOT</version> <version>3.1.0-SNAPSHOT</version>
</parent> </parent>
<properties> <properties>

View File

@@ -27,6 +27,8 @@
package org.alfresco.module.org_alfresco_module_rm.patch.compatibility; package org.alfresco.module.org_alfresco_module_rm.patch.compatibility;
import static org.alfresco.repo.module.ModuleVersionNumber.VERSION_ZERO;
import java.io.Serializable; import java.io.Serializable;
import org.alfresco.module.org_alfresco_module_rm.patch.ModulePatchExecuterImpl; import org.alfresco.module.org_alfresco_module_rm.patch.ModulePatchExecuterImpl;
@@ -117,49 +119,63 @@ public abstract class ModulePatchComponent extends AbstractModuleComponent
@Override @Override
protected void executeInternal() protected void executeInternal()
{ {
ModuleVersionNumber moduleInstalledVersionNumber = getModuleVersionNumber(REGISTRY_PROPERTY_INSTALLED_VERSION); //Get the new module version
ModuleVersionNumber moduleCurrentVersionNumber = getModuleVersionNumber(REGISTRY_PROPERTY_CURRENT_VERSION); String moduleId = modulePatchExecuter.getModuleId();
ModuleVersionNumber moduleNewVersionNumber = moduleService.getModule(moduleId).getModuleVersionNumber();
// Get the module details from the registry
ModuleVersionNumber moduleCurrentVersionNumber = getModuleVersionNumber(REGISTRY_PROPERTY_CURRENT_VERSION,
moduleId);
// Get the module patch component name
String moduleName = getName(); String moduleName = getName();
if (moduleCurrentVersionNumber.equals(VERSION_ZERO) ||
if (isVersionLaterThan(moduleInstalledVersionNumber, moduleCurrentVersionNumber)) moduleCurrentVersionNumber.equals(moduleNewVersionNumber)) // No previous record of it
{ {
LOGGER.info("Module patch component '{}' is skipped for upgrade from version {} to version {}", LOGGER.info("Module patch component '{}' is skipped, no previous version found.", moduleName);
moduleName, moduleInstalledVersionNumber, moduleCurrentVersionNumber);
} }
else else
{ {
try if (isVersionLaterThan(moduleCurrentVersionNumber, moduleNewVersionNumber))
{ {
LOGGER.info("Module patch component '{}' is executing ...", moduleName); LOGGER.info("Module patch component '{}' is skipped for upgrade from version {} to version {}",
moduleName, moduleCurrentVersionNumber, moduleNewVersionNumber);
// execute path within an isolated transaction }
retryingTransactionHelper.doInTransaction(new RetryingTransactionHelper.RetryingTransactionCallback<Void>() else
{
try
{ {
@Override LOGGER.info("Module patch component '{}' is executing ...", moduleName);
public Void execute()
// execute path within an isolated transaction
retryingTransactionHelper.doInTransaction(new RetryingTransactionHelper.RetryingTransactionCallback<Void>()
{ {
behaviourFilter.disableBehaviour(); @Override
try public Void execute()
{ {
executePatch(); behaviourFilter.disableBehaviour();
try
{
executePatch();
}
finally
{
behaviourFilter.enableBehaviour();
}
return null;
} }
finally
{
behaviourFilter.enableBehaviour();
}
return null;
}
}, false, true); }, false, true);
LOGGER.info(" ... completed module patch '{}'", moduleName); LOGGER.info(" ... completed module patch '{}'", moduleName);
} catch (Exception exception) }
{ catch (Exception exception)
// record the exception otherwise it gets swallowed {
LOGGER.info(" ... error encountered. {}", exception.getMessage(), exception); // record the exception otherwise it gets swallowed
throw exception; LOGGER.info(" ... error encountered. {}", exception.getMessage(), exception);
throw exception;
}
} }
} }
} }
@@ -167,14 +183,21 @@ public abstract class ModulePatchComponent extends AbstractModuleComponent
/** /**
* Helper method to get the ModuleVersionNumber. * Helper method to get the ModuleVersionNumber.
*/ */
private ModuleVersionNumber getModuleVersionNumber(String registryProperty) private ModuleVersionNumber getModuleVersionNumber(String registryProperty, String moduleId)
{ {
String moduleId = modulePatchExecuter.getModuleId();
RegistryKey moduleKeyVersion = new RegistryKey(ModuleComponentHelper.URI_MODULES_1_0, RegistryKey moduleKeyVersion = new RegistryKey(ModuleComponentHelper.URI_MODULES_1_0,
new String[]{REGISTRY_PATH_MODULES, moduleId, registryProperty}); new String[]{REGISTRY_PATH_MODULES, moduleId, registryProperty});
Serializable moduleVersion = this.registryService.getProperty(moduleKeyVersion); Serializable moduleVersion = this.registryService.getProperty(moduleKeyVersion);
return new ModuleVersionNumber(moduleVersion.toString()); if (moduleVersion == null)
{
return VERSION_ZERO;
}
else
{
return new ModuleVersionNumber(moduleVersion.toString());
}
} }
/** /**
@@ -182,22 +205,27 @@ public abstract class ModulePatchComponent extends AbstractModuleComponent
* patches. * patches.
* *
*/ */
private boolean isVersionLaterThan(ModuleVersionNumber installedModuleVersionNumber, private boolean isVersionLaterThan(ModuleVersionNumber moduleCurrentVersionNumber,
ModuleVersionNumber currentModuleVersionNumber) ModuleVersionNumber moduleNewVersionNumber)
{ {
// assume that the v2.0 and v2.1 patches should be run // assume that the v2.0 and v2.1 patches should be run
boolean versionLaterThan = false; boolean versionLaterThan = false;
// if this is an upgrade as opposed to a fresh install // if this is an upgrade as opposed to a fresh install
if (installedModuleVersionNumber.compareTo(currentModuleVersionNumber) != 0) if (moduleCurrentVersionNumber.compareTo(moduleNewVersionNumber) < 0)
{ {
// if the installed version is later than the minimum version number of this patch // if the installed version is later than the minimum version number of this patch
ModuleVersionNumber minVersion = this.getAppliesFromVersionNumber(); ModuleVersionNumber minVersion = this.getAppliesFromVersionNumber();
if (installedModuleVersionNumber.compareTo(minVersion) >= 0) if (moduleCurrentVersionNumber.compareTo(minVersion) >= 0)
{ {
versionLaterThan = true; versionLaterThan = true;
} }
} }
// v2.0 and v2.1 patches should not be run when both the current and the new version numbers are equals
else
{
versionLaterThan =true;
}
return versionLaterThan; return versionLaterThan;
} }

View File

@@ -7,7 +7,7 @@
<parent> <parent>
<groupId>org.alfresco</groupId> <groupId>org.alfresco</groupId>
<artifactId>alfresco-governance-services-community</artifactId> <artifactId>alfresco-governance-services-community</artifactId>
<version>3.0.0-SNAPSHOT</version> <version>3.1.0-SNAPSHOT</version>
</parent> </parent>
<properties> <properties>

0
scripts/cleanImages.sh Normal file → Executable file
View File

78
scripts/pushDockerDigestTag.sh Executable file
View File

@@ -0,0 +1,78 @@
#!/usr/bin/env bash
set -x
scriptName=`basename "$0"`
usage="Usage: $scriptName [options]
-h , --help show this help text
-i <sourceImage> a source image to use
(e.g. quay.io/alfresco/ags-share-community)
-r <repository> a repository to push new tags to
(e.g. registry.hub.docker.com)
-t <tag> the existing tag for the images (mandatory)
-d <digestLength> the length of digest to output (default 12 chars)"
digestLength=12
while getopts ':hi:r:t:d:' option; do
case "$option" in
h) echo -e "Tag one or more images to include the digest and push this to some repositories.\n\n${usage}"
exit
;;
i) sourceImages+=("$OPTARG")
;;
r) repositories+=("$OPTARG")
;;
t) existingTag=$OPTARG
;;
d) digestLength=$OPTARG
;;
:) echo -e "Missing argument for -${OPTARG}\n\n${usage}" >&2
exit 1
;;
\?) echo -e "Illegal option: -${OPTARG}\n\n${usage}" >&2
exit 1
;;
esac
done
shift $((OPTIND - 1))
if [ "#$existingTag" == "#" ]; then
echo -e "Please supply a tag with the -t option.\n\n${usage}" >&2
exit 1
fi
for sourceImage in ${sourceImages[@]}
do
echo "Processing $sourceImage"
# Note that this command should work even if the image is already present locally.
digest=`docker pull ${sourceImage}:${existingTag} | grep "Digest:" | awk -F':' '{print $3}' | cut -c 1-$digestLength`
if [ ${#digest} != $digestLength ]
then
echo "Unexpected length for digest of ${sourceImage}: '${digest}'" >&2
exit 1
fi
newTag=${existingTag}-${digest}
# Remove the source repository name if it contains one.
slashes=`echo $sourceImage | sed "s|[^/]||g"`
if [ ${#slashes} == 2 ]
then
# The repository name is everything up to the first slash.
image=`echo $sourceImage | sed "s|[^/]*/||"`
else
# Assume the source image doesn't reference the repository name.
image=$sourceImage
fi
for repository in ${repositories[@]}
do
docker tag ${sourceImage}:${existingTag} ${repository}/${image}:${newTag}
docker push ${repository}/${image}:${newTag}
echo "Pushed ${sourceImage}:${existingTag} to ${repository}/${image}:${newTag}"
done
done

0
scripts/waitForAlfrescoToStart.sh Normal file → Executable file
View File