Skip to content
Snippets Groups Projects
Commit 42cd7fd4 authored by Sirieam Marie Hunke's avatar Sirieam Marie Hunke
Browse files

Merge branch 'dev' into 'Issue/2915-migrateSql2Linked'

# Conflicts:
#   src/GraphDeployer/Deployer.cs
parents 3cb0ff4a 6ff20d1a
Branches
No related tags found
1 merge request!26New: MigrateSQL2Linked to GD
# Development container for dotnet # Development container for dotnet
FROM mcr.microsoft.com/devcontainers/dotnet:8.0 as develop FROM mcr.microsoft.com/devcontainers/dotnet:8.0 as develop
USER vscode ARG USERNAME=vscode
ARG USER_UID=1000
ARG USER_GID=$USER_UID
# Remove any existing user with the same UID (if it's not the specified user)
RUN if id -u $USER_UID >/dev/null 2>&1; then \
existing_user=$(getent passwd $USER_UID | cut -d: -f1); \
if [ "$existing_user" != "$USERNAME" ]; then \
userdel -f $existing_user; \
fi; \
fi
# Change the user's GID and UID
RUN groupmod -g $USER_GID $USERNAME \
&& usermod -u $USER_UID -g $USER_GID $USERNAME
# Change user folder owner and group
RUN chown -R $USER_GID:$USER_GID /home/$USERNAME
# [Optional] Set the default user. Omit if you want to keep the default as root.
USER $USERNAME
# Add nuget sources for private packages (here: api-client) # Add nuget sources for private packages (here: api-client)
RUN dotnet nuget add source "https://git.rwth-aachen.de/api/v4/projects/88930/packages/nuget/index.json" -n "api-client" RUN dotnet nuget add source "https://git.rwth-aachen.de/api/v4/projects/88930/packages/nuget/index.json" -n "api-client"
\ No newline at end of file
...@@ -8,6 +8,7 @@ ...@@ -8,6 +8,7 @@
"updateRemoteUserUID": false, "updateRemoteUserUID": false,
"remoteUser": "vscode", "remoteUser": "vscode",
"containerUser": "vscode", "containerUser": "vscode",
"postAttachCommand": "bash",
"customizations": { "customizations": {
"vscode": { "vscode": {
"settings": { "settings": {
......
...@@ -50,7 +50,7 @@ public class Deployer ...@@ -50,7 +50,7 @@ public class Deployer
// Check if the graph deployer has to skip SSL checks when connecting to the API // Check if the graph deployer has to skip SSL checks when connecting to the API
if (_graphDeployerConfiguration.SkipSslCheck) if (_graphDeployerConfiguration.SkipSslCheck)
{ {
_logger.LogInformation("Skipping SSL certificate validation..."); _logger.LogInformation("{y}Skipping SSL certificate validation...{res}", _y, _0);
// Skip SSL certificate validation // Skip SSL certificate validation
apiClientConfig.RemoteCertificateValidationCallback = (_, _, _, _) => true; apiClientConfig.RemoteCertificateValidationCallback = (_, _, _, _) => true;
} }
...@@ -81,7 +81,11 @@ public class Deployer ...@@ -81,7 +81,11 @@ public class Deployer
// Log the current application execution mode // Log the current application execution mode
if (opts.DummyMode) if (opts.DummyMode)
{ {
_logger.LogInformation("Running in Dummy Mode. No changes will be made."); _logger.LogInformation("{y}Running in Dummy Mode. No changes will be made.{r}", _y, _0);
}
if (opts.Redeploy)
{
_logger.LogInformation("{y}Redeploying all graphs.{r}", _y, _0);
} }
// Override the working folder if specified in the configuration // Override the working folder if specified in the configuration
...@@ -97,7 +101,7 @@ public class Deployer ...@@ -97,7 +101,7 @@ public class Deployer
// Iterate over the repositories and deploy the graphs // Iterate over the repositories and deploy the graphs
foreach (var graphRepo in _graphDeployerConfiguration.GitLab.Repositories) foreach (var graphRepo in _graphDeployerConfiguration.GitLab.Repositories)
{ {
_logger.LogInformation("Working with {repoName}", graphRepo.Name); _logger.LogInformation("Working with {bb}{repoName}{res}...", _bb, graphRepo.Name, _0);
// Clone the repository inside the Working Folder // Clone the repository inside the Working Folder
var success = CloneRepo(graphRepo.Url, WorkingFolder, _graphDeployerConfiguration.GitLab.Token, graphRepo.Ref); var success = CloneRepo(graphRepo.Url, WorkingFolder, _graphDeployerConfiguration.GitLab.Token, graphRepo.Ref);
...@@ -129,10 +133,10 @@ public class Deployer ...@@ -129,10 +133,10 @@ public class Deployer
} }
catch (Exception e) catch (Exception e)
{ {
_logger.LogError("Failed to load and process Turtle file: \"{file}\". Error: {errorMessage}", file, e.Message); _logger.LogError("Failed to load and process Turtle file: \"{r}{file}{res}\". Error: {errorMessage}", _r, file, _0, e.Message);
} }
}); });
_logger.LogDebug("Accumulated {count} graphs for possible deployment.", graphAccumulation.Count); _logger.LogDebug("Accumulated {c}{count}{res} graphs for possible deployment.", _c, graphAccumulation.Count, _0);
// Iterate over the accumulated graphs and deploy them // Iterate over the accumulated graphs and deploy them
foreach (var kv in graphAccumulation) foreach (var kv in graphAccumulation)
...@@ -142,11 +146,31 @@ public class Deployer ...@@ -142,11 +146,31 @@ public class Deployer
var graphId = kv.Key.ToString(); var graphId = kv.Key.ToString();
var currentRun = new Dictionary<string, string>(); var currentRun = new Dictionary<string, string>();
_logger.LogDebug("Deploying graph: {c}{graphName}{res}", _c, graphId, _0);
// Get the hash of the currently deployed graph and compare it with the hash of the graph to be deployed // Get the hash of the currently deployed graph and compare it with the hash of the graph to be deployed
files.ForEach((path) => currentRun.TryAdd(graphId, HashUtil.GetFileHash(path))); files.ForEach((path) => currentRun.TryAdd(graphId, HashUtil.GetFileHash(path)));
var deployedGraph = deployedGraphsList.FirstOrDefault((g) => g.Uri == graphId); var deployedGraph = deployedGraphsList.FirstOrDefault((g) => g.Uri == graphId);
var hasChanged = deployedGraph is null || !deployedGraph.FileHashes.Contains(currentRun[graphId]) || opts.Redeploy; var hasChanged = deployedGraph is null || !deployedGraph.FileHashes.Contains(currentRun[graphId]) || opts.Redeploy;
if (hasChanged)
{
_logger.LogDebug("The graph has changed.");
} else
{
_logger.LogDebug("The graph has not changed.");
}
if(deployedGraph is null)
{
_logger.LogDebug("Deployed graph is null");
} else {
_logger.LogDebug("Deployed hash: {hash}", string.Join(',', deployedGraph.FileHashes));
}
_logger.LogDebug("Incoming hash: {hash}", currentRun[graphId]);
// Deploy the graph if it has changed or if the redeploy flag is set // Deploy the graph if it has changed or if the redeploy flag is set
if (hasChanged) if (hasChanged)
{ {
...@@ -175,12 +199,12 @@ public class Deployer ...@@ -175,12 +199,12 @@ public class Deployer
}); });
} }
_logger.LogInformation("Deployed {graphName} successfully.", graphId); _logger.LogInformation("Deployed {c}{graphName}{res} {gb}successfully{res}.", _c, graphId, _0, _gb, _0);
DeployedGraphs.Add(graphId); DeployedGraphs.Add(graphId);
} }
else else
{ {
_logger.LogDebug("Skipped {graphName} as it has not changed.", graphId); _logger.LogDebug("Skipped {c}{graphName}{res} as it has not changed.", _c, graphId, _0);
SkippedGraphs.Add(graphId); SkippedGraphs.Add(graphId);
continue; continue;
} }
...@@ -249,7 +273,7 @@ public class Deployer ...@@ -249,7 +273,7 @@ public class Deployer
// Retrieve the reference of the repository, either the branch name or the commit hash // Retrieve the reference of the repository, either the branch name or the commit hash
var repoRef = localRepo.Head.IsTracking ? localRepo.Head.FriendlyName : localRepo.Head.Tip.Sha; var repoRef = localRepo.Head.IsTracking ? localRepo.Head.FriendlyName : localRepo.Head.Tip.Sha;
_logger.LogInformation("Repository successfully cloned and switched on ref \"{ref}\".", repoRef); _logger.LogInformation("Repository successfully cloned and switched on ref \"{c}{ref}{res}\".", _c, repoRef, _0);
return true; return true;
} }
......
...@@ -7,7 +7,7 @@ ...@@ -7,7 +7,7 @@
<AssemblyName>Coscine.GraphDeployer</AssemblyName> <AssemblyName>Coscine.GraphDeployer</AssemblyName>
<ImplicitUsings>enable</ImplicitUsings> <ImplicitUsings>enable</ImplicitUsings>
<Nullable>enable</Nullable> <Nullable>enable</Nullable>
<Version>2.1.0</Version> <Version>2.1.6</Version>
</PropertyGroup> </PropertyGroup>
<PropertyGroup> <PropertyGroup>
......
Output @ a5abb9b0
Subproject commit a5abb9b05d3ed65cb1bc82e9fac08a9bf3392b11
...@@ -13,7 +13,7 @@ ...@@ -13,7 +13,7 @@
"Token": null, "Token": null,
"Repositories": [ "Repositories": [
{ {
"Name": "Application Profiles", "Name": "Metadata Profiles",
"Url": "https://git.rwth-aachen.de/coscine/graphs/applicationprofiles.git" "Url": "https://git.rwth-aachen.de/coscine/graphs/applicationprofiles.git"
}, },
{ {
......
...@@ -8,8 +8,11 @@ ...@@ -8,8 +8,11 @@
<variable name="logHome" value="${basedir}/Logs" /> <variable name="logHome" value="${basedir}/Logs" />
<variable name="logLevel" value="Warn" /> <variable name="logLevel" value="Warn" />
<!-- This variable is used to remove ANSI escape codes from the log message. -->
<variable name="message_raw" value="${replace:inner=${message}:searchFor=\x1B\[[0-9;]*[A-Za-z]:replaceWith=:regex=true}" />
<!--Possible aspnet- variables: https://nlog-project.org/config/?tab=layout-renderers&search=package:nlog.web--> <!--Possible aspnet- variables: https://nlog-project.org/config/?tab=layout-renderers&search=package:nlog.web-->
<variable name="layout" value="${longdate} | [${level:uppercase=true}] ${message} ${exception:format=tostring}" /> <variable name="layout" value="${longdate} | [${level:uppercase=true}] ${message_raw} ${exception:format=tostring}" />
<targets> <targets>
<!-- Write logs to File --> <!-- Write logs to File -->
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment