Skip to content

Add -NoBinaryLog switch to opt-out of binlog in CI#5421

Merged
wtgodbe merged 7 commits into
masterfrom
wtgodbe/NoBinLog
May 8, 2020
Merged

Add -NoBinaryLog switch to opt-out of binlog in CI#5421
wtgodbe merged 7 commits into
masterfrom
wtgodbe/NoBinLog

Conversation

@wtgodbe
Copy link
Copy Markdown
Member

@wtgodbe wtgodbe commented May 5, 2020

Some repos may want to opt-out of creating a binlog while in CI. For example currently, the AspNetCore binlog is currently large enough that it's hitting an msbuild error causing the build to OOM occasionally: dotnet/aspnetcore#21478. This PR adds a -NoBinaryLog switch that can be passed along with -CI to opt out of producing a binlog. It's kind of an ugly solution, but I couldn't think of another one that wasn't breaking. Changing the behavior of -CI would break repos that assumed passing -CI would create a binlog, and changing -Bl from a switch to a bool would break folks in a similar way. I'm open to suggestions, though.

@wtgodbe wtgodbe requested review from JunTaoLuo, chcosta, dougbu and tmat May 5, 2020 20:15
Copy link
Copy Markdown
Contributor

@dougbu dougbu left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Comment thread eng/common/build.sh Outdated
Comment thread eng/common/tools.ps1 Outdated
Comment thread eng/common/tools.ps1 Outdated
Comment thread eng/common/tools.sh
Comment thread eng/common/tools.ps1 Outdated
# Binary log must be enabled on CI.
[bool]$binaryLog = if (Test-Path variable:binaryLog) { $binaryLog } else { $ci }

# Set to true to opt out of outputing binary log while running in CI
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
# Set to true to opt out of outputing binary log while running in CI
# Set to true to opt out of outputting binary log while running in CI

Comment thread eng/common/tools.sh Outdated
# Binary log must be enabled on CI.
binary_log=${binary_log:-$ci}

# Set to true to opt out of outputing binary log while running in CI
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
# Set to true to opt out of outputing binary log while running in CI
# Set to true to opt out of outputting binary log while running in CI

Comment thread eng/common/build.ps1 Outdated
Write-Host "Advanced settings:"
Write-Host " -projects <value> Semi-colon delimited list of sln/proj's to build. Globbing is supported (*.sln)"
Write-Host " -ci Set when running on CI server"
Write-Host " -noBinaryLog Don't output binary log (useful when running on CI server) (short: -nobl)"
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'd remove the (useful when running on CI server) since it makes it sound like not using the binlog in CI would be recommended, but we actually want them in CI in most cases.

@tmat
Copy link
Copy Markdown
Member

tmat commented May 6, 2020

I don't like this. I'd prefer commenting out the condition if it's needed as a temporary workaround until the OOM is fixed:

 if (!$binaryLog) {
      Write-PipelineTelemetryError -Category 'Build' -Message 'Binary log must be enabled in CI build.'	        
      ExitWithExitCode 1	      ExitWithExitCode 1
    }

@dougbu
Copy link
Copy Markdown
Contributor

dougbu commented May 6, 2020

  1. @tmat even if we didn't want to disable producing binary logs in this repo, the new switch enables us removing hacks like this:
# Workaround Arcade check which asserts BinaryLog is true on CI.
# We always use binlogs on CI, but we customize the name of the log file
$tmpBinaryLog = $BinaryLog
if ($CI) {
    $BinaryLog = $true
}
  1. Commenting out that block in dotnet/aspnetcore would be overridden in every Arcade dependency update.
  2. @rainersigwald doesn't have a fix out yet for OOM when generating binlog for boost.hana msbuild#3577 i.e. we have no idea yet when it will be fixed.

@tmat
Copy link
Copy Markdown
Member

tmat commented May 6, 2020

Commenting out that block in dotnet/aspnetcore would be overridden in every Arcade dependency update.

I meant commenting it out in Arcade.

@dougbu
Copy link
Copy Markdown
Contributor

dougbu commented May 6, 2020

I meant commenting it out in Arcade.

How would that work without removing the -ci ==> -binaryLog default in tools.ps1❔ Also, commenting out is confusing and deletion is better (everything that ever existed is in git history😃).

@wtgodbe
Copy link
Copy Markdown
Member Author

wtgodbe commented May 6, 2020

How would that work without removing the -ci ==> -binaryLog default in tools.ps1

The same default also exists in build.ps1:

arcade/eng/common/build.ps1

Lines 136 to 139 in a8ee27e

if ($ci) {
$binaryLog = $true
$nodeReuse = $false
}

@markwilkie
Copy link
Copy Markdown
Member

(this makes me sad.....however...onward)

Question: Am I reading this correctly that -NoBinaryLog is only relevant for -CI? If so, maybe change the flag to -NoCIBinaryLog or something?

@dougbu
Copy link
Copy Markdown
Contributor

dougbu commented May 7, 2020

@wtgodbe could you try hacking your local Arcade bits to make the minimal eng/common/tools.ps1|sh change i.e. just remove the error❔ Leave our build.ps1|sh hack mostly in place but include !$BinaryLog in the condition and switch the $BinaryLog setting to false. If that works, it's probably the minimal change we could make.

(As a smaller detail, the block a bit later just redoes what tools.ps1|sh does when $BinaryLog is true.)

Note a change to configure-toolset.ps1 could override an explicit -binaryLog on the build.ps1|sh command line because it runs after the variables are set in tools.ps1|sh.

@markwilkie
Copy link
Copy Markdown
Member

Also, I'm not asking for a minimal change or a hack. I'm only asking if the flag is relevant to CI only, then perhaps we should put 'ci' in the name for clarity.

@dougbu
Copy link
Copy Markdown
Contributor

dougbu commented May 7, 2020

I'm not asking for a minimal change or a hack

Understood but I thought @tmat was looking for the minimal change. I suggested it and the hack would only be a variant of something dotnet/aspnetcore already needs to do. Either way, I'm fine.

Comment thread eng/common/tools.sh Outdated
# Set to true to output binary log from msbuild. Note that emitting binary log slows down the build.
# Binary log must be enabled on CI.
binary_log=${binary_log:-$ci}
binary_log=${binary_log:-$ci && -n $no_ci_binary_log}
Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm not sure if this is the right syntax

@markwilkie
Copy link
Copy Markdown
Member

This change makes sense to me.

Comment thread eng/common/build.ps1 Outdated
[switch] $publish,
[switch] $clean,
[switch][Alias('bl')]$binaryLog,
[switch][Alias('nobl')]$noCIBinaryLog,
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

nit: maybe "excludeCiBinlog", "no ci binary log" is slightly confusing as to what it means.

Copy link
Copy Markdown
Contributor

@dougbu dougbu left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please merge as soon as you're sure the tools.sh change is correct unless there are new objections.

Comment thread eng/common/tools.sh Outdated
# Set to true to output binary log from msbuild. Note that emitting binary log slows down the build.
# Binary log must be enabled on CI.
binary_log=${binary_log:-$ci}
binary_log=${binary_log:-$ci && -n $exclude_ci_binary_log}
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Did you find a way to test this @wtgodbe

If not, Arcade doesn't use --excludeCIBinlog or anything similar, you'll need to apply this change in dotnet/aspnetcore and use it in dotnet/aspnetcore (under WSL, on a Linux VM, or in your PR). A quick check would include --projects rc/Html/Abstractions/src/Microsoft.AspNetCore.Html.Abstractions.csproj on the build.sh command line.

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Just tested it, this didn't work - I couldn't figure out a way to get expressions working while setting default parameters, so I initialized the default above.

Comment thread eng/common/build.ps1 Outdated
Write-Host "Advanced settings:"
Write-Host " -projects <value> Semi-colon delimited list of sln/proj's to build. Globbing is supported (*.sln)"
Write-Host " -ci Set when running on CI server"
Write-Host " -excludeCIBinlog Don't output binary log (short: -nobl)"
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@chcosta do these descriptions need to line up perfectly❔ (I'm hoping this is a nit we can fix later.)

@chcosta
Copy link
Copy Markdown
Member

chcosta commented May 8, 2020

I don't want to delay unblocking people, but another nit is that the naming is still a bit inconsistent. Sometimes it's "binary log" and sometimes it's "binlog". I only mention it because if it's not inconsistent now, then it probably never will be as it may become a breaking change.

@dougbu , things like descriptions can be easily fixed whenever.

@wtgodbe wtgodbe merged commit 8078d8f into master May 8, 2020
@tmat
Copy link
Copy Markdown
Member

tmat commented May 8, 2020

So, you could have already done this without adding another parameter by setting the default for $binaryLog variable. The default can be overridden in eng\configure-toolset.ps1.

See dotnet/aspnetcore#21478 (comment).

@dougbu dougbu deleted the wtgodbe/NoBinLog branch May 10, 2020 00:10
@dougbu
Copy link
Copy Markdown
Contributor

dougbu commented May 10, 2020

The default can be overridden in eng\configure-toolset.ps1.

As I mentioned before, the default can't be changed. Instead the final version can be overridden -- without any information about the binaryLog value before tools.ps1 is invoked.

@markwilkie
Copy link
Copy Markdown
Member

To close on this discussion, let's leave this in for now but add a tracking issue to do a follow up later for possible clean up, or an improved approach.

cc/ @dougbu

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

7 participants