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

Add FF for setting git config when out-of-memory problem #4474

Merged
merged 8 commits into from
Oct 20, 2023
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
11 changes: 10 additions & 1 deletion src/Agent.Plugins/GitCliManager.cs
Original file line number Diff line number Diff line change
Expand Up @@ -87,7 +87,16 @@ public virtual async Task LoadGitExecutionInfo(AgentTaskPluginExecutionContext c
{
string agentHomeDir = context.Variables.GetValueOrDefault("agent.homedirectory")?.Value;
ArgUtil.NotNullOrEmpty(agentHomeDir, nameof(agentHomeDir));
gitPath = Path.Combine(agentHomeDir, "externals", "git", "cmd", $"git.exe");

if (AgentKnobs.FixPossibleGitOutOfMemoryProblem.GetValue(context).AsBoolean())
{
gitPath = Path.Combine(agentHomeDir, "externals", "ff_git", "cmd", $"git.exe");
}
else
{
gitPath = Path.Combine(agentHomeDir, "externals", "git", "cmd", $"git.exe");
}

gitLfsPath = Path.Combine(agentHomeDir, "externals", "git", PlatformUtil.BuiltOnX86 ? "mingw32" : "mingw64", "bin", "git-lfs.exe");

// Prepend the PATH.
Expand Down
11 changes: 11 additions & 0 deletions src/Agent.Plugins/GitSourceProvider.cs
Original file line number Diff line number Diff line change
Expand Up @@ -684,6 +684,17 @@ public async Task GetSourceAsync(
executionContext.Warning("Unable turn off git auto garbage collection, git fetch operation may trigger auto garbage collection which will affect the performance of fetching.");
}

if (AgentKnobs.FixPossibleGitOutOfMemoryProblem.GetValue(executionContext).AsBoolean())
{
await gitCommandManager.GitConfig(executionContext, targetPath, "pack.threads", "1");
await gitCommandManager.GitConfig(executionContext, targetPath, "http.postBuffer", "524288000");
await gitCommandManager.GitConfig(executionContext, targetPath, "core.packedgitwindowsize", "256m");
await gitCommandManager.GitConfig(executionContext, targetPath, "core.packedgitlimit", "256m");
await gitCommandManager.GitConfig(executionContext, targetPath, "pack.windowmemory", "256m");
await gitCommandManager.GitConfig(executionContext, targetPath, "pack.deltaCacheSize", "256m");
await gitCommandManager.GitConfig(executionContext, targetPath, "pack.packSizeLimit", "256m");
}

// always remove any possible left extraheader setting from git config.
if (await gitCommandManager.GitConfigExist(executionContext, targetPath, $"http.{repositoryUrl.AbsoluteUri}.extraheader"))
{
Expand Down
7 changes: 7 additions & 0 deletions src/Agent.Sdk/Knob/AgentKnobs.cs
Original file line number Diff line number Diff line change
Expand Up @@ -121,6 +121,13 @@ public class AgentKnobs
new EnvironmentKnobSource("AGENT_GIT_USE_SECURE_PARAMETER_PASSING"),
new BuiltInDefaultKnobSource("true"));

public static readonly Knob FixPossibleGitOutOfMemoryProblem = new Knob(
nameof(FixPossibleGitOutOfMemoryProblem),
"When true, set config git properties to fix possible out of memory problem",
new RuntimeKnobSource("FIX_POSSIBLE_GIT_OUT_OF_MEMORY_PROBLEM"),
new EnvironmentKnobSource("FIX_POSSIBLE_GIT_OUT_OF_MEMORY_PROBLEM"),
new BuiltInDefaultKnobSource("false"));

public static readonly Knob TfVCUseSecureParameterPassing = new Knob(
nameof(TfVCUseSecureParameterPassing),
"If true, don't pass auth token in TFVC parameters",
Expand Down
2 changes: 2 additions & 0 deletions src/Misc/externals.sh
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ NODE10_VERSION="10.24.1"
NODE16_VERSION="16.20.2"
NODE20_VERSION="20.3.1"
MINGIT_VERSION="2.39.1"
FF_MINGIT_VERSION="2.42.0.2"
LFS_VERSION="3.3.0"

get_abs_path() {
Expand Down Expand Up @@ -160,6 +161,7 @@ if [[ "$PACKAGERUNTIME" == "win-x"* ]]; then
acquireExternalTool "$CONTAINER_URL/vstsom/m122_887c6659/vstsom.zip" vstsom
fi

acquireExternalTool "$CONTAINER_URL/mingit/${FF_MINGIT_VERSION}/MinGit-${FF_MINGIT_VERSION}-${BIT}-bit.zip" ff_git
acquireExternalTool "$CONTAINER_URL/mingit/${MINGIT_VERSION}/MinGit-${MINGIT_VERSION}-${BIT}-bit.zip" git
acquireExternalTool "$CONTAINER_URL/git-lfs/${LFS_VERSION}/x${BIT}/git-lfs.exe" "git/mingw${BIT}/bin"
acquireExternalTool "$CONTAINER_URL/pdbstr/1/pdbstr.zip" pdbstr
Expand Down
Loading