Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix:[NEXT-291] renamed feature flag correctly #2353

Merged
merged 1 commit into from
Dec 18, 2024

Conversation

ershad-paladin
Copy link
Contributor

@ershad-paladin ershad-paladin commented Dec 18, 2024

Description

  • renamed feature flag correctly

Please include a summary of the changes and the related issues. Please also include relevant motivation and context. List
any dependencies that are required for this change.

Problem

Solution

Fixes # (issue if any)

Type of change

Please delete options that are not relevant.

  • Bug fix (non-breaking change which fixes an issue)
  • New feature (non-breaking change which adds functionality)
  • Chore (no code changes)
  • Breaking change (fix or feature that would cause existing functionality to not work as expected)
  • This change requires a documentation update

How Has This Been Tested?

Please describe the tests that you ran to verify your changes. Provide instructions so we can reproduce. Please also
list any relevant details for your test configuration

  • Test A
  • Test B

Checklist:

  • My code follows the style guidelines of this project
  • My commit message/PR follows the contribution guidelines of this project
  • I have performed a self-review of my code
  • I have commented my code, particularly in hard-to-understand areas
  • I have added tests that prove my fix is effective or that my feature works
  • New and existing unit tests pass locally with my changes

Other Information:

List any documentation updates that are needed for the Wiki

Summary by CodeRabbit

  • New Features

    • Introduced tenant-specific feature flags for improved asset management.
    • Added new constants for tenant configuration and status tracking.
  • Bug Fixes

    • Enhanced error handling in feature flag checks for asset state services.
  • Improvements

    • Updated logging for asset state event processing to improve traceability.
    • Centralized the table name definition for DynamoDB queries for better maintainability.

Copy link
Contributor

coderabbitai bot commented Dec 18, 2024

Walkthrough

The pull request introduces modifications to the PacmanSdkConstants interface and PolicyExecutor class in the Pacman Rule Engine project. The changes primarily focus on refactoring feature flag handling and tenant configuration management. The constants related to feature flags have been renamed and new constants for tenant configuration and status have been added. The PolicyExecutor class has been updated to use these new constants, improve feature flag checking logic, and enhance logging for asset state events.

Changes

File Change Summary
jobs/pacman-rule-engine-2.0/src/main/java/com/tmobile/pacman/common/PacmanSdkConstants.java - Renamed API_FEATURE_FLAGS to TENANT_FEATURE_FLAGS
- Added TENANT_CONFIG_TABLE constant
- Added STATUS constant
jobs/pacman-rule-engine-2.0/src/main/java/com/tmobile/pacman/executor/PolicyExecutor.java - Updated isAssetStateSvcEnabled method to use new feature flag constant
- Improved feature flag checking logic
- Added logging in sendAssetStateEvent method

Sequence Diagram

sequenceDiagram
    participant PolicyExecutor
    participant DynamoDB
    participant FeatureFlags

    PolicyExecutor->>DynamoDB: Query TENANT_CONFIG_TABLE
    DynamoDB-->>PolicyExecutor: Return tenant configuration
    PolicyExecutor->>FeatureFlags: Check TENANT_FEATURE_FLAGS
    FeatureFlags-->>PolicyExecutor: Return feature flag status
    PolicyExecutor->>PolicyExecutor: Determine asset state service enablement
Loading

Poem

🐰 In the realm of Pacman's code so bright,
Tenant flags now shine with clearer light
Constants dance, their names refined
Feature checks, more smartly designed
A rabbit's leap of config delight! 🚀

Tip

CodeRabbit's docstrings feature is now available as part of our Early Access Program! Simply use the command @coderabbitai generate docstrings to have CodeRabbit automatically generate docstrings for your pull request. We would love to hear your feedback on Discord.


Thank you for using CodeRabbit. We offer it for free to the OSS community and would appreciate your support in helping us grow. If you find it useful, would you consider giving us a shout-out on your favorite social media?

❤️ 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.
    • Generate unit testing code for this file.
    • 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 generate unit testing code for this file.
    • @coderabbitai modularize this function.
  • 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 generate unit testing code.
    • @coderabbitai read the files in the src/scheduler package and generate a class diagram using mermaid and a README in the markdown format.
    • @coderabbitai help me debug CodeRabbit configuration file.

Note: Be mindful of the bot's finite context window. It's strongly recommended to break down tasks such as reading entire modules into smaller chunks. For a focused discussion, use review comments to chat about specific files and their changes, instead of using the PR comments.

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. (Beta)
  • @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
Contributor

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

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

Actionable comments posted: 0

🧹 Nitpick comments (1)
jobs/pacman-rule-engine-2.0/src/main/java/com/tmobile/pacman/executor/PolicyExecutor.java (1)

220-220: Enhance error logging with more context

