Uploaded image for project: 'Subscription Watch'
  1. Subscription Watch
  2. SWATCH-4321

Simplify Product Usage Collectors to remove re-normalization

XMLWordPrintable

    • False
    • Hide

      None

      Show
      None
    • False
    • subs-swatch-thunder

      Description

      As a swatch developer, I need to remove the re-normalization logic from Product Usage Collectors so that they only perform categorization and "in the box" logic, trusting the already-normalized values from FactNormalizer.

      Currently, collectors re-apply normalization rules:

      • cloudProvider != null -> sockets = 1
      • isMarketplace -> sockets = 0
      • unmappedGuest -> sockets = 1

      This is redundant since FactNormalizer already applies these rules before storing to instance_measurements.

      Technical Details

      Files:

      • swatch-tally/src/main/java/.../collector/DefaultProductUsageCollector.java
      • swatch-tally/src/main/java/.../collector/RHELProductUsageCollector.java

      Before (DefaultProductUsageCollector):

      if (normalizedFacts.getCloudProviderType() != null) {
          appliedSockets = normalizedFacts.isMarketplace() ? 0 : 1;  // RE-NORMALIZING!
          appliedType = normalizedFacts.getCloudProviderType();
      }
      

      After:

      if (normalizedFacts.getCloudProviderType() != null) {
          appliedSockets = normalizedFacts.getSockets();  // Trust normalized value
          appliedType = normalizedFacts.getCloudProviderType();
      }
      

      What Collectors Should Do (After)

      1. Determine HardwareMeasurementType:

      • PHYSICAL, VIRTUAL, HYPERVISOR, AWS, AZURE, GCP, ALIBABA

      2. Apply "In the Box" Logic:

      • Decide if host contributes to tallies based on hypervisor mapping

      3. Use Normalized Values AS-IS:

      • cores from NormalizedFacts.getCores()
      • sockets from NormalizedFacts.getSockets()

      Acceptance Criteria

      • DefaultProductUsageCollector.buildBucket() uses normalized values directly
      • RHELProductUsageCollector.buildBucket() uses normalized values directly
      • No re-normalization logic remains in collectors
      • host_tally_buckets values match instance_measurements for cores/sockets
      • All existing collector tests pass (may need updates to reflect new behavior)
      • Collectors still correctly determine HardwareMeasurementType
      • Hypervisor-guest mapping logic unchanged

              Unassigned Unassigned
              kflahert@redhat.com Kevin Flaherty
              Votes:
              0 Vote for this issue
              Watchers:
              1 Start watching this issue

                Created:
                Updated: