Пример #1
0
        public async Task EnqueueAsync(string validatorName, PackageValidationMessage message)
        {
            message.Package = message.Package.TruncateForAzureQueue();

            _logger.LogInformation($"Start enqueue validation {{{TraceConstant.ValidatorName}}} " +
                                   $"{{{TraceConstant.ValidationId}}} " +
                                   $"- package {{{TraceConstant.PackageId}}} " +
                                   $"v. {{{TraceConstant.PackageVersion}}}...",
                                   validatorName,
                                   message.ValidationId,
                                   message.PackageId,
                                   message.PackageVersion);

            var queue = await GetQueueAsync(validatorName);

            await queue.AddMessageAsync(new CloudQueueMessage(JsonConvert.SerializeObject(message)));

            _logger.LogInformation($"Finished enqueue validation {{{TraceConstant.ValidatorName}}} " +
                                   $"{{{TraceConstant.ValidationId}}} " +
                                   $"- package {{{TraceConstant.PackageId}}} " +
                                   $"v. {{{TraceConstant.PackageVersion}}}.",
                                   validatorName,
                                   message.ValidationId,
                                   message.PackageId,
                                   message.PackageVersion);
        }
Пример #2
0
        public async Task DeleteAsync(string validatorName, PackageValidationMessage message)
        {
            _logger.LogInformation($"Start complete validation {{{TraceConstant.ValidatorName}}}...", validatorName);

            var queue = await GetQueueAsync(validatorName);

            await queue.DeleteMessageAsync(message.MessageId, message.PopReceipt);

            _logger.LogInformation($"Finished complete validation {{{TraceConstant.ValidatorName}}}.", validatorName);
        }
Пример #3
0
        public async Task StartValidationProcessAsync(NuGetPackage package, string[] validators, Guid validationId)
        {
            var packageId      = package.Id;
            var packageVersion = package.GetVersion();
            var created        = DateTimeOffset.UtcNow;

            _logger.LogInformation(
                $"Starting validation process for validation {{{TraceConstant.ValidationId}}} " +
                $"- package {{{TraceConstant.PackageId}}} " +
                $"v. {{{TraceConstant.PackageVersion}}}...",
                validationId,
                packageId,
                packageVersion);

            // Write a tracking entity
            await _packageValidationTable.StoreAsync(new PackageValidationEntity
            {
                ValidationId        = validationId,
                PackageId           = packageId,
                PackageVersion      = packageVersion,
                RequestedValidators = string.Join(";", validators.OrderBy(v => v)),
                CompletedValidators = string.Empty,
                Created             = created
            });

            // Enqueue validations
            foreach (var validator in validators)
            {
                var message = new PackageValidationMessage
                {
                    ValidationId   = validationId,
                    PackageId      = packageId,
                    PackageVersion = packageVersion,
                    Package        = package
                };

                await _packageValidationQueue.EnqueueAsync(validator, message);
            }

            // Write audit entry so we can get all the nitty-gritty details on our validation process
            try
            {
                await _packageValidationAuditor.StartAuditAsync(validationId, validators, created, packageId, packageVersion, package);
            }
            catch (Exception ex)
            {
                var logMessage = $"Error while starting validation process for validation {validationId} - package {packageId} {packageVersion}: {ex.Message} {ex.StackTrace}";

                _logger.LogError(TraceEvent.StartValidationAuditFailed, ex,
                                 $"Error while starting validation process for validation {{{TraceConstant.ValidationId}}} " +
                                 $"- package {{{TraceConstant.PackageId}}} " +
                                 $"v. {{{TraceConstant.PackageVersion}}}",
                                 validationId,
                                 packageId,
                                 packageVersion);

                await _notificationService.SendNotificationAsync(
                    "exception",
                    "Error while starting validation process for validation",
                    logMessage);

                throw;
            }

            _logger.LogInformation($"Started validation process for validation {{{TraceConstant.ValidationId}}} " +
                                   $"- package {{{TraceConstant.PackageId}}} " +
                                   $"v. {{{TraceConstant.PackageVersion}}}",
                                   validationId,
                                   packageId,
                                   packageVersion);
        }