Skip to content

Commit

Permalink
Fast egress server draining (#2858)
Browse files Browse the repository at this point in the history
Task/Issue URL: https://app.asana.com/0/1203137811378537/1207555842602667/f
Tech Design URL:
CC:

Description:

This PR adds support for fast egress server draining.

All of the real work happens on the BSK side, this PR just wires up events to pixels.
  • Loading branch information
samsymons authored Jun 13, 2024
1 parent e688145 commit eb40c83
Show file tree
Hide file tree
Showing 8 changed files with 69 additions and 11 deletions.
2 changes: 1 addition & 1 deletion DuckDuckGo.xcodeproj/project.pbxproj
Original file line number Diff line number Diff line change
Expand Up @@ -13078,7 +13078,7 @@
repositoryURL = "https://github.com/duckduckgo/BrowserServicesKit";
requirement = {
kind = exactVersion;
version = 153.0.0;
version = 154.0.0;
};
};
9FF521422BAA8FF300B9819B /* XCRemoteSwiftPackageReference "lottie-spm" */ = {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -32,8 +32,8 @@
"kind" : "remoteSourceControl",
"location" : "https://github.com/duckduckgo/BrowserServicesKit",
"state" : {
"revision" : "b78ae617c7fe66244741f489158a1f40e567e674",
"version" : "153.0.0"
"revision" : "2045f13479f3da34b827198b43ae7a47e01551cf",
"version" : "154.0.0"
}
},
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,10 @@ enum NetworkProtectionPixelEvent: PixelKitEventV2 {
case networkProtectionTunnelWakeSuccess
case networkProtectionTunnelWakeFailure(_ error: Error)

case networkProtectionServerMigrationAttempt
case networkProtectionServerMigrationSuccess
case networkProtectionServerMigrationFailure(_ error: Error)

case networkProtectionEnableAttemptConnecting
case networkProtectionEnableAttemptSuccess
case networkProtectionEnableAttemptFailure
Expand Down Expand Up @@ -74,6 +78,8 @@ enum NetworkProtectionPixelEvent: PixelKitEventV2 {
case networkProtectionClientFailedToParseRedeemResponse(_ error: Error)
case networkProtectionClientFailedToFetchLocations(_ error: Error?)
case networkProtectionClientFailedToParseLocationsResponse(_ error: Error?)
case networkProtectionClientFailedToFetchServerStatus(_ error: Error?)
case networkProtectionClientFailedToParseServerStatusResponse(_ error: Error?)
case networkProtectionClientInvalidAuthToken

case networkProtectionKeychainErrorFailedToCastKeychainValueToData(field: String)
Expand Down Expand Up @@ -275,6 +281,21 @@ enum NetworkProtectionPixelEvent: PixelKitEventV2 {
case .networkProtectionSystemExtensionActivationFailure:
return "netp_system_extension_activation_failure"

case .networkProtectionClientFailedToFetchServerStatus:
return "netp_server_migration_failed_to_fetch_status"

case .networkProtectionClientFailedToParseServerStatusResponse:
return "netp_server_migration_failed_to_parse_response"

case .networkProtectionServerMigrationAttempt:
return "netp_ev_server_migration_attempt"

case .networkProtectionServerMigrationFailure:
return "netp_ev_server_migration_attempt_failure"

case .networkProtectionServerMigrationSuccess:
return "netp_ev_server_migration_attempt_success"

case .networkProtectionUnhandledError:
return "netp_unhandled_error"
}
Expand Down Expand Up @@ -320,8 +341,14 @@ enum NetworkProtectionPixelEvent: PixelKitEventV2 {
return error.pixelParameters
case .networkProtectionWireguardErrorCannotStartWireguardBackend(code: let code):
return [PixelKit.Parameters.errorCode: String(code)]
case .networkProtectionClientFailedToFetchServerStatus(let error):
return error?.pixelParameters
case .networkProtectionClientFailedToParseServerStatusResponse(let error):
return error?.pixelParameters
case .networkProtectionWireguardErrorInvalidState(reason: let reason):
return [PixelKit.Parameters.reason: reason]
case .networkProtectionServerMigrationFailure:
return error?.pixelParameters
case .networkProtectionActiveUser,
.networkProtectionNewUser,
.networkProtectionControllerStartAttempt,
Expand Down Expand Up @@ -365,7 +392,9 @@ enum NetworkProtectionPixelEvent: PixelKitEventV2 {
.networkProtectionRekeyAttempt,
.networkProtectionRekeyCompleted,
.networkProtectionRekeyFailure,
.networkProtectionSystemExtensionActivationFailure:
.networkProtectionSystemExtensionActivationFailure,
.networkProtectionServerMigrationAttempt,
.networkProtectionServerMigrationSuccess:
return nil
}
}
Expand All @@ -376,7 +405,9 @@ enum NetworkProtectionPixelEvent: PixelKitEventV2 {
.networkProtectionClientFailedToFetchLocations(let error),
.networkProtectionClientFailedToParseLocationsResponse(let error),
.networkProtectionClientFailedToFetchServerList(let error),
.networkProtectionClientFailedToFetchRegisteredServers(let error):
.networkProtectionClientFailedToFetchRegisteredServers(let error),
.networkProtectionClientFailedToFetchServerStatus(let error),
.networkProtectionClientFailedToParseServerStatusResponse(let error):
return error
case .networkProtectionControllerStartFailure(let error),
.networkProtectionTunnelStartFailure(let error),
Expand All @@ -387,7 +418,8 @@ enum NetworkProtectionPixelEvent: PixelKitEventV2 {
.networkProtectionWireguardErrorCannotSetNetworkSettings(let error),
.networkProtectionRekeyFailure(let error),
.networkProtectionUnhandledError(_, _, let error),
.networkProtectionSystemExtensionActivationFailure(let error):
.networkProtectionSystemExtensionActivationFailure(let error),
.networkProtectionServerMigrationFailure(let error):
return error
case .networkProtectionActiveUser,
.networkProtectionNewUser,
Expand Down Expand Up @@ -431,7 +463,9 @@ enum NetworkProtectionPixelEvent: PixelKitEventV2 {
.networkProtectionWireguardErrorCannotStartWireguardBackend,
.networkProtectionNoAuthTokenFoundError,
.networkProtectionRekeyAttempt,
.networkProtectionRekeyCompleted:
.networkProtectionRekeyCompleted,
.networkProtectionServerMigrationAttempt,
.networkProtectionServerMigrationSuccess:
return nil
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -82,7 +82,9 @@ extension EventMapping where Event == NetworkProtectionError {
.wireGuardDnsResolution,
.wireGuardSetNetworkSettings,
.startWireGuardBackend,
.failedToRetrieveAuthToken:
.failedToRetrieveAuthToken,
.failedToFetchServerStatus,
.failedToParseServerStatusResponse:
domainEvent = .networkProtectionUnhandledError(function: #function, line: #line, error: event)
frequency = .standard
return
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -115,6 +115,10 @@ final class MacPacketTunnelProvider: PacketTunnelProvider {
domainEvent = .networkProtectionWireguardErrorCannotStartWireguardBackend(code: code)
case .noAuthTokenFound:
domainEvent = .networkProtectionNoAuthTokenFoundError
case .failedToFetchServerStatus(let error):
domainEvent = .networkProtectionClientFailedToFetchServerStatus(error)
case .failedToParseServerStatusResponse(let error):
domainEvent = .networkProtectionClientFailedToParseServerStatusResponse(error)
case .unhandledError(function: let function, line: let line, error: let error):
domainEvent = .networkProtectionUnhandledError(function: function, line: line, error: error)
case .failedToRetrieveAuthToken,
Expand Down Expand Up @@ -312,6 +316,24 @@ final class MacPacketTunnelProvider: PacketTunnelProvider {
includeAppVersionParameter: true
)
}
case .serverMigrationAttempt(let step):
switch step {
case .begin:
PixelKit.fire(
NetworkProtectionPixelEvent.networkProtectionServerMigrationAttempt,
frequency: .dailyAndCount,
includeAppVersionParameter: true)
case .failure(let error):
PixelKit.fire(
NetworkProtectionPixelEvent.networkProtectionServerMigrationFailure(error),
frequency: .dailyAndCount,
includeAppVersionParameter: true)
case .success:
PixelKit.fire(
NetworkProtectionPixelEvent.networkProtectionServerMigrationSuccess,
frequency: .dailyAndCount,
includeAppVersionParameter: true)
}
}
}

Expand Down
2 changes: 1 addition & 1 deletion LocalPackages/DataBrokerProtection/Package.swift
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ let package = Package(
targets: ["DataBrokerProtection"])
],
dependencies: [
.package(url: "https://github.com/duckduckgo/BrowserServicesKit", exact: "153.0.0"),
.package(url: "https://github.com/duckduckgo/BrowserServicesKit", exact: "154.0.0"),
.package(path: "../SwiftUIExtensions"),
.package(path: "../XPCHelper"),
],
Expand Down
2 changes: 1 addition & 1 deletion LocalPackages/NetworkProtectionMac/Package.swift
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ let package = Package(
.library(name: "VPNAppLauncher", targets: ["VPNAppLauncher"]),
],
dependencies: [
.package(url: "https://github.com/duckduckgo/BrowserServicesKit", exact: "153.0.0"),
.package(url: "https://github.com/duckduckgo/BrowserServicesKit", exact: "154.0.0"),
.package(url: "https://github.com/airbnb/lottie-spm", exact: "4.4.1"),
.package(path: "../AppLauncher"),
.package(path: "../UDSHelper"),
Expand Down
2 changes: 1 addition & 1 deletion LocalPackages/SubscriptionUI/Package.swift
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ let package = Package(
targets: ["SubscriptionUI"]),
],
dependencies: [
.package(url: "https://github.com/duckduckgo/BrowserServicesKit", exact: "153.0.0"),
.package(url: "https://github.com/duckduckgo/BrowserServicesKit", exact: "154.0.0"),
.package(path: "../SwiftUIExtensions")
],
targets: [
Expand Down

0 comments on commit eb40c83

Please sign in to comment.