public async Task ProcessValidationOutcomeAsync(PackageValidationSet validationSet, Package package)
        {
            if (AnyValidationFailed(validationSet))
            {
                _logger.LogWarning("Some validations failed for package {PackageId} {PackageVersion}, validation set {ValidationSetId}: {FailedValidations}",
                                   package.PackageRegistration.Id,
                                   package.NormalizedVersion,
                                   validationSet.ValidationTrackingId,
                                   GetFailedValidations(validationSet));

                if (package.PackageStatusKey != PackageStatus.Available)
                {
                    await _galleryPackageService.UpdatePackageStatusAsync(package, PackageStatus.FailedValidation);

                    _messageService.SendPackageValidationFailedMessage(package);
                }
                else
                {
                    // The case when validation fails while PackageStatus is Available is the case of
                    // manual revalidation. In this case we don't want to take package down automatically
                    // and let the person who requested revalidation to decide how to proceed. User will be
                    // alerted by failed validation monitoring.
                    _logger.LogInformation("Package {PackageId} {PackageVersion} was available when validation set {ValidationSetId} failed. Will not mark it as failed",
                                           package.PackageRegistration.Id,
                                           package.NormalizedVersion,
                                           validationSet.ValidationTrackingId);
                }
            }
            else if (AllValidationsSucceeded(validationSet))
            {
                _logger.LogInformation("All validations are complete for the package {PackageId} {PackageVersion}, validation set {ValidationSetId}",
                                       package.PackageRegistration.Id,
                                       package.NormalizedVersion,
                                       validationSet.ValidationTrackingId);
                if (package.PackageStatusKey != PackageStatus.Available)
                {
                    await MoveFileToPublicStorageAndMarkPackageAsAvailable(validationSet, package);
                }
                else
                {
                    _logger.LogInformation("Package {PackageId} {PackageVersion} {ValidationSetId} was already available, not going to copy data and update DB",
                                           package.PackageRegistration.Id,
                                           package.NormalizedVersion,
                                           validationSet.ValidationTrackingId);
                }
                _logger.LogInformation("Done processing {PackageId} {PackageVersion} {ValidationSetId}",
                                       package.PackageRegistration.Id,
                                       package.NormalizedVersion,
                                       validationSet.ValidationTrackingId);
            }
            else
            {
                // No failed validations and some validations are still in progress.
                // Scheduling another check
                var messageData = new PackageValidationMessageData(package.PackageRegistration.Id, package.Version, validationSet.ValidationTrackingId);
                await _validationEnqueuer.StartValidationAsync(messageData, DateTimeOffset.UtcNow + _validationConfiguration.ValidationMessageRecheckPeriod);
            }
        }
Пример #2
0
        private async Task MakePackageFailedValidationAsync(Package package, PackageValidationSet validationSet)
        {
            var fromStatus = package.PackageStatusKey;

            await _galleryPackageService.UpdatePackageStatusAsync(package, PackageStatus.FailedValidation, commitChanges : true);

            if (fromStatus != PackageStatus.FailedValidation)
            {
                _telemetryService.TrackPackageStatusChange(fromStatus, PackageStatus.FailedValidation);
            }
        }
Пример #3
0
 public async Task UpdateStatusAsync(Package entity, PackageStatus newStatus, bool commitChanges = true)
 {
     await _galleryEntityService.UpdatePackageStatusAsync(entity, newStatus, commitChanges);
 }