The error log should include the tenant ID to help with debugging issues.

-            logger.error("Unable to fetch tenant config flags");
+            logger.error("Unable to fetch tenant config flags for tenantId: {}", tenantId);
📜 Review details

Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 23d4632 and 4194afa.

📒 Files selected for processing (2)
  • jobs/pacman-rule-engine-2.0/src/main/java/com/tmobile/pacman/common/PacmanSdkConstants.java (1 hunks)
  • jobs/pacman-rule-engine-2.0/src/main/java/com/tmobile/pacman/executor/PolicyExecutor.java (1 hunks)
🔇 Additional comments (4)
jobs/pacman-rule-engine-2.0/src/main/java/com/tmobile/pacman/common/PacmanSdkConstants.java (2)

705-707: LGTM! Improved naming for feature flags

The renaming from API_FEATURE_FLAGS to TENANT_FEATURE_FLAGS better reflects the multi-tenant architecture. The addition of ENABLE_ASSET_STATE_SERVICE_FLAG_NAME provides clear context for asset state service configuration.

Let's verify the usage of these constants:

✅ Verification successful

Let me gather more context about the usage of these constants in PolicyExecutor.java to ensure the renaming is properly handled.


Verified: Feature flag renaming and usage is consistent

The changes are correctly implemented:

  • TENANT_FEATURE_FLAGS is properly used in PolicyExecutor.java for DynamoDB queries
  • ENABLE_ASSET_STATE_SERVICE_FLAG_NAME is correctly referenced to check the asset state service configuration
  • No instances of the old constant API_FEATURE_FLAGS were found in the codebase
🏁 Scripts executed

The following scripts were executed for the analysis:

Script:

#!/bin/bash
# Search for references to the old and new feature flag constants
echo "Searching for old and new feature flag usage..."
rg -l "API_FEATURE_FLAGS|TENANT_FEATURE_FLAGS"

# Search for asset state service configuration usage
echo "Searching for asset state service configuration..."
rg "ENABLE_ASSET_STATE_SERVICE_FLAG_NAME"

Length of output: 1160


Script:

#!/bin/bash
# Check the context of feature flag usage in PolicyExecutor.java
echo "Checking feature flag usage in PolicyExecutor.java..."
rg -A 5 -B 5 "TENANT_FEATURE_FLAGS|API_FEATURE_FLAGS" jobs/pacman-rule-engine-2.0/src/main/java/com/tmobile/pacman/executor/PolicyExecutor.java

Length of output: 1134


708-709: LGTM! Added tenant configuration constants

The new constants TENANT_CONFIG_TABLE and STATUS support tenant-specific configuration management. The naming is clear and follows the existing convention.

Let's verify the usage of these constants:

✅ Verification successful

Let me gather more context about the usage of these constants in the PolicyExecutor class to understand how they're being used.


Constants are properly used and integrated

The verification shows that:

  • TENANT_CONFIG_TABLE constant is correctly used in PolicyExecutor.java for DynamoDB table queries in the tenant configuration context
  • STATUS constant follows the existing pattern, as evidenced by similar declarations in other core components (admin, commons, aws-rules)
  • The implementation maintains consistency with the codebase's constant naming and usage patterns
🏁 Scripts executed

The following scripts were executed for the analysis:

Script:

#!/bin/bash
# Search for references to the new tenant configuration constants
echo "Searching for tenant configuration usage..."
rg "TENANT_CONFIG_TABLE"

# Search for status constant usage
echo "Searching for status constant usage..."
rg "STATUS.*=.*\"status\""

Length of output: 1166


Script:

#!/bin/bash
# Check the usage context in PolicyExecutor
rg -A 5 -B 5 "TENANT_CONFIG_TABLE" jobs/pacman-rule-engine-2.0/src/main/java/com/tmobile/pacman/executor/PolicyExecutor.java

# Check if there are any other tenant-config related patterns
rg "tenant-config" --type java

Length of output: 1035

jobs/pacman-rule-engine-2.0/src/main/java/com/tmobile/pacman/executor/PolicyExecutor.java (2)

202-217: LGTM! Improved feature flag handling with constants

The changes properly use constants instead of magic strings and add appropriate null checks for the nested map structure.


225-225: ⚠️ Potential issue

Fix logging parameters

The log message format is missing the parameters, which means the source and targetType values won't be logged.

-        logger.info("sending asset state event for source: {} and target type: {}");
+        logger.info("sending asset state event for source: {} and target type: {}", source, targetType);

Likely invalid or redundant comment.

@ershad-paladin ershad-paladin merged commit 3868f56 into master Dec 18, 2024
61 checks passed
@ershad-paladin ershad-paladin deleted the fix/next-291/rename-feature-flag branch December 18, 2024 10:20
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.

2 participants