Skip to content
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

Initialize VMR #3322

Merged
merged 52 commits into from
Feb 22, 2024
Merged
Show file tree
Hide file tree
Changes from 43 commits
Commits
Show all changes
52 commits
Select commit Hold shift + click to select a range
47d3a46
initialize secrets
dkurepa Feb 9, 2024
c05ab10
add dev vault config
dkurepa Feb 12, 2024
51645b0
add
dkurepa Feb 12, 2024
cbbc6f8
Merge remote-tracking branch 'source/main' into dkurepa/InitializeVMR
dkurepa Feb 12, 2024
c25e8c2
try checking out dotnet/dotent
dkurepa Feb 14, 2024
fbb277a
test the image
dkurepa Feb 14, 2024
ef5c84a
remove comment from entrypoint
dkurepa Feb 14, 2024
f9abaca
add vmr registrations
dkurepa Feb 14, 2024
ed7715f
initialize the vmr
dkurepa Feb 14, 2024
cf1fa0c
dkurepa/InitializeVMR
dkurepa Feb 19, 2024
5ada34f
run as root
dkurepa Feb 19, 2024
18ec6f5
clone vmr
dkurepa Feb 19, 2024
ce195de
Add git clone telemetry
dkurepa Feb 19, 2024
e017a8e
fix stack overflow
dkurepa Feb 19, 2024
37d33e2
use 1es
dkurepa Feb 19, 2024
e5d1132
use a startup filter
dkurepa Feb 19, 2024
44ea14d
ues fast pool
dkurepa Feb 19, 2024
f27ada7
fix
dkurepa Feb 19, 2024
c1025bb
fix di
dkurepa Feb 19, 2024
391f4bd
fix
dkurepa Feb 19, 2024
055d5cd
resolve comments
dkurepa Feb 20, 2024
664458d
set vmrUri through envVariable
dkurepa Feb 20, 2024
bdc61c5
use 1es
dkurepa Feb 20, 2024
ab5f007
rename const
dkurepa Feb 20, 2024
43b3195
fix const name
dkurepa Feb 20, 2024
13ba132
update csproj
dkurepa Feb 20, 2024
94591a2
update dockerfile
dkurepa Feb 20, 2024
3ee166e
use fast pool
dkurepa Feb 20, 2024
d95bbd6
fix dockerile
dkurepa Feb 20, 2024
47b5e19
add missing project to dockerfile
dkurepa Feb 20, 2024
3b61e95
resolve comments
dkurepa Feb 20, 2024
ef70310
resolve more comments
dkurepa Feb 20, 2024
95f4b42
record telemetry during vmr cloning
dkurepa Feb 20, 2024
4d60dcb
add vmrUri to VmrInfo
dkurepa Feb 20, 2024
8e49ec4
indentation
dkurepa Feb 20, 2024
ea0d7df
use 1es
dkurepa Feb 20, 2024
cadecbf
deployment improvement
dkurepa Feb 21, 2024
041ca7d
don't use write error in deployment script, use write-warning
dkurepa Feb 21, 2024
127ea46
Merge remote-tracking branch 'source/main' into dkurepa/InitializeVMR
dkurepa Feb 21, 2024
1295215
initialize vmr in a background service
dkurepa Feb 21, 2024
b8136d5
rename to VmrReady check
dkurepa Feb 21, 2024
fa95812
update bicep, update readme
dkurepa Feb 21, 2024
78f2fac
remove things
dkurepa Feb 21, 2024
b6508e0
update vmr health check tag
dkurepa Feb 21, 2024
561ca7f
Update src/ProductConstructionService/ProductConstructionService.Api/…
dkurepa Feb 21, 2024
30478b6
resolve comments
dkurepa Feb 21, 2024
7059b6f
Merge remote-tracking branch 'origin/dkurepa/InitializeVMR' into dkur…
dkurepa Feb 21, 2024
b39ca7a
remove /vmrReady endpoint, use /health instead
dkurepa Feb 21, 2024
14bc93b
send PreconditionFailed result when bad start request
dkurepa Feb 21, 2024
bebe7b8
use 1es
dkurepa Feb 21, 2024
f50a543
try bumping Microsoft.Bcl.AsyncInterfaces
dkurepa Feb 21, 2024
5a6c454
fix tests, jobProcessorScopeManager configuration
dkurepa Feb 22, 2024
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
38 changes: 38 additions & 0 deletions .vault-config/product-construction-dev.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
storageLocation:
type: azure-key-vault
parameters:
subscription: cab65fc3-d077-467d-931f-3932eabf36d3
name: ProductConstructionDev

