-
Notifications
You must be signed in to change notification settings - Fork 92
refactor(RHINENG-22633): drop canonical_facts column #3270
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
base: master
Are you sure you want to change the base?
refactor(RHINENG-22633): drop canonical_facts column #3270
Conversation
Reviewer's GuideRefactors the Host model and related logic to remove the JSONB canonical_facts column in favor of first‑class columns for each canonical field, updates matching/serialization/notification logic to use those columns (with a helper to reconstruct canonical fact dicts when needed), and adjusts queries, jobs, and tests accordingly, including special handling for JSONB array canonical fields. Sequence diagram for host matching using per-column canonical facts and in-memory reconstructionsequenceDiagram
actor Client
participant API as HostAPI
participant Repo as HostRepository
participant DB as Database
participant Ser as Serialization
Client->>API: POST /hosts (host payload)
API->>Repo: add_host(identity, input_host, existing_hosts?)
Repo->>Ser: extract_canonical_facts_from_host(input_host)
Ser-->>Repo: canonical_facts_dict
alt existing_hosts provided
Repo->>Repo: find_existing_host(identity, canonical_facts_dict, existing_hosts)
Repo-->>API: matched_host or None
else no in-memory match
Repo->>Repo: find_existing_host(identity, canonical_facts_dict)
Repo->>DB: query Host using
Repo->>DB: contains_no_incorrect_facts_filter(canonical_facts_dict)
Repo->>DB: matches_at_least_one_canonical_fact_filter(canonical_facts_dict)
DB-->>Repo: existing Host or None
Repo-->>API: matched_host or None
end
API->>Ser: serialize_host(matched_or_new_host,...)
Ser->>Ser: extract_canonical_facts_from_host(host)
Ser-->>API: serialized_host (canonical facts reconstructed)
API-->>Client: response with serialized_host
ER diagram for Hosts table after dropping canonical_facts JSONB columnerDiagram
HOSTS ||--o{ GROUPS : has
HOSTS {
uuid id PK
varchar account
varchar org_id
varchar display_name
varchar ansible_host
jsonb facts
jsonb tags
jsonb tags_alt
jsonb system_profile_facts
jsonb groups
uuid insights_id
uuid subscription_manager_id
uuid satellite_id
varchar fqdn
jsonb ip_addresses
jsonb mac_addresses
varchar provider_id
varchar provider_type
uuid openshift_cluster_id
timestamptz created
timestamptz modified
timestamptz stale_timestamp
jsonb per_reporter_staleness
varchar reporter
timestamptz last_check_in
}
GROUPS {
uuid id
varchar name
}
Class diagram for updated Host and LimitedHost models without canonical_facts JSONBclassDiagram
class LimitedHost {
<<SQLAlchemyModel>>
+UUID id
+String display_name
+String ansible_host
+String account
+String org_id
+JSONB facts
+JSONB tags
+JSONB tags_alt
+JSONB system_profile_facts
+JSONB groups
+UUID insights_id
+UUID subscription_manager_id
+UUID satellite_id
+String fqdn
+JSONB ip_addresses
+JSONB mac_addresses
+String provider_id
+String provider_type
+UUID openshift_cluster_id
+DateTime created
+DateTime modified
+DateTime stale_timestamp
+JSONB per_reporter_staleness
+String reporter
+DateTime last_check_in
+save()
}
class Host {
<<SQLAlchemyModel>>
+UUID id
+String display_name
+String ansible_host
+String account
+String org_id
+JSONB facts
+JSONB tags
+JSONB tags_alt
+JSONB system_profile_facts
+JSONB groups
+UUID insights_id
+UUID subscription_manager_id
+UUID satellite_id
+String fqdn
+JSONB ip_addresses
+JSONB mac_addresses
+String provider_id
+String provider_type
+UUID openshift_cluster_id
+DateTime created
+DateTime modified
+DateTime stale_timestamp
+JSONB per_reporter_staleness
+String reporter
+DateTime last_check_in
+save()
+update(input_host, update_system_profile)
+update_display_name(input_display_name, input_reporter, input_fqdn)
+_should_ignore_display_name_update(input_reporter) bool
+_apply_display_name_fallback(input_fqdn)
+_update_ansible_host(ansible_host)
+update_facts(facts_dict)
}
LimitedHost <|-- Host
File-Level Changes
Tips and commandsInteracting with Sourcery
Customizing Your ExperienceAccess your dashboard to:
Getting Help
|
Overview
This PR is being created to address RHINENG-22633.
(A description of your PR's changes, along with why/context to the PR, goes here.)
PR Checklist
Secure Coding Practices Documentation Reference
You can find documentation on this checklist here.
Secure Coding Checklist
Summary by Sourcery
Remove the denormalized canonical_facts JSON column from the Host model, switching all read/write paths, filters, events, and jobs to use first-class host columns and a helper for extracting canonical facts.
Enhancements:
Tests: