Fallback to cached bundles if there is no network connection#4772
Fallback to cached bundles if there is no network connection#4772aishwaryabh merged 10 commits intomainfrom
Conversation
There was a problem hiding this comment.
Pull request overview
This PR implements fallback to cached extension bundles when network connectivity is unavailable during func start. The implementation adds offline detection capabilities, caches offline status for performance, and provides fallback logic to use locally cached bundles when downloads fail. The PR also introduces conditional bundle downloading based on the AzureFunctionsJobHost__extensionBundle__ensureLatest setting.
Changes:
- Added offline detection with caching to avoid excessive network checks
- Implemented cached bundle lookup functionality with version range matching
- Modified
func startto conditionally download bundles based on ensureLatest setting - Added comprehensive unit and E2E tests for offline scenarios
Reviewed changes
Copilot reviewed 12 out of 12 changed files in this pull request and generated 24 comments.
Show a summary per file
| File | Description |
|---|---|
| src/Cli/func/ExtensionBundle/ExtensionBundleHelper.cs | Adds offline detection, cached bundle lookup, and network failure handling |
| src/Cli/func/Actions/HostActions/StartHostAction.cs | Implements conditional bundle downloading based on ensureLatest setting |
| src/Cli/func/Actions/HostActions/Startup.cs | Sets ensureLatest environment variable based on offline status |
| src/Cli/func/ExtensionBundle/ExtensionBundleConfigurationBuilder.cs | Configures ensureLatest setting based on offline status |
| src/Cli/func/Helpers/RetryHelper.cs | Adds support for non-retryable exceptions |
| src/Cli/func/Azure.Functions.Cli.csproj | Exposes internals to test assembly |
| test/Cli/Func.UnitTests/HelperTests/ExtensionBundleHelperTests.cs | Adds comprehensive unit tests for bundle helper methods |
| test/Cli/Func.E2ETests/Commands/FuncStart/Core/BaseOfflineBundleTests.cs | Adds E2E test infrastructure for offline scenarios |
| test/Cli/Func.E2ETests/Commands/FuncStart/TestsWithFixtures/NodeV4Tests.cs | Adds E2E tests for Node v4 runtime |
| test/Cli/Func.E2ETests/Commands/FuncStart/TestsWithFixtures/NodeV3Tests.cs | Adds E2E tests for Node v3 runtime |
| test/Cli/Func.E2ETests/Commands/FuncStart/TestsWithFixtures/PowershellTests.cs | Adds E2E tests for PowerShell runtime |
| release_notes.md | Documents the new offline bundle fallback feature |
test/Cli/Func.E2ETests/Commands/FuncStart/Core/BaseOfflineBundleTests.cs
Outdated
Show resolved
Hide resolved
test/Cli/Func.E2ETests/Commands/FuncStart/TestsWithFixtures/NodeV4Tests.cs
Outdated
Show resolved
Hide resolved
test/Cli/Func.E2ETests/Commands/FuncStart/TestsWithFixtures/NodeV3Tests.cs
Outdated
Show resolved
Hide resolved
test/Cli/Func.UnitTests/HelperTests/ExtensionBundleHelperTests.cs
Outdated
Show resolved
Hide resolved
test/Cli/Func.UnitTests/HelperTests/ExtensionBundleHelperTests.cs
Outdated
Show resolved
Hide resolved
|
@copilot open a new PR addressing the comments in this thread. Can you also rebase to main for the conflicts? |
|
@aishwaryabh I've opened a new pull request, #4789, to work on those changes. Once the pull request is ready, I'll request review from you. |
9f44007 to
efe7dc0
Compare
liliankasem
left a comment
There was a problem hiding this comment.
offline mode should be a global settting and not connected to ext bundles
f4c2d83 to
1d79909
Compare
liliankasem
left a comment
There was a problem hiding this comment.
Sorry meant to request changes not approve :D
a5c411d to
f5de440
Compare
test/Cli/Func.UnitTests/HelperTests/ExtensionBundleHelperTests.cs
Outdated
Show resolved
Hide resolved
test/Cli/Func.E2ETests/Commands/FuncStart/Core/BaseOfflineBundleTests.cs
Show resolved
Hide resolved
|
Tested this with a happy and edge cases and its working really well! Only other thing I think we should fix is thr error messaging when offline i.e. Could do: // IsOfflineAsync
catch (Exception ex)
{
ColoredConsole.WriteLine(WarningColor("Unable to resolve network connection, running the CLI in offline mode."));
if (GlobalCoreToolsSettings.IsVerbose)
{
ColoredConsole.WriteLine(VerboseColor($"Details: {ex.Message}"));
}
return true;
}
}I think we should log a better message here i.e. Otherwise lgtm - ready to approve with this and above comments are addressed. Please also make sure to rebase and clean up commits. |
f5de440 to
e890718
Compare
seeing if latest changes work with func new using bundle path changing back adding reference to ensureLatest env variable adding release notes
fixing syntax rebasing and fixing tests
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com> addressing syntax issue addressing comments fixing not needed file changes updating scenarios to work turn offline method into async and methods calling it as well addressing comments
updating global offline flag to not override if user has explicit --offline flag updating offline logic to work
e890718 to
3e81a05
Compare
src/Cli/func/ExtensionBundle/ExtensionBundleConfigurationBuilder.cs
Outdated
Show resolved
Hide resolved
kshyju
left a comment
There was a problem hiding this comment.
A few more questions to clarify. Otherwise looking good.
Issue describing the changes in this PR
resolves ##4770
This PR addresses the scenario if we want to fallback to cached bundles specifically for
func start. For detecting if the system is online, we check by trying to ping an endpoint and cache if the system is offline or not for a specified interval for future calls. We also only download bundles infunc startif the customer has specifiedAzureFunctionsJobHost__extensionBundle__ensureLatestto be true OR if we detect that the system is offline.Example of running with no internet connection with no bundles cached:

Example of running with no internet connection but with bundles cached already:

Pull request checklist
release_notes.mdAdditional information
Additional PR information