references:
helixkv:
type: azure-key-vault
parameters:
subscription: a4fc5514-21a9-4296-bfaf-5c7ee7fa35d1
name: helixkv

engkeyvault:
type: azure-key-vault
parameters:
subscription: a4fc5514-21a9-4296-bfaf-5c7ee7fa35d1
name: engkeyvault

secrets:
BotAccount-dotnet-bot-repo-PAT:
type: github-access-token
parameters:
gitHubBotAccountSecret:
location: engkeyvault
name: BotAccount-dotnet-bot
gitHubBotAccountName: dotnet-bot

dn-bot-all-orgs-code-r:
type: azure-devops-access-token
parameters:
domainAccountName: dn-bot
domainAccountSecret:
location: helixkv
name: dn-bot-account-redmond
name: dn-bot-all-orgs-code-r
organizations: devdiv dnceng
scopes: code
54 changes: 54 additions & 0 deletions .vault-config/product-construction-int.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,54 @@
storageLocation:
type: azure-key-vault
parameters:
subscription: cab65fc3-d077-467d-931f-3932eabf36d3
name: ProductConstructionInt

references:
maestroint:
type: azure-key-vault
parameters:
subscription: cab65fc3-d077-467d-931f-3932eabf36d3
name: maestroint

helixkv:
type: azure-key-vault
parameters:
subscription: a4fc5514-21a9-4296-bfaf-5c7ee7fa35d1
name: helixkv

engkeyvault:
type: azure-key-vault
parameters:
subscription: a4fc5514-21a9-4296-bfaf-5c7ee7fa35d1
name: engkeyvault

secrets:
build-asset-registry-sql-connection-string:
type: sql-connection-string
parameters:
adminConnection:
location: maestroint
name: build-asset-registry-admin-connection-string
dataSource: tcp:maestro-int-server.database.windows.net,1433
database: BuildAssetRegistry
permissions: r

BotAccount-dotnet-bot-repo-PAT:
type: github-access-token
parameters:
gitHubBotAccountSecret:
location: engkeyvault
name: BotAccount-dotnet-bot
gitHubBotAccountName: dotnet-bot

dn-bot-all-orgs-code-r:
type: azure-devops-access-token
parameters:
domainAccountName: dn-bot
domainAccountSecret:
location: helixkv
name: dn-bot-account-redmond
name: dn-bot-all-orgs-code-r
organizations: devdiv dnceng
scopes: code
24 changes: 0 additions & 24 deletions .vault-config/productconstructionint.yaml

This file was deleted.

5 changes: 3 additions & 2 deletions azure-pipelines-product-construction-service.yml
Original file line number Diff line number Diff line change
Expand Up @@ -43,8 +43,9 @@ stages:
- job: Publish
displayName: Publish Product Construction Service
pool:
name: NetCore1ESPool-Internal
demands: ImageOverride -equals 1es-ubuntu-2004
# name: NetCore1ESPool-Internal
# demands: ImageOverride -equals 1es-ubuntu-2004
vmImage: 'ubuntu-latest'
dkurepa marked this conversation as resolved.
Show resolved Hide resolved

