-
Notifications
You must be signed in to change notification settings - Fork 1.4k
Change PackageCollectionSigning API from callback-based to async/await #6609
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
Conversation
Motivation: Package collection signing crashes with code 139 on Linux (Ubuntu Jammy). Adding a signed collection also fails. Modifications: - Change `PackageCollectionSigning` API from callback-based to async/await - Certificate validation is async/await instead of callback-based - Change `PackageCollectionSigning` to actor since accessing `self.observabilityScope` also causes crash
@swift-ci please smoke test |
Tested |
} else if !Self.isSignatureCheckSupported { | ||
callback(.failure(StringError("Unsupported platform"))) | ||
} else { | ||
// Check the signature | ||
let signatureResults = ThreadSafeArrayStore<Result<Void, Error>>() | ||
certPolicyKeys.forEach { certPolicyKey in | ||
self.signatureValidator.validate(signedCollection: signedCollection, certPolicyKey: certPolicyKey) { result in | ||
let count = signatureResults.append(result) | ||
Task { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
👀 the key change in this file. The rest is mostly formatting.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
is the change to run this in a task context, or something more?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
To run async code in a Task yes. It is inside a loop and each task updates the signatureResults
array.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
could we use a task group maybe to help collect the results and make waiting for all the tasks to complete easier? just an idea, not sure if helpful
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
+1 for a task group or async let
if either can be used here, otherwise we end up not utilizing structured concurrency benefits
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
amended 073d7df
@swift-ci please smoke test |
@swift-ci please test Windows platform |
guard SignatureError.invalidSignature == error as? SignatureError else { | ||
return XCTFail("Expected SignatureError.invalidSignature") | ||
} | ||
private func readTestCertData(path: (AbsolutePath) -> AbsolutePath, callback: (Result<Data, Error>) -> Void) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can this be made async
? The tests calling it seem to be async
already.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
amended 813bd98
@swift-ci please smoke test |
@swift-ci please test Windows platform |
Motivation:
Package collection signing crashes with code 139 on Linux (Ubuntu Jammy). Adding a signed collection also fails.
Modifications:
PackageCollectionSigning
API from callback-based to async/awaitPackageCollectionSigning
to actor since accessingself.observabilityScope
also causes crash