[Entity-Service] Use staging's column names in the instance and deployed-product queries - #1877
Merged
Rashmika998 merged 1 commit intoSep 21, 2026
Conversation
…yed-product queries Staging's schema is built by the sync service, which renamed columns the instance queries were written against: deployment_node.deployment_ref -> deployment_number and subscription_key -> project_key; deployment_information.number_of_cores -> core_count and reported_created_on/reported_updated_on -> payload_*_on. With the old names SearchInstances, SearchInstanceMetrics and SearchInstanceUsage failed on staging with "column dn.deployment_ref does not exist". The deployment rename is a change of meaning: the value is a deployment NUMBER (DEP000002442), never a UUID, so the old "cast deployment_ref to uuid" join could not match anything. Resolve a node's project from project_key (project.key is unique) and its deployment from deployment_number (deployment.number is unique) only when that deployment belongs to the node's own project. That guard matters: staging has three nodes whose deployment_number "320" equals the number of a deployment in a different project, which a join on the number alone would have attached to the wrong project. core_count is a real integer column, so the free-text parser is gone. Verified against staging: every instance and deployed-product method runs; 16 nodes, 14 resolve to a project and 11 to a deployment, none to a deployment of another project; filtering by project and by deployment equals independent SQL. Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
Contributor
|
Warning Review limit reachedNext included review available in 16 minutes. View limit detailsLimit details: You’ve used the included review currently available. You've used all free OSS reviews for now. Wait for the free limit to reset to keep reviewing this public repository. Review configuration: ⚙️ Run configurationConfiguration used: Repository: wso2-open-operations/cs-tools/.coderabbit.yaml Review profile: CHILL Plan: Advanced Run ID: 📒 Files selected for processing (3)
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. Comment |
shayanmalinda
approved these changes
Sep 21, 2026
Rashmika998
merged commit Sep 21, 2026
7e9d848
into
wso2-open-operations:dev-app-csm-portal
2 checks passed
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Three instance endpoints fail on staging today:
(
SearchInstances,SearchInstanceMetrics,SearchInstanceUsage.) Staging's schema is built by the sync service, which renamed columns these queries were written against. Found while auditing table and column names against the live database.deployment_node.deployment_refdeployment_numberdeployment_node.subscription_keyproject_keydeployment_information.number_of_cores(text)core_count(integer)deployment_information.reported_created_on/reported_updated_onpayload_created_on/payload_updated_onThe deployment rename is a change of meaning, not just spelling. The value is a deployment number (
DEP000002442), never a UUID, so the old join (castdeployment_refto a UUID and matchdeployment.id) could not match anything, and its own comment said it was unverified against real data.The join
project_key->project.key(unique, present on every node), so a node's project no longer depends on its deployment resolving.deployment_number->deployment.number(unique) only if that deployment belongs to the node's own project. This guard matters: staging has three nodes whosedeployment_numberis"320", which equals the number of a deployment in a different project. Matching the number alone would have attached them to the wrong project. With the guard they stay unresolved (deployment nil, project still set).core_countis a real integer column, so the free-textparseCoreCountis removed.deployed_product_repo.go's node resolution uses the same rule.Verification (against staging, throwaway tests, not committed)
SearchInstances,SearchInstanceMetrics,SearchInstanceUsage, both stats methods) andSearchDeployedProducts,SearchDeployedProductMetrics,SearchDeployedProductUsageCountsnow run without error.gofmt,go vet,gosec(0 issues),govulncheckclean.go testhas one failure,TestSNCaseService_CreateCase_PublishesCaseCreated, which fails the same way without this change.Data gap, not a code bug
No
deployment_information.node_idmatches anydeployment_node.node_idin staging (the former are sys_ids andTEST2/TEST3), so no instance has metadata there.Note
migrations/000054still uses the old column names; staging does not matchmigrations/(see the schema drift notes in #1876). This PR follows the live database, as asked.🤖 Generated with Claude Code