steps:
- checkout: self
Expand Down
4 changes: 2 additions & 2 deletions eng/deployment/product-construction-service-deploy.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ function StopAndWait([string]$pcsStatusUrl, [string]$pcsStopUrl) {
} While ($pcsStateResponse.Content -notmatch "Stopped")
}
catch {
Write-Error "An error occurred: $($_.Exception.Message). Deploying the new revision without stopping the service."
Write-Warning "An error occurred: $($_.Exception.Message). Deploying the new revision without stopping the service."
premun marked this conversation as resolved.
Show resolved Hide resolved
}
return
}
Expand Down Expand Up @@ -119,7 +119,7 @@ try
Write-Host "All traffic has been redirected to label $inactiveLabel"
}
else {
Write-Error "New revision is not running. Check revision $newRevisionName logs in the inactive revisions. Deactivating the new revision"
Write-Warning "New revision is not running. Check revision $newRevisionName logs in the inactive revisions. Deactivating the new revision"
az containerapp revision deactivate --revision $newRevisionName --name $containerappName --resource-group $resourceGroupName
exit 1
}
Expand Down
26 changes: 25 additions & 1 deletion eng/service-templates/ProductConstructionService/provision.bicep
Original file line number Diff line number Diff line change
Expand Up @@ -170,6 +170,18 @@ var env = [
name: 'APPLICATIONINSIGHTS_CONNECTION_STRING'
value: applicationInsights.properties.ConnectionString
}
{
name: 'VmrPath'
value: '/mnt/datadir/vmr'
}
{
name: 'TmpPath'
value: '/mnt/datadir/tmp'
}
{
name: 'VmrUri'
value: 'https://github.com/maestro-auth-test/dnceng-vmr'
dkurepa marked this conversation as resolved.
Show resolved Hide resolved
}
]

// container app hosting the Product Construction Service
Expand Down Expand Up @@ -223,7 +235,7 @@ resource containerapp 'Microsoft.App/containerApps@2023-04-01-preview' = {
probes: [
{
httpGet: {
path: '/health'
path: '/alive'
port: 8080
scheme: 'HTTP'
}
Expand All @@ -233,6 +245,18 @@ resource containerapp 'Microsoft.App/containerApps@2023-04-01-preview' = {
failureThreshold: 3
type: 'Startup'
}
{
httpGet: {
path: '/vmrReady'
port: 8080
scheme: 'HTTP'
}
initialDelaySeconds: 60
failureThreshold: 10
successThreshold: 1
periodSeconds: 30
type: 'Readiness'
}
]
}
]
Expand Down
2 changes: 2 additions & 0 deletions src/Microsoft.DotNet.Darc/DarcLib/Constants.cs
Original file line number Diff line number Diff line change
Expand Up @@ -27,4 +27,6 @@ public class Constants
public static readonly LibGit2Sharp.Identity DotnetBotIdentity = new(DarcBotName, DarcBotEmail);

public const string CommonScriptFilesPath = "eng/common";

public const string VmrFolderName = "vmr";
}
Original file line number Diff line number Diff line change
Expand Up @@ -59,6 +59,11 @@ Task<ILocalGitRepo> PrepareCloneAsync(
IReadOnlyCollection<string> requestedRefs,
string checkoutRef,
CancellationToken cancellationToken);

/// <summary>
/// Prepares a clone of the VMR.
/// </summary>
Task<ILocalGitRepo> PrepareVmrCloneAsync(string vmrUri, CancellationToken cancellationToken);
}

/// <summary>
Expand Down Expand Up @@ -200,6 +205,19 @@ public async Task<ILocalGitRepo> PrepareCloneAsync(
return repo;
}

public async Task<ILocalGitRepo> PrepareVmrCloneAsync(string vmrUri, CancellationToken cancellationToken)
{
// The vmr directory won't use a hash for its name, so we don't accidentally overwrite it
var path = await PrepareCloneInternal(vmrUri, Constants.VmrFolderName, cancellationToken);
var repo = _localGitRepoFactory.Create(path);
premun marked this conversation as resolved.
Show resolved Hide resolved
await repo.CheckoutAsync("main");

_vmrInfo.VmrPath = path;
_vmrInfo.VmrUri = vmrUri;

return repo;
}

private async Task<NativePath> PrepareCloneInternal(string remoteUri, string dirName, CancellationToken cancellationToken)
{
cancellationToken.ThrowIfCancellationRequested();
Expand Down
28 changes: 25 additions & 3 deletions src/Microsoft.DotNet.Darc/DarcLib/VirtualMonoRepo/VmrInfo.cs
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,11 @@ public interface IVmrInfo
/// </summary>
NativePath VmrPath { get; set; }

/// <summary>
/// Uri from which the VMR has been cloned
/// </summary>
string VmrUri { get; set; }

/// <summary>
/// Path within the VMR where VMR patches are stored.
/// These patches are applied on top of the synchronized content.
Expand Down Expand Up @@ -79,21 +84,38 @@ public class VmrInfo : IVmrInfo

public static UnixPath DefaultRelativeSourceManifestPath { get; } = RelativeSourcesDir / SourceManifestFileName;

public NativePath VmrPath { get; set; }
private NativePath _vmrPath;

public NativePath VmrPath
{
get
{
return _vmrPath;
}

set
{
_vmrPath = value;
SourceManifestPath = value / DefaultRelativeSourceManifestPath;
}
}

public NativePath TmpPath { get; set; }

public string? PatchesPath { get; set; }

public string? SourceMappingsPath { get; set; }

public string VmrUri { get; set; }

public IReadOnlyCollection<(string Source, string? Destination)> AdditionalMappings { get; set; } = Array.Empty<(string, string?)>();

public VmrInfo(NativePath vmrPath, NativePath tmpPath)
{
VmrPath = vmrPath;
_vmrPath = vmrPath;
TmpPath = tmpPath;
SourceManifestPath = vmrPath / SourcesDir / SourceManifestFileName;
VmrUri = Constants.DefaultVmrUri;
}

public VmrInfo(string vmrPath, string tmpPath) : this(new NativePath(vmrPath), new NativePath(tmpPath))
Expand All @@ -108,5 +130,5 @@ public VmrInfo(NativePath vmrPath, NativePath tmpPath)

public static UnixPath GetRelativeRepoSourcesPath(string mappingName) => RelativeSourcesDir / mappingName;

public NativePath SourceManifestPath { get; }
public NativePath SourceManifestPath { get; private set; }
}
Original file line number Diff line number Diff line change
Expand Up @@ -8,29 +8,34 @@
namespace ProductConstructionService.Api.Controllers;

[Route("status")]
public class StatusController(JobsProcessorScopeManager jobsProcessorScopeManager) : Controller
public class StatusController(JobProcessorScopeManager jobProcessorScopeManager) : Controller
{
private readonly JobsProcessorScopeManager _jobsProcessorScopeManager = jobsProcessorScopeManager;
private readonly JobProcessorScopeManager _jobProcessorScopeManager = jobProcessorScopeManager;

[HttpPut("stop")]
public IActionResult StopPcsJobsProcessor()
public IActionResult StopPcsJobProcessor()
{
_jobsProcessorScopeManager.FinishJobAndStop();
_jobProcessorScopeManager.FinishJobAndStop();

return GetPcsJobsProcessorStatus();
return GetPcsJobProcessorStatus();
}

[HttpPut("start")]
public IActionResult StartPcsJobsProcessor()
public IActionResult StartPcsJobProcessor()
{
_jobsProcessorScopeManager.Start();
if (_jobProcessorScopeManager.State == JobsProcessorState.WaitingForVmrClone)
{
return BadRequest("The JobProcessor can't be started until the VMR is cloned");
dkurepa marked this conversation as resolved.
Show resolved Hide resolved
premun marked this conversation as resolved.
Show resolved Hide resolved
}

return GetPcsJobsProcessorStatus();
_jobProcessorScopeManager.Start();

return GetPcsJobProcessorStatus();
}

[HttpGet]
public IActionResult GetPcsJobsProcessorStatus()
public IActionResult GetPcsJobProcessorStatus()
{
return Ok(_jobsProcessorScopeManager.State.GetDisplayName());
return Ok(_jobProcessorScopeManager.State.GetDisplayName());
}
}
Original file line number Diff line number Diff line change
@@ -1,35 +1,51 @@
#See https://aka.ms/customizecontainer to learn how to customize your debug container and how Visual Studio uses this Dockerfile to build your images for faster debugging.

