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

Migrate swatch-tally FactNormalizer to use CoreSocketNormalizer

XMLWordPrintable

    • False
    • Hide

      None

      Show
      None
    • False
    • subs-swatch-thunder

      Description

      As a swatch developer, I need to update FactNormalizer in swatch-tally to use the centralized CoreSocketNormalizer so that normalization logic is no longer duplicated.

      Technical Details

      File: swatch-tally/src/main/java/.../tally/facts/FactNormalizer.java

      Before:

      • Contains all normalization methods inline
      • Applies marketplace, cloud, modulo-2, vCPU, unit-based rules directly

      After:

      • Build NormalizationContext from InventoryHostFacts
      • Call CoreSocketNormalizer.normalize(context)
      • Use returned NormalizedMeasurements to populate NormalizedFacts

      Code Changes

      // Before (inline normalization)
      private void normalizeSocketCount(NormalizedFacts normalizedFacts, InventoryHostFacts hostFacts) {
          // Complex inline logic
      }
      
      // After (delegate to shared library)
      private void normalizeCoresAndSockets(NormalizedFacts normalizedFacts, InventoryHostFacts hostFacts) {
          NormalizationContext ctx = NormalizationContext.builder()
              .rawCores(hostFacts.getCores())
              .rawSockets(hostFacts.getSockets())
              .isMarketplace(isMarketplace(hostFacts))
              .cloudProvider(hostFacts.getCloudProvider())
              // ... other fields
              .build();
          
          NormalizedMeasurements result = CoreSocketNormalizer.normalize(ctx);
          normalizedFacts.setCores(result.getCores());
          normalizedFacts.setSockets(result.getSockets());
      }
      

      Acceptance Criteria

      • FactNormalizer builds NormalizationContext from host facts
      • FactNormalizer calls CoreSocketNormalizer.normalize()
      • Old normalization methods removed or deprecated
      • All existing FactNormalizer tests pass without modification
      • instance_measurements values unchanged (verified via integration tests)

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

                Created:
                Updated: