Skip to content

Conversation

@polyglot-k
Copy link
Contributor

This pull request introduces several significant improvements and refactorings across the CI/CD pipeline, cron job architecture, Redis cache operations, and attachment management for inquiries and notices. The main themes are: enhanced deployment automation, standardization and extensibility of cron executors, improved Redis script management, and more robust and reusable attachment update logic.

CI/CD Pipeline Enhancements:

  • The GitHub Actions workflow .github/workflows/self-depoly.yaml now targets the develop branch instead of test and includes steps for source checkout, JDK setup, Gradle caching, external JAR fetching, Docker image build/push, and deployment, streamlining the deployment process and improving build reproducibility.

Cron Job Architecture Refactoring:

  • Refactored cron job classes to follow a standardized Executor naming convention and interface, moving from generic interfaces like DomainArchiver and LogCleanup to more specific DomainArchiveExecutor and LogCleanupExecutor. Also, replaced Spring stereotypes with a custom @CronTarget annotation for better control and extensibility. [1] [2]
  • Introduced a new cron executor, BlockedIpBatchAchiever, which archives blocked IP history entries from a Caffeine cache to the database in batches, focusing on entries with the highest penalty level.

Redis Cache Operator Improvements:

  • Updated the AtomicExamQuotaDecrementOperator and AtomicExamQuotaIncrementOperator to retrieve Lua scripts from a shared examLuaScripts map by name, rather than direct injection, improving flexibility and maintainability. [1] [2]
  • Adjusted ExamQuotaCacheManager to lazily inject the examQuotaCacheAtomicOperatorMap to resolve potential circular dependencies and to use the correct qualifier.

Attachment Management Refactoring:

  • Standardized the update logic for attachments in InquiryAnswerAttachmentService, InquiryAttachmentService, and NoticeAttachmentService by introducing an updateAttachment method that deletes existing attachments before creating new ones, ensuring consistency and reducing code duplication. [1] [2] [3]
  • Changed the method for generating file URLs in NoticeAttachmentService from pre-signed URLs to public URLs for improved accessibility.

Inquiry/Notice Service Adjustments:

  • Modified inquiry answer and notice service methods to accept the acting UserJpaEntity as a parameter, ensuring proper auditing and permission checks during create and update operations. Also, ensured that deleting an inquiry answer now also deletes associated attachments. [1] [2] [3] [4] [5]

These changes collectively improve the maintainability, extensibility, and reliability of the system, especially around automated deployments, scheduled maintenance tasks, and data consistency for attachments.

Most Important Changes:

CI/CD and Deployment:

  • Enhanced the GitHub Actions workflow to include source checkout, JDK setup, Gradle caching, external JAR fetching, Docker image build/push, and deployment, and changed the trigger branch to develop. (.github/workflows/self-depoly.yaml)

Cron Job and Batch Processing:

  • Refactored cron job classes to use Executor naming and interfaces, introduced @CronTarget, and added a new batch archiver for blocked IPs from cache to DB. (src/main/java/life/mosu/mosuserver/application/application/cron/ApplicationFailureLogCleanupExecutor.java, src/main/java/life/mosu/mosuserver/application/application/cron/ApplicationFailureLogDomainArchiveExecutor.java, src/main/java/life/mosu/mosuserver/application/caffeine/BlockedIpBatchAchiever.java) [1] [2] [3]

Redis Script and Cache Management:

  • Updated exam quota cache operators to retrieve Lua scripts from a map by name, and made cache operator map injection lazy to resolve circular dependencies. (src/main/java/life/mosu/mosuserver/application/exam/cache/AtomicExamQuotaDecrementOperator.java, src/main/java/life/mosu/mosuserver/application/exam/cache/AtomicExamQuotaIncrementOperator.java, src/main/java/life/mosu/mosuserver/application/exam/cache/ExamQuotaCacheManager.java) [1] [2] [3]

Attachment Handling Standardization:

  • Added a standardized updateAttachment method for inquiries and notices, ensuring attachments are deleted and recreated atomically during updates. (src/main/java/life/mosu/mosuserver/application/inquiry/InquiryAnswerAttachmentService.java, src/main/java/life/mosu/mosuserver/application/inquiry/InquiryAttachmentService.java, src/main/java/life/mosu/mosuserver/application/notice/NoticeAttachmentService.java) [1] [2] [3]
  • Changed notice attachment URLs to use public URLs instead of pre-signed URLs.

Inquiry/Notice Service Logic:

  • Modified inquiry answer and notice service methods to accept the acting user and ensured attachments are properly managed on create/update/delete. (src/main/java/life/mosu/mosuserver/application/inquiry/InquiryAnswerService.java, src/main/java/life/mosu/mosuserver/application/inquiry/InquiryService.java, src/main/java/life/mosu/mosuserver/application/notice/NoticeService.java) [1] [2] [3] [4] [5]

jbh010204 and others added 30 commits August 7, 2025 19:36
MOSU-240 refactor: 반복적인 분당 요청에 대해 제한 시간 증가 및 하루 차단된 사용자들 DB로 영속화
…lete and create operations into update method
…type mismatch and resource not found responses
MOSU-246 refactor: 공지, 질문 로직 수정
polyglot-k and others added 18 commits August 8, 2025 13:13
 Quartz 를 통한 스케줄링 공통화 Resolver 구성 ( Configuration 중복 작업 완화)
캐시 원자 단위 의존성 주입 Resolver 추가 및 동적 Bean 등록
@coderabbitai
Copy link

coderabbitai bot commented Aug 9, 2025

Important

Review skipped

Auto reviews are disabled on base/target branches other than the default branch.

Please check the settings in the CodeRabbit UI or the .coderabbit.yaml file in this repository. To trigger a single review, invoke the @coderabbitai review command.

You can disable this status message by setting the reviews.review_status to false in the CodeRabbit configuration file.

✨ Finishing Touches
🧪 Generate unit tests
  • Create PR with unit tests
  • Post copyable unit tests in a comment
  • Commit unit tests in branch develop

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share
🪧 Tips

Chat

There are 3 ways to chat with CodeRabbit:

  • Review comments: Directly reply to a review comment made by CodeRabbit. Example:
    • I pushed a fix in commit <commit_id>, please review it.
    • Explain this complex logic.
    • Open a follow-up GitHub issue for this discussion.
  • Files and specific lines of code (under the "Files changed" tab): Tag @coderabbitai in a new review comment at the desired location with your query. Examples:
    • @coderabbitai explain this code block.
  • PR comments: Tag @coderabbitai in a new PR comment to ask questions about the PR branch. For the best results, please provide a very specific query, as very limited context is provided in this mode. Examples:
    • @coderabbitai gather interesting stats about this repository and render them as a table. Additionally, render a pie chart showing the language distribution in the codebase.
    • @coderabbitai read src/utils.ts and explain its main purpose.
    • @coderabbitai read the files in the src/scheduler package and generate a class diagram using mermaid and a README in the markdown format.

Support

Need help? Create a ticket on our support page for assistance with any issues or questions.

CodeRabbit Commands (Invoked using PR comments)

  • @coderabbitai pause to pause the reviews on a PR.
  • @coderabbitai resume to resume the paused reviews.
  • @coderabbitai review to trigger an incremental review. This is useful when automatic reviews are disabled for the repository.
  • @coderabbitai full review to do a full review from scratch and review all the files again.
  • @coderabbitai summary to regenerate the summary of the PR.
  • @coderabbitai generate docstrings to generate docstrings for this PR.
  • @coderabbitai generate sequence diagram to generate a sequence diagram of the changes in this PR.
  • @coderabbitai generate unit tests to generate unit tests for this PR.
  • @coderabbitai resolve resolve all the CodeRabbit review comments.
  • @coderabbitai configuration to show the current CodeRabbit configuration for the repository.
  • @coderabbitai help to get help.

Other keywords and placeholders

  • Add @coderabbitai ignore anywhere in the PR description to prevent this PR from being reviewed.
  • Add @coderabbitai summary to generate the high-level summary at a specific location in the PR description.
  • Add @coderabbitai anywhere in the PR title to generate the title automatically.

CodeRabbit Configuration File (.coderabbit.yaml)

  • You can programmatically configure CodeRabbit by adding a .coderabbit.yaml file to the root of your repository.
  • Please see the configuration documentation for more information.
  • If your editor has YAML language server enabled, you can add the path at the top of this file to enable auto-completion and validation: # yaml-language-server: $schema=https://coderabbit.ai/integrations/schema.v2.json

Documentation and Community

  • Visit our Documentation for detailed information on how to use CodeRabbit.
  • Join our Discord Community to get help, request features, and share feedback.
  • Follow us on X/Twitter for updates and announcements.

Copy link

@gemini-code-assist gemini-code-assist bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Summary of Changes

Hello @polyglot-k, I'm Gemini Code Assist1! I'm currently reviewing this pull request and will post my feedback shortly. In the meantime, here's a summary to help you and other reviewers quickly get up to speed!

I've made significant improvements and refactorings across several core areas of our system. This pull request focuses on enhancing our CI/CD pipeline for smoother deployments, standardizing and extending our cron job architecture for better maintainability, improving how we manage Redis scripts for exam quota operations, and streamlining attachment management for inquiries and notices. These changes collectively boost the system's maintainability, extensibility, and reliability, particularly for automated deployments, scheduled tasks, and data consistency.

Highlights

  • CI/CD and Deployment: Enhanced the GitHub Actions workflow to include source checkout, JDK setup, Gradle caching, external JAR fetching, Docker image build/push, and deployment, and changed the trigger branch to develop.
  • Cron Job and Batch Processing: Refactored cron job classes to use Executor naming and interfaces, introduced a custom @CronTarget annotation, and added a new batch archiver for blocked IPs from cache to the database.
  • Redis Script and Cache Management: Updated exam quota cache operators to retrieve Lua scripts from a shared map by name, and implemented lazy injection for the cache operator map to resolve potential circular dependencies.
  • Attachment Handling Standardization: Introduced a standardized updateAttachment method across inquiry and notice services, ensuring attachments are deleted and recreated atomically during updates. Also, changed notice attachment URLs to use public URLs instead of pre-signed URLs.
  • Inquiry/Notice Service Logic: Modified inquiry answer and notice service methods to accept the acting UserJpaEntity for proper auditing and permission checks, and ensured associated attachments are deleted when an inquiry answer is removed.
Using Gemini Code Assist

The full guide for Gemini Code Assist can be found on our documentation page, here are some quick tips.

Invoking Gemini

You can request assistance from Gemini at any point in your pull request via creating an issue comment (i.e. comment on the pull request page) using either /gemini <command> or @gemini-code-assist <command>. Below is a summary of the supported commands.

Feature Command Description
Code Review /gemini review Performs a code review for the current pull request in its current state.
Pull Request Summary /gemini summary Provides a summary of the current pull request in its current state.
Comment @gemini-code-assist Responds in comments when explicitly tagged, both in issue comments and review comments.
Help /gemini help Displays a list of available commands.

Customization

To customize Gemini Code Assist for GitHub experience, repository maintainers can create a configuration file and/or provide a custom code review style guide (such as PEP-8 for Python) by creating and adding files to a .gemini/ folder in the base of the repository. Detailed instructions can be found here.

Limitations & Feedback

Gemini Code Assist may make mistakes. Please leave feedback on any instances where its feedback is incorrect or counter productive. You can react with 👍 and 👎 on @gemini-code-assist comments or fill out our survey to provide feedback.

You can also get AI-powered code generation, chat, as well as code reviews directly in the IDE at no cost with the Gemini Code Assist IDE Extension.

Footnotes

  1. Review the Privacy Notices, Generative AI Prohibited Use Policy, Terms of Service, and learn how to configure Gemini Code Assist in GitHub here. Gemini can make mistakes, so double check it and use code with caution.

@polyglot-k polyglot-k merged commit 0c2d775 into prod Aug 9, 2025
4 checks passed
Copy link

@gemini-code-assist gemini-code-assist bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Code Review

This pull request introduces a major refactoring of cron jobs, Redis usage, and attachment handling, along with a new IP rate-limiting feature. The changes are generally good, improving modularity and using modern Spring features. I've found a few issues: a potential regression in inquiry deletion logic, a validation message mismatch, a typo in a log message, a potential performance issue in a new batch job, and a significant behavioral change in a cron job.

inquiryAnswerJpaRepository.findByInquiryId(postId).ifPresent(answer -> {
inquiryAnswerService.deleteInquiryAnswer(postId);
});
inquiryAnswerService.deleteInquiryAnswer(postId);

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

high

When deleting an inquiry, it's possible that it doesn't have an answer. The previous implementation handled this case gracefully by using ifPresent. The new implementation directly calls inquiryAnswerService.deleteInquiryAnswer(postId), which will throw an INQUIRY_ANSWER_NOT_FOUND exception if no answer exists. This could prevent inquiries without answers from being deleted.

Suggested change
inquiryAnswerService.deleteInquiryAnswer(postId);
inquiryAnswerJpaRepository.findByInquiryId(postId).ifPresent(answer -> inquiryAnswerService.deleteInquiryAnswer(postId));


public record InquiryCreateRequest(

@Size(max = 100, message = "제목은 최대 300자까지 입력 가능합니다.")

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

high

There is a mismatch between the validation annotation and the description message. The @Size annotation specifies a maximum length of 100 characters, but the message says '제목은 최대 300자까지 입력 가능합니다.' (Title can be up to 300 characters). Please make them consistent.

Suggested change
@Size(max = 100, message = "제목은 최대 300자까지 입력 가능합니다.")
@Size(max = 300, message = "제목은 최대 300자까지 입력 가능합니다.")

Comment on lines +29 to +53
public void archive() {
Map<String, BlockedIpHistory> blockedHistoryMap = blockedHistoryCache.asMap();

List<BlockedIpHistoryLogJpaEntity> logs = blockedHistoryMap.values().stream()
.filter(entry -> entry.getPenaltyLevel() == TimePenalty.LEVEL_5)
.map(this::createBlockedHistoryLog)
.toList();

if (logs.isEmpty()) {
log.debug("[BlockedIpArchiver] 저장할 로그가 없음.");
return;
}

for (int i = 0; i < logs.size(); i += BATCH_SIZE) {
int end = Math.min(i + BATCH_SIZE, logs.size());
List<BlockedIpHistoryLogJpaEntity> batch = logs.subList(i, end);

try {
blockedIpHistoryLogJpaRepository.saveAllUsingBatch(batch);
log.debug("[BlockedIpArchiver] 저장 완료: {}개", batch.size());
} catch (Exception e) {
log.error("[BlockedIpArchiver] 저장 실패: {}~{} 인덱스", i, end, e);
}
}
}

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

medium

The current implementation of the archive method collects all matching log entries into a list before processing them in batches. If the blockedHistoryCache contains a very large number of entries, this could lead to high memory consumption.

A more memory-efficient approach would be to iterate through the cache entries and build batches on the fly, without creating a large intermediate list.

    @Override
    public void archive() {
        List<BlockedIpHistoryLogJpaEntity> batch = new ArrayList<>(BATCH_SIZE);
        int savedCount = 0;

        for (BlockedIpHistory history : blockedHistoryCache.asMap().values()) {
            if (history.getPenaltyLevel() == TimePenalty.LEVEL_5) {
                batch.add(createBlockedHistoryLog(history));
                if (batch.size() >= BATCH_SIZE) {
                    try {
                        blockedIpHistoryLogJpaRepository.saveAllUsingBatch(batch);
                        log.debug("[BlockedIpArchiver] 저장 완료: {}개", batch.size());
                        savedCount += batch.size();
                    } catch (Exception e) {
                        log.error("[BlockedIpArchiver] 저장 실패. Batch size: {}", batch.size(), e);
                    }
                    batch.clear();
                }
            }
        }

        if (!batch.isEmpty()) {
            try {
                blockedIpHistoryLogJpaRepository.saveAllUsingBatch(batch);
                log.debug("[BlockedIpArchiver] 저장 완료: {}개", batch.size());
                savedCount += batch.size();
            } catch (Exception e) {
                log.error("[BlockedIpArchiver] 저장 실패. Batch size: {}", batch.size(), e);
            }
        }

        if (savedCount == 0) {
            log.debug("[BlockedIpArchiver] 저장할 로그가 없음.");
        }
    }

private static class RequestCounter {
blockedIpCache.invalidate(ip);
blockedIpCache.put(ip, new BlockedIp(nextPenaltyLevel));
log.warn("IP 차단: {}, 차단 레벨: {})", ip, nextPenaltyLevel);

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

medium

There is a typo in the log message format string. {}) should be {}.

Suggested change
log.warn("IP 차단: {}, 차단 레벨: {})", ip, nextPenaltyLevel);
log.warn("IP 차단: {}, 차단 레벨: {}", ip, nextPenaltyLevel);

Comment on lines +24 to +39
public void execute(JobExecutionContext ctx) {
if (domainArchiveExecutors == null || domainArchiveExecutors.isEmpty()) {
log.info("No domain archivers configured, skipping execution");
return;
}

for (DomainArchiveExecutor archiver : domainArchiveExecutors) {
try {
log.info("Starting archive for {}", archiver.getName());
archiver.archive();
log.info("Archiving completed for {}", archiver.getName());
} catch (Exception e) {
log.error("Archiving failed for {}", archiver.getName(), e);
}
}
}

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

medium

The execution logic for archivers has changed from parallel with delays to sequential. The previous implementation used a ScheduledExecutorService to run archivers with a delay between them, allowing them to run in parallel. The new implementation iterates and executes them sequentially in a single thread. This is a significant behavioral change that could lead to performance issues if any archiver takes a long time to execute, as it will block all subsequent archivers. Please verify if this change was intentional.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

5 participants