Skip to content

Merge dev into main. Integrate latest bug fixes and improvements. #1643

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 8 commits into from
Jun 12, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 0 additions & 1 deletion Common/OJS.Common/Constants/ServiceConstants.cs
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@ public static class ServiceConstants
public const string WorkersQueueName = "OJS.Servers.Worker.Consumers.SubmissionsForProcessingConsumer";

// HttpClients
public const string LokiHttpClientName = "Loki";
public const string SvnHttpClientName = "Svn";
public const string DefaultHttpClientName = "Default";

Expand Down
3 changes: 2 additions & 1 deletion Common/OJS.Common/Enumerations/OpenAiModels.cs
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
namespace OJS.Common.Enumerations;
// ReSharper disable InconsistentNaming
namespace OJS.Common.Enumerations;

public enum OpenAIModels
{
Expand Down
2 changes: 1 addition & 1 deletion Docker/Dockerfile.worker
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ COPY Services/Infrastructure ./Services/Infrastructure
WORKDIR Servers/Worker/OJS.Servers.Worker
RUN dotnet publish OJS.Servers.Worker.csproj -c Release --verbosity q -o /app

FROM ghcr.io/softuni-internal/judge_worker_base:latest
FROM ghcr.io/softuni-internal/judge_worker_base:dev-latest
WORKDIR /app
COPY --from=build-env /app .

Expand Down
4 changes: 3 additions & 1 deletion Docker/envs/common.env
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
# Environment Configuration
ASPNETCORE_URLS=http://*:80
DOTNET_RUNNING_IN_CONTAINER=true
DOTNET_RUNNING_IN_CONTAINER=true

OTEL_EXPORTER_OTLP_ENDPOINT=http://dashboard:18889
3 changes: 2 additions & 1 deletion Docker/envs/worker.env
Original file line number Diff line number Diff line change
@@ -1,2 +1,3 @@
ASPNETCORE_ENVIRONMENT=Production
DOTNET_RUNNING_IN_CONTAINER=true
DOTNET_RUNNING_IN_CONTAINER=true
OTEL_RESOURCE_ATTRIBUTES=service.name=worker, deployment.environment=local
47 changes: 15 additions & 32 deletions Docker/worker_base/Dockerfile
Original file line number Diff line number Diff line change
@@ -1,26 +1,4 @@
FROM ubuntu:22.04

ENV TZ=Etc/UTC
ENV LANG=en_US.UTF-8
ENV LANGUAGE=en_US:en
ENV LC_ALL=en_US.UTF-8

# Base Setup
RUN apt-get update && apt-get install -y --no-install-recommends \
curl \
sudo \
apt-transport-https \
ca-certificates \
gnupg \
lsb-release \
build-essential \
locales \
acl \
unzip && \
ln -snf /usr/share/zoneinfo/$TZ /etc/localtime && echo $TZ > /etc/timezone && \
sed -i '/en_US.UTF-8/s/^# //g' /etc/locale.gen && \
locale-gen && \
rm -rf /var/lib/apt/lists/*
FROM ghcr.io/softuni-internal/judge_worker_dotnet_base:latest

Check warning on line 1 in Docker/worker_base/Dockerfile

View check run for this annotation

Codacy Production / Codacy Static Code Analysis

Docker/worker_base/Dockerfile#L1

Using latest is prone to errors if the image will ever update. Pin the version explicitly to a release tag

# Add restricted_user
RUN useradd -m -s /bin/bash restricted_user && \
Expand All @@ -29,8 +7,6 @@

# Install supported languages and frameworks
RUN apt-get update && apt-get install -y \
dotnet-sdk-8.0 \
dotnet-sdk-6.0 \
openjdk-11-jdk \
openjdk-21-jdk \
python3.9 \
Expand All @@ -50,7 +26,7 @@
rm -rf /var/lib/apt/lists/*

# Install Maven
ENV MAVEN_VERSION 3.9.1
ENV MAVEN_VERSION=3.9.1
WORKDIR /judge-resources
RUN curl -O https://archive.apache.org/dist/maven/maven-3/$MAVEN_VERSION/binaries/apache-maven-$MAVEN_VERSION-bin.tar.gz && \
tar -xzvf apache-maven-$MAVEN_VERSION-bin.tar.gz && \
Expand Down Expand Up @@ -96,8 +72,8 @@
libpq-dev && \
rm -rf /var/lib/apt/lists/*

ENV PYENV_ROOT /root/.pyenv
ENV PATH $PYENV_ROOT/shims:$PYENV_ROOT/bin:$PATH
ENV PYENV_ROOT=/root/.pyenv
ENV PATH=$PYENV_ROOT/shims:$PYENV_ROOT/bin:$PATH
RUN curl https://pyenv.run | bash && \
pyenv update && \
pyenv install 3.11.5
Expand Down Expand Up @@ -131,14 +107,21 @@

USER root

# Go
ENV GO111MODULE=off

# Grant restricted user access to Node.js and Python env
RUN chgrp -R restricted_user /root/.nvm && \
chmod +x /root && chmod -R g+rx /root/.nvm && chmod -R g+rx /root/.pyenv

# Clean up
RUN apt-get autoremove -y && apt-get clean && rm -rf /var/lib/apt/lists/*

CMD tail -f /dev/null
# Environment varialbes needed during runtime
ENV NUGET_CONFIG_FILE=/root/.nuget/NuGet/NuGet.Config
ENV DOTNET_CLI_DISABLE_RESTORE_FIRST_RUN=true
ENV DOTNET_SKIP_FIRST_TIME_EXPERIENCE=true
ENV DOTNET_NOLOGO=true
ENV PATH="/usr/lib/dotnet:$PATH"

# Go
ENV GO111MODULE=off

CMD ["/bin/sh", "-c", "tail -f /dev/null"]
66 changes: 66 additions & 0 deletions Docker/worker_base/dotnet/Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,66 @@
FROM ubuntu:22.04

ENV TZ=Etc/UTC
ENV LANG=en_US.UTF-8
ENV LANGUAGE=en_US:en
ENV LC_ALL=en_US.UTF-8

# Base Setup
RUN apt-get update && apt-get install -y --no-install-recommends \

Check warning on line 9 in Docker/worker_base/dotnet/Dockerfile

View check run for this annotation

Codacy Production / Codacy Static Code Analysis

Docker/worker_base/dotnet/Dockerfile#L9

Pin versions in apt get install. Instead of `apt-get install <package>` use `apt-get install <package>=<version>`
curl \
sudo \
apt-transport-https \
ca-certificates \
gnupg \
lsb-release \
build-essential \
locales \
acl \
unzip && \
ln -snf /usr/share/zoneinfo/$TZ /etc/localtime && echo $TZ > /etc/timezone && \
sed -i '/en_US.UTF-8/s/^# //g' /etc/locale.gen && \
locale-gen && \
rm -rf /var/lib/apt/lists/*

RUN apt-get update && apt-get install -y \

Check notice on line 25 in Docker/worker_base/dotnet/Dockerfile

View check run for this annotation

Codacy Production / Codacy Static Code Analysis

Docker/worker_base/dotnet/Dockerfile#L25

Avoid additional packages by specifying `--no-install-recommends`

Check warning on line 25 in Docker/worker_base/dotnet/Dockerfile

View check run for this annotation

Codacy Production / Codacy Static Code Analysis

Docker/worker_base/dotnet/Dockerfile#L25

Pin versions in apt get install. Instead of `apt-get install <package>` use `apt-get install <package>=<version>`
dotnet-sdk-8.0 \
dotnet-sdk-6.0 && \
rm -rf /var/lib/apt/lists/*

WORKDIR /judge-resources/dotnet/nuget-packages

# Set environment variables for offline mode
ENV NUGET_PACKAGES=/judge-resources/dotnet/nuget-packages
COPY ./packages-net6.csproj /tmp/packages-net6.csproj
COPY ./packages-net8.csproj /tmp/packages-net8.csproj
COPY ./NuGet.config /opt/NuGet.config

WORKDIR /tmp
RUN dotnet restore packages-net6.csproj && \
dotnet restore packages-net8.csproj

# Create dummy console apps to download runtime dependencies
RUN dotnet new console -n DummyNet6 -f net6.0 && \
dotnet new console -n DummyNet8 -f net8.0

RUN cd DummyNet6 && \

Check warning on line 46 in Docker/worker_base/dotnet/Dockerfile

View check run for this annotation

Codacy Production / Codacy Static Code Analysis

Docker/worker_base/dotnet/Dockerfile#L46

Use WORKDIR to switch to a directory
dotnet restore --runtime linux-x64 && \
dotnet publish --no-restore --runtime linux-x64 --self-contained false

RUN cd DummyNet8 && \

Check warning on line 50 in Docker/worker_base/dotnet/Dockerfile

View check run for this annotation

Codacy Production / Codacy Static Code Analysis

Docker/worker_base/dotnet/Dockerfile#L50

Use WORKDIR to switch to a directory
dotnet restore --runtime linux-x64 && \
dotnet publish --no-restore --runtime linux-x64 --self-contained false

RUN rm -rf /tmp/*

# Copy nuget.config (just in case create 2 versions for case sensitivity issues)
WORKDIR /root/.nuget/NuGet
RUN cp /opt/NuGet.config /root/.nuget/NuGet/NuGet.config && \
cp /opt/NuGet.config /root/.nuget/NuGet/NuGet.Config

RUN chmod -R 755 /judge-resources/dotnet/nuget-packages

RUN ln -sf /usr/lib/dotnet/dotnet /usr/bin/dotnet && \
chmod +x /usr/lib/dotnet/dotnet

ENV PATH="/usr/lib/dotnet:$PATH"
10 changes: 10 additions & 0 deletions Docker/worker_base/dotnet/NuGet.config
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
<?xml version="1.0" encoding="utf-8"?>
<configuration>
<packageSources>
<clear />
<add key="offline-cache" value="/judge-resources/dotnet/nuget-packages" />
</packageSources>
<config>
<add key="globalPackagesFolder" value="/judge-resources/dotnet/nuget-packages" />
</config>
</configuration>
17 changes: 17 additions & 0 deletions Docker/worker_base/dotnet/packages-net6.csproj
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<TargetFramework>net6.0</TargetFramework>
<RuntimeIdentifier>linux-x64</RuntimeIdentifier>
</PropertyGroup>
<ItemGroup>
<PackageReference Include="NUnit" Version="3.13.2" />
<PackageReference Include="NUnitLite" Version="3.13.2" />
<PackageReference Include="Newtonsoft.Json" Version="13.0.3" />
<PackageReference Include="System.Text.Json" Version="8.0.0" />
<PackageReference Include="Microsoft.Extensions.Logging" Version="8.0.0" />
<PackageReference Include="Microsoft.Extensions.DependencyInjection" Version="8.0.0" />
<PackageReference Include="Microsoft.EntityFrameworkCore.InMemory" Version="6.0.1" />
<PackageReference Include="Microsoft.EntityFrameworkCore.Proxies" Version="6.0.1" />
<PackageReference Include="System.ComponentModel.Annotations" Version="5.0.0" />
</ItemGroup>
</Project>
17 changes: 17 additions & 0 deletions Docker/worker_base/dotnet/packages-net8.csproj
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<TargetFramework>net8.0</TargetFramework>
<RuntimeIdentifier>linux-x64</RuntimeIdentifier>
</PropertyGroup>
<ItemGroup>
<PackageReference Include="NUnit" Version="3.13.2" />
<PackageReference Include="NUnitLite" Version="3.13.2" />
<PackageReference Include="Newtonsoft.Json" Version="13.0.3" />
<PackageReference Include="System.Text.Json" Version="8.0.0" />
<PackageReference Include="Microsoft.Extensions.Logging" Version="8.0.0" />
<PackageReference Include="Microsoft.Extensions.DependencyInjection" Version="8.0.0" />
<PackageReference Include="Microsoft.EntityFrameworkCore.InMemory" Version="8.0.0" />
<PackageReference Include="Microsoft.EntityFrameworkCore.Proxies" Version="8.0.0" />
<PackageReference Include="System.ComponentModel.Annotations" Version="5.0.0" />
</ItemGroup>
</Project>
3 changes: 3 additions & 0 deletions Docker/worker_base/js/setup_node.sh
Original file line number Diff line number Diff line change
Expand Up @@ -33,5 +33,8 @@ npm install --prefix /judge-resources/js/v20
npm install --prefix /judge-resources/js/v20/js-run-spa-in-docker-and-execute-mocha-tests
npm install -g typescript

# Install ESLint and its plugins globally
npm install -g eslint eslint-plugin-import

# Update /usr/bin/node to point to the currently active Node.js version:
ln -sf "$(which node)" /usr/bin/node
Original file line number Diff line number Diff line change
Expand Up @@ -4,26 +4,30 @@ namespace OJS.Servers.Administration.Consumers;
using MassTransit;
using Microsoft.Extensions.Logging;
using OJS.PubSub.Worker.Models.Submissions;
using OJS.Servers.Infrastructure.Telemetry;
using OJS.Services.Administration.Business.Submissions;
using OJS.Services.Common.Telemetry;
using OJS.Services.Infrastructure.Constants;

public class RetestSubmissionConsumer : IConsumer<RetestSubmissionPubSubModel>
public class RetestSubmissionConsumer(
ISubmissionsBusinessService submissionsBusinessService,
ILogger<RetestSubmissionConsumer> logger,
ITracingService tracingService)
: IConsumer<RetestSubmissionPubSubModel>
{
private readonly ISubmissionsBusinessService submissionsBusinessService;
private readonly ILogger<RetestSubmissionConsumer> logger;

public RetestSubmissionConsumer(
ISubmissionsBusinessService submissionsBusinessService,
ILogger<RetestSubmissionConsumer> logger)
{
this.submissionsBusinessService = submissionsBusinessService;
this.logger = logger;
}

public async Task Consume(ConsumeContext<RetestSubmissionPubSubModel> context)
{
this.logger.LogReceivedRetestSubmission(context.Message.Id);
await this.submissionsBusinessService.Retest(context.Message.Id, context.Message.Verbosely);
this.logger.LogRetestedSubmission(context.Message.Id);
}
=> await tracingService.TraceAsync(
OjsActivitySources.submissions,
OjsActivitySources.SubmissionActivities.Retest,
async activity =>
{
logger.LogReceivedRetestSubmission(context.Message.Id);
await submissionsBusinessService.Retest(context.Message.Id, context.Message.Verbosely);
activity?.SetTag("submission.verbosely", context.Message.Verbosely);
activity?.SetTag("retest.success", true);
logger.LogRetestedSubmission(context.Message.Id);
},
tags: null,
BusinessContext.ForSubmission(context.Message.Id),
continueFromMessageHeaders: context);
}
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,6 @@ namespace OJS.Servers.Administration.Extensions;
using OJS.Common.Exceptions;
using OJS.Data;
using OJS.Data.Models.Users;
using OJS.Servers.Administration.Consumers;
using OJS.Servers.Administration.Middleware;
using OJS.Servers.Infrastructure.Extensions;
using OJS.Services.Administration.Business.Contests.Validators;
Expand Down
3 changes: 2 additions & 1 deletion Servers/Administration/OJS.Servers.Administration/Program.cs
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,8 @@ public static void Main(string[] args)
var builder = WebApplication.CreateBuilder(args);

builder.Services.ConfigureServices(builder.Configuration, builder.Environment);
builder.Host.UseLogger(builder.Environment);

builder.ConfigureOpenTelemetry();

var app = builder.Build();

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,9 @@
"launchBrowser": false,
"applicationUrl": "http://localhost:5001",
"environmentVariables": {
"ASPNETCORE_ENVIRONMENT": "Development"
"ASPNETCORE_ENVIRONMENT": "Development",
"OTEL_EXPORTER_OTLP_ENDPOINT": "http://127.0.0.1:18889",
"OTEL_RESOURCE_ATTRIBUTES": "service.name=administration-api, deployment.environment=local"
}
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,11 +2,8 @@
"ConnectionStrings": {
"DefaultConnection": "Data Source=localhost; Initial Catalog=OpenJudgeSystem; Integrated Security=true; TrustServerCertificate=True"
},
"ApplicationSettings": {
"OtlpCollectorBaseUrl": "http://localhost:3100"
},
"Redis": {
"ConnectionString": "localhost,password=redisPass123,ConnectTimeout=10000,abortConnect=false"
"ConnectionString": "127.0.0.1,password=redisPass123,ConnectTimeout=10000,abortConnect=false"
},
"MessageQueue": {
"Host": "localhost"
Expand All @@ -31,11 +28,11 @@
},
{
"Name": "UI API",
"Uri": "http://localhost:5010/api/health"
"Uri": "http://127.0.0.1:5010/api/health"
},
{
"Name": "Worker API",
"Uri": "http://localhost:8003/api/health"
"Uri": "http://127.0.0.1:8003/api/health"
}
],
"EvaluationTimeInSeconds": 3600
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,6 @@
"ApplicationSettings": {
"SharedAuthCookieDomain": "localhost",
"ApiKey": "12345",
"OtlpCollectorBaseUrl": "http://loki:3100",
"OtlpCollectorLogsPushPath": "/otlp/v1/logs",
"SecondsBetweenContestLimitsAdjustment": 120,
"SecondsBetweenWorkersBusyRatioPolling": 20
},
Expand Down Expand Up @@ -76,11 +74,13 @@
"EvaluationTimeInSeconds": 10,
"MinimumSecondsBetweenFailureNotifications": 60
},
"Logging": {
"LogLevel": {
"Serilog": {
"MinimumLevel": {
"Default": "Information",
"Microsoft": "Warning",
"Microsoft.Hosting.Lifetime": "Information"
"Override": {
"System.Net.Http.HttpClient": "Warning",
"Microsoft.AspNetCore.Hosting.Diagnostics": "Information"
}
}
},
"Http": {
Expand Down
Loading
Loading