Example #1
0
 public DeleteCrashReportDumpJob(ILogger <DeleteCrashReportDumpJob> logger, NotificationsEnabledDb database,
                                 ILocalTempFileLocks localTempFileLocks)
 {
     this.logger             = logger;
     this.database           = database;
     this.localTempFileLocks = localTempFileLocks;
 }
 public RefreshLFSProjectFilesJob(ILogger <RefreshLFSProjectFilesJob> logger, NotificationsEnabledDb database,
                                  ILocalTempFileLocks localTempFileLocks)
 {
     this.logger             = logger;
     this.database           = database;
     this.localTempFileLocks = localTempFileLocks;
 }
Example #3
0
        public StackwalkToolController(ILogger <StackwalkToolController> logger, ApplicationDbContext database,
                                       IConfiguration configuration, IBackgroundJobClient jobClient, ILocalTempFileLocks localTempFileLocks)
        {
            this.logger             = logger;
            this.database           = database;
            this.jobClient          = jobClient;
            this.localTempFileLocks = localTempFileLocks;

            enabled = !string.IsNullOrEmpty(Convert.ToString(configuration["Crashes:StackwalkService"]));
        }
Example #4
0
 public CheckAndStartCIBuild(ILogger <CheckAndStartCIBuild> logger, NotificationsEnabledDb database,
                             IBackgroundJobClient jobClient, ILocalTempFileLocks localTempFileLocks,
                             IGithubCommitStatusReporter statusReporter)
 {
     this.logger             = logger;
     this.database           = database;
     this.jobClient          = jobClient;
     this.localTempFileLocks = localTempFileLocks;
     this.statusReporter     = statusReporter;
 }
        public static async Task BuildFileTree(ILocalTempFileLocks tempFiles, ApplicationDbContext database,
                                               LfsProject project, ILogger logger, CancellationToken cancellationToken)
        {
            var semaphore = tempFiles.GetTempFilePath($"gitFileTrees/{project.Slug}", out string tempPath);

            await semaphore.WaitAsync(TimeSpan.FromMinutes(10), cancellationToken);

            try
            {
                await GitRunHelpers.EnsureRepoIsCloned(project.CloneUrl, tempPath, true, cancellationToken);

                try
                {
                    await GitRunHelpers.Checkout(tempPath, project.BranchToBuildFileTreeFor, true, cancellationToken);
                }
                catch (Exception)
                {
                    // In case the branch refers to a new branch
                    await GitRunHelpers.Fetch(tempPath, true, cancellationToken);

                    await GitRunHelpers.Checkout(tempPath, project.BranchToBuildFileTreeFor, true, cancellationToken);
                }

                await GitRunHelpers.Pull(tempPath, true, cancellationToken, true);

                // Skip if commit has not changed
                var newCommit = await GitRunHelpers.GetCurrentCommit(tempPath, cancellationToken);

                if (newCommit == project.FileTreeCommit)
                {
                    logger.LogDebug("Commit is still the same ({FileTreeCommit}), skipping tree update " +
                                    "for {Id}",
                                    project.FileTreeCommit, project.Id);
                    return;
                }

                logger.LogInformation("New commit {NewCommit} to build file tree from (previous: {FileTreeCommit}) " +
                                      "for project {Id}", newCommit, project.FileTreeCommit, project.Id);

                project.FileTreeCommit = newCommit;

                // Make sure we don't have any extra files locally
                await GitRunHelpers.Clean(tempPath, cancellationToken);

                // And then make sure the DB file tree entries are fine
                await UpdateFileTreeForProject(database, tempPath, project, cancellationToken);
            }
            finally
            {
                semaphore.Release();
            }

            project.FileTreeUpdated = DateTime.UtcNow;
            await database.SaveChangesAsync(cancellationToken);
        }
Example #6
0
 public RunStackwalkTaskJob(ILogger <RunStackwalkTaskJob> logger, NotificationsEnabledDb database,
                            IConfiguration configuration, ILocalTempFileLocks localTempFileLocks, IStackwalk stackwalk,
                            IStackwalkSymbolPreparer symbolPreparer)
 {
     this.logger             = logger;
     this.database           = database;
     this.localTempFileLocks = localTempFileLocks;
     this.stackwalk          = stackwalk;
     this.symbolPreparer     = symbolPreparer;
     symbolFolder            = configuration["Crashes:StackwalkSymbolFolder"];
 }
 public StartStackwalkOnReportJob(ILogger <StartStackwalkOnReportJob> logger, NotificationsEnabledDb database,
                                  IConfiguration configuration, ILocalTempFileLocks localTempFileLocks, IStackwalk stackwalk,
                                  IBackgroundJobClient jobClient, IStackwalkSymbolPreparer symbolPreparer)
 {
     this.logger             = logger;
     this.database           = database;
     this.localTempFileLocks = localTempFileLocks;
     this.stackwalk          = stackwalk;
     this.jobClient          = jobClient;
     this.symbolPreparer     = symbolPreparer;
     symbolFolder            = configuration["Crashes:StackwalkSymbolFolder"];
 }
        public CrashReportController(ILogger <CrashReportController> logger,
                                     NotificationsEnabledDb database, IConfiguration configuration, ILocalTempFileLocks localTempFileLocks,
                                     IBackgroundJobClient jobClient, DiscordNotifications discordNotifications)
        {
            this.logger               = logger;
            this.database             = database;
            this.localTempFileLocks   = localTempFileLocks;
            this.jobClient            = jobClient;
            this.discordNotifications = discordNotifications;

            uploadEnabled = Convert.ToBoolean(configuration["Crashes:Enabled"]);
            baseUrl       = configuration.GetBaseUrl();
        }
Example #9
0
        public static async Task DeleteReportTempFile(CrashReport report, ILocalTempFileLocks fileLocks, ILogger logger,
                                                      CancellationToken cancellationToken)
        {
            var semaphore =
                fileLocks.GetTempFilePath(CrashReport.CrashReportTempStorageFolderName, out string baseFolder);

            if (string.IsNullOrEmpty(report.DumpLocalFileName))
            {
                logger.LogInformation("Crash report doesn't have a dump file set, skip deleting it");
                return;
            }

            var filePath = Path.Combine(baseFolder, report.DumpLocalFileName);

            await semaphore.WaitAsync(cancellationToken);

            try
            {
                if (!Directory.Exists(baseFolder))
                {
                    logger.LogInformation("Crash report dump folder doesn't exist, skip deleting a dump file");
                    return;
                }

                if (!File.Exists(filePath))
                {
                    logger.LogInformation(
                        "Crash report dump file with name {DumpLocalFileName} doesn't exist, skip trying to delete it",
                        report.DumpLocalFileName);
                    return;
                }

                File.Delete(filePath);
            }
            finally
            {
                semaphore.Release();
            }

            logger.LogInformation("Deleted crash dump file {DumpLocalFileName}", report.DumpLocalFileName);
        }