FROM mcr.microsoft.com/dotnet/aspnet:8.0 AS base
USER app
RUN apt-get update
RUN apt-get install git -y
WORKDIR /app
EXPOSE 8080
EXPOSE 8081

FROM mcr.microsoft.com/dotnet/sdk:8.0 AS build
ARG BUILD_CONFIGURATION=Release
WORKDIR /src

COPY ["Directory.Packages.props", "Directory.Build.props", "Directory.Build.targets", "NuGet.config", "global.json", "./"]
COPY ["eng/Versions.props", "./eng/"]
COPY ["src/ProductConstructionService/ProductConstructionService.Api/ProductConstructionService.Api.csproj", "./ProductConstructionService/ProductConstructionService.Api/"]
COPY ["src/ProductConstructionService/ProductConstructionService.ServiceDefaults/ProductConstructionService.ServiceDefaults.csproj", "./ProductConstructionService/ProductConstructionService.ServiceDefaults/"]

COPY ["src/Maestro/Client/src/Microsoft.DotNet.Maestro.Client.csproj", "./Maestro/Client/src/"]
COPY ["src/Maestro/Maestro.AzureDevOps/Maestro.AzureDevOps.csproj", "./Maestro/Maestro.AzureDevOps/"]
COPY ["src/Maestro/Maestro.Data/Maestro.Data.csproj", "./Maestro/Maestro.Data/"]
COPY ["src/Maestro/Maestro.DataProviders/Maestro.DataProviders.csproj", "./Maestro/Maestro.DataProviders/"]
COPY ["src/Maestro/Maestro.MergePolicyEvaluation/Maestro.MergePolicyEvaluation.csproj", "./Maestro/Maestro.MergePolicyEvaluation/"]

COPY ["src/Microsoft.DotNet.Darc/DarcLib/Microsoft.DotNet.DarcLib.csproj", "./Microsoft.DotNet.Darc/DarcLib/"]

COPY ["src/ProductConstructionService/ProductConstructionService.Api/ProductConstructionService.Api.csproj", "./ProductConstructionService/ProductConstructionService.Api/"]
COPY ["src/ProductConstructionService/ProductConstructionService.ServiceDefaults/ProductConstructionService.ServiceDefaults.csproj", "./ProductConstructionService/ProductConstructionService.ServiceDefaults/"]

RUN dotnet restore "./ProductConstructionService/ProductConstructionService.Api/ProductConstructionService.Api.csproj"
COPY ["src/ProductConstructionService", "./ProductConstructionService"]

COPY ["src/Maestro/Client/src", "./Maestro/Client/src"]
COPY ["src/Maestro/Maestro.AzureDevOps", "./Maestro/Maestro.AzureDevOps"]
COPY ["src/Maestro/Maestro.Data", "./Maestro/Maestro.Data"]
COPY ["src/Maestro/Maestro.DataProviders", "./Maestro/Maestro.DataProviders"]
COPY ["src/Maestro/Maestro.MergePolicyEvaluation", "./Maestro/Maestro.MergePolicyEvaluation"]

COPY ["src/Microsoft.DotNet.Darc/DarcLib", "./Microsoft.DotNet.Darc/DarcLib"]

COPY ["src/ProductConstructionService", "./ProductConstructionService"]

RUN dotnet build "./ProductConstructionService/ProductConstructionService.Api/ProductConstructionService.Api.csproj" -c $BUILD_CONFIGURATION -o /app/build --no-restore

FROM build AS publish
ARG BUILD_CONFIGURATION=Release
RUN dotnet publish "./ProductConstructionService/ProductConstructionService.Api/ProductConstructionService.Api.csproj" -c $BUILD_CONFIGURATION -o /app/publish /p:UseAppHost=false

FROM base AS final
RUN git config --global user.email "dotnet-maestro[bot]@users.noreply.github.com" \
&& git config --global user.name "dotnet-maestro[bot]"
WORKDIR /app
COPY --from=publish /app/publish .
ENTRYPOINT ["dotnet", "ProductConstructionService.Api.dll"]
ENTRYPOINT ["dotnet", "ProductConstructionService.Api.dll"]
Loading