From 9a5b3e864251e1bafdf5a1634464dec81e222f1f Mon Sep 17 00:00:00 2001 From: minwoox Date: Fri, 30 Aug 2024 18:59:50 +0900 Subject: [PATCH] Address the comment from @ikhoon --- .../mirror/RemovingHostnamePatternsService.java | 14 ++++++++------ 1 file changed, 8 insertions(+), 6 deletions(-) diff --git a/server/src/main/java/com/linecorp/centraldogma/server/internal/mirror/RemovingHostnamePatternsService.java b/server/src/main/java/com/linecorp/centraldogma/server/internal/mirror/RemovingHostnamePatternsService.java index ed337f2d4c..0354782016 100644 --- a/server/src/main/java/com/linecorp/centraldogma/server/internal/mirror/RemovingHostnamePatternsService.java +++ b/server/src/main/java/com/linecorp/centraldogma/server/internal/mirror/RemovingHostnamePatternsService.java @@ -68,7 +68,7 @@ void start() throws Exception { } final Stopwatch stopwatch = Stopwatch.createStarted(); - int numMigratedProjects = 0; + int numProjects = 0; try { for (Project project : projectManager.list().values()) { if (InternalProjectInitializer.INTERNAL_PROJECT_DOGMA.equals(project.name())) { @@ -92,12 +92,14 @@ void start() throws Exception { ((ObjectNode) content).without("hostnamePatterns"))); } - if (!changes.isEmpty()) { - numMigratedProjects++; - logger.info("hostnamePatterns in credentials are removed in the project: {}", - project.name()); + if (changes.isEmpty()) { + continue; } + numProjects++; + logger.info("hostnamePatterns in credentials are removed in the project: {}", + project.name()); + commandExecutor.execute(Command.forcePush(Command.push( Author.SYSTEM, project.name(), Project.REPO_META, Revision.HEAD, "Remove hostnamePatterns in credentials.", "", Markup.PLAINTEXT, @@ -109,7 +111,7 @@ void start() throws Exception { } } logger.info("hostnamePatterns are removed in {} projects. (took: {} ms.)", - numMigratedProjects, stopwatch.elapsed().toMillis()); + numProjects, stopwatch.elapsed().toMillis()); } finally { // Exit read-only mode. commandExecutor.execute(Command.updateServerStatus(ServerStatus.WRITABLE))