Merge branch 'master' into bug5979

This commit is contained in:
Thomas Stokes
2024-03-21 13:07:53 +01:00
7 changed files with 83 additions and 58 deletions
@@ -1,7 +1,7 @@
#!/bin/bash
# Purpose: Deployed in a file named "post-receive", in the hooks dir of a bare git repo. Upon push completion, this script runs and
# triggers an update to instances in the region with a specified tag. A command is ran in the repo
# triggers an update to instances in the region with a specified tag. A command is ran in the repo
# after the merge completes. The user, in which the bare repo and hook are installed, must have aws credentials, that
# don't need mfa. (These may need to be installed manually -- within the correct user -- if starting from a clean instance.)
@@ -23,12 +23,24 @@ sync_repo() {
ssh -o "StrictHostKeyChecking=no" -o "ConnectTimeout=10" root@${IP} "cd ~ && sync-repo-and-execute-cmd.sh '${DIR}' '${COMMAND}' '${2}'";
done;
}
check_conflict() {
# $1: Return code of a command
# $2: Error msg to use
if [[ "$1" -ne 0 ]]; then
echo "$2"
echo "$2" | notify-operators "Merge issue for httpd config repo in checked-out workspace"
exit 1
fi
}
merge_main_into_branch() {
#$1 branch name. Assumes you are in the git repo.
#$1 Branch name. Assumes you are in the git repo.
git checkout "${1}"
check_conflict "$?" "Conflict checking out ${1}"
git pull
echo "merging ${MAIN_BRANCH_NAME} into ${1}"
check_conflict "$?" "Conflict pulling ${1}"
echo "Merging ${MAIN_BRANCH_NAME} into ${1}"
git merge ${MAIN_BRANCH_NAME}
check_conflict "$?" "Conflict merging ${MAIN_BRANCH_NAME} into ${1}"
git push
}
while read oldrev newrev refname; do # These vars are passed on stdin to this hook.
@@ -46,14 +58,21 @@ while read oldrev newrev refname; do # These vars are passed on stdin to this
cd ~
unset GIT_DIR
cd ${CHECKED_OUT_WORKSPACE_NAME}
# get the latest main
# Get the latest main
git checkout ${MAIN_BRANCH_NAME}
check_conflict "$?" "Uncommitted files in the working directory"
git pull
# get the latest diposable branch and merge in changes
merge_main_into_branch "$DISPOSABLE_BRANCH_NAME"
# get the latest central branch and merge in changes
merge_main_into_branch "$CENTRAL_BRANCH_NAME"
git checkout ${MAIN_BRANCH_NAME}
check_conflict "$?" "Merge conflict in main branch"
if [[ "$(git rev-parse ${MAIN_BRANCH_NAME})" != "$(git rev-parse origin/${MAIN_BRANCH_NAME})" ]]; then
echo "Merge induced by pull. Pushing latest changes in ${MAIN_BRANCH_NAME} to origin" # In case of a merge from diverging branches. This seems cyclic as we are pushing to the same branch, but should resolve, when "Everything up-to-date".
git push
else
# Get the latest diposable branch and merge in changes
merge_main_into_branch "$DISPOSABLE_BRANCH_NAME"
# Get the latest central branch and merge in changes
merge_main_into_branch "$CENTRAL_BRANCH_NAME"
git checkout ${MAIN_BRANCH_NAME}
fi
fi
fi
done
@@ -7,11 +7,14 @@ PATH_TO_STORE="$2"
NAME_TO_STORE_IN="landscapeManagersMailingList"
BASE_URL="https://security-service.sapsailing.com"
curl_output=$( curl -H 'X-SAPSSE-Forward-Request-To: master' -H 'Authorization: Bearer '${BEARER_TOKEN} "${BASE_URL}/security/api/restsecurity/users_with_permission?permission=LANDSCAPE:MANAGE:AWS" 2>/dev/null )
if [[ -f "${PATH_TO_STORE}/${NAME_TO_STORE_IN}" ]]; then
mv -f ${PATH_TO_STORE}/${NAME_TO_STORE_IN} ${PATH_TO_STORE}/${NAME_TO_STORE_IN}.bak
fi
touch ${PATH_TO_STORE}/${NAME_TO_STORE_IN}
temp_file_path=$(mktemp /var/cache/emails_XXX)
chmod 644 $temp_file_path
echo $curl_output | jq -r .[] | while read user; do
email=$(curl -H 'X-SAPSSE-Forward-Request-To: master' -H 'Authorization: Bearer '${BEARER_TOKEN} "${BASE_URL}/security/api/restsecurity/user?username=$user" 2>/dev/null| jq -r '.email' )
echo $email >> ${PATH_TO_STORE}/${NAME_TO_STORE_IN}
echo $email >> $temp_file_path
done
if ! diff ${PATH_TO_STORE}/${NAME_TO_STORE_IN} ${temp_file_path}; then
mv "$temp_file_path" ${PATH_TO_STORE}/${NAME_TO_STORE_IN}
else
rm ${temp_file_path}
fi
@@ -5248,11 +5248,10 @@ Replicator {
String message = e.getMessage();
if (connection instanceof HttpURLConnection) {
// try to obtain an error message from the connection's error stream:
try {
message = new BufferedReader(
try (BufferedReader reader = new BufferedReader(
new InputStreamReader(((HttpURLConnection) connection).getErrorStream(),
HttpUrlConnectionHelper.getCharsetFromConnectionOrDefault(connection, "UTF-8")))
.readLine();
HttpUrlConnectionHelper.getCharsetFromConnectionOrDefault(connection, "UTF-8")))) {
message = reader.readLine();
} catch (Exception exceptionTryingToReadErrorStream) {
// in this case we just stay with the exception's message
}
@@ -366,8 +366,8 @@
<plugin id="org.apache.xalan"/>
<plugin id="org.apache.xml.serializer"/>
<plugin id="org.eclipse.jetty.osgi.boot.jsp.source"/>
<plugin id="org.eclipse.jetty.osgi-servlet-api" version="3.1.0.M3"/>
<plugin id="org.eclipse.jetty.osgi-servlet-api.source" version="3.1.0.M3"/>
<plugin id="org.eclipse.jetty.osgi-servlet-api"/>
<plugin id="org.eclipse.jetty.osgi-servlet-api.source"/>
<plugin id="javax.annotation"/>
<plugin id="org.eclipse.jetty.io"/>
<plugin id="org.eclipse.osgi.util"/>
@@ -419,6 +419,7 @@
<plugin id="com.google.gson.source"/>
<plugin id="com.amazonaws.aws-lambda-java-core"/>
<plugin id="com.amazonaws.aws-lambda-java-core.source"/>
<plugin id="javax.cache.api"/>
</includeBundles>
<targetJRE path="org.eclipse.jdt.launching.JRE_CONTAINER/org.eclipse.jdt.internal.debug.ui.launcher.StandardVMType/JavaSE-1.8"/>
</target>
</target>
+32 -33
View File
@@ -85,7 +85,6 @@
download-size="0"
install-size="0"
version="2.0.12"
fragment="true"
unpack="false"/>
<plugin
@@ -723,7 +722,6 @@
version="2.9.0"
unpack="false"/>
<plugin
id="com.github.mwiede.jsch"
download-size="0"
@@ -1032,7 +1030,7 @@
install-size="0"
version="3.27.2"
unpack="false"/>
<plugin
id="com.esotericsoftware.kryo"
download-size="0"
@@ -1067,120 +1065,120 @@
install-size="0"
version="2.16.1"
unpack="false"/>
<plugin
id="com.fasterxml.jackson.dataformat.jackson-dataformat-yaml"
download-size="0"
install-size="0"
version="2.16.1"
unpack="false"/>
<plugin
id="org.yaml.snakeyaml"
download-size="0"
install-size="0"
version="2.2.0"
unpack="false"/>
unpack="false"/>
<plugin
id="io.netty.transport"
download-size="0"
install-size="0"
version="4.1.107.Final"
unpack="false"/>
<plugin
<plugin
id="io.netty.buffer"
download-size="0"
install-size="0"
version="4.1.107.Final"
unpack="false"/>
<plugin
<plugin
id="io.netty.common"
download-size="0"
install-size="0"
version="4.1.107.Final"
unpack="false"/>
<plugin
<plugin
id="io.netty.resolver"
download-size="0"
install-size="0"
version="4.1.107.Final"
unpack="false"/>
<plugin
<plugin
id="io.netty.transport-classes-epoll"
download-size="0"
install-size="0"
version="4.1.107.Final"
unpack="false"/>
<plugin
<plugin
id="io.netty.transport-native-unix-common"
download-size="0"
install-size="0"
version="4.1.107.Final"
unpack="false"/>
<plugin
<plugin
id="io.netty.transport-classes-kqueue"
download-size="0"
install-size="0"
version="4.1.107.Final"
unpack="false"/>
<plugin
<plugin
id="io.netty.codec"
download-size="0"
install-size="0"
version="4.1.107.Final"
unpack="false"/>
<plugin
<plugin
id="io.netty.handler"
download-size="0"
install-size="0"
version="4.1.107.Final"
unpack="false"/>
<plugin
<plugin
id="io.netty.resolver-dns"
download-size="0"
install-size="0"
version="4.1.107.Final"
unpack="false"/>
<plugin
<plugin
id="io.netty.codec-dns"
download-size="0"
install-size="0"
version="4.1.107.Final"
unpack="false"/>
<plugin
<plugin
id="io.netty.incubator.netty-incubator-transport-classes-io_uring"
download-size="0"
install-size="0"
version="0.0.25.Final"
unpack="false"/>
<plugin
<plugin
id="io.reactivex.rxjava3.rxjava"
download-size="0"
install-size="0"
version="3.1.8"
unpack="false"/>
<plugin
<plugin
id="reactive-streams"
download-size="0"
install-size="0"
version="1.0.4"
unpack="false"/>
<plugin
<plugin
id="javax.cache.api"
download-size="0"
install-size="0"
@@ -1311,6 +1309,7 @@
download-size="0"
install-size="0"
version="1.0.0"
fragment="true"
unpack="false"/>
</feature>
@@ -142,9 +142,10 @@ public class MongoDBServiceImpl implements MongoDBService {
@Override
public MongoClient getMongo(ConnectionString mongoConnectionString) {
MongoClient mongo = mongos.computeIfAbsent(mongoConnectionString,
k-> MongoClients.create(mongoConnectionString));
return mongo;
try (MongoClient mongo = mongos.computeIfAbsent(mongoConnectionString,
k-> MongoClients.create(mongoConnectionString))) {
return mongo;
}
}
@Override
@@ -712,7 +712,10 @@ public class ReplicationServiceImpl implements ReplicationService, OperationsToM
.redirectConnectionWithBearerToken(initialLoadURL, /* HTTP request method */ "POST", master.getBearerToken());
final InputStream is = (InputStream) initialLoadConnection.getContent();
final InputStreamReader queueNameReader = new InputStreamReader(is, HttpUrlConnectionHelper.getCharsetFromConnectionOrDefault(initialLoadConnection, "UTF-8"));
final String queueName = new BufferedReader(queueNameReader).readLine();
final String queueName;
try (BufferedReader reader = new BufferedReader(queueNameReader)) {
queueName = reader.readLine();
}
queueNameReader.close();
final Channel channel = master.createChannel();
initialLoadChannels.put(master, new InitialLoadRequest(channel, replicables, queueName));