private _getAllocation()

in src/app/frontend/resource/cluster/node/detail/component.ts [84:134]


  private _getAllocation(): void {
    const cpuLimitsValue = FormattedValue.NewFormattedCoreValue(this.node.allocatedResources.cpuLimits);
    const cpuRequestsValue = FormattedValue.NewFormattedCoreValue(this.node.allocatedResources.cpuRequests);
    const cpuCapacityValue = FormattedValue.NewFormattedCoreValue(this.node.allocatedResources.cpuCapacity);

    const memoryLimitsValue = FormattedValue.NewFormattedMemoryValue(this.node.allocatedResources.memoryLimits);
    const memoryRequestsValue = FormattedValue.NewFormattedMemoryValue(this.node.allocatedResources.memoryRequests);
    const memoryCapacityValue = FormattedValue.NewFormattedMemoryValue(this.node.allocatedResources.memoryCapacity);

    if (
      cpuLimitsValue.suffixPower !== cpuRequestsValue.suffixPower ||
      cpuLimitsValue.suffixPower !== cpuCapacityValue.suffixPower
    ) {
      const suffix =
        cpuLimitsValue.suffixPower < cpuRequestsValue.suffixPower ? cpuLimitsValue.suffix : cpuRequestsValue.suffix;

      cpuLimitsValue.normalize(suffix);
      cpuRequestsValue.normalize(suffix);
      cpuCapacityValue.normalize(suffix);
    }

    if (
      memoryLimitsValue.suffixPower !== memoryRequestsValue.suffixPower ||
      memoryLimitsValue.suffixPower !== memoryCapacityValue.suffixPower
    ) {
      const suffix =
        memoryLimitsValue.suffixPower < memoryRequestsValue.suffixPower
          ? memoryLimitsValue.suffix
          : memoryRequestsValue.suffix;

      memoryLimitsValue.normalize(suffix);
      memoryRequestsValue.normalize(suffix);
      memoryCapacityValue.normalize(suffix);
    }

    this.cpuLabel = cpuRequestsValue.suffix.length > 0 ? `${cpuRequestsValue.suffix}cores` : 'Cores';
    this.cpuCapacity = cpuCapacityValue.value;
    this.cpuAllocation = [
      {name: 'Requests', value: cpuRequestsValue.value},
      {name: 'Limits', value: cpuLimitsValue.value},
    ];

    this.memoryLabel = memoryRequestsValue.suffix.length > 0 ? `${memoryRequestsValue.suffix}B` : 'B';
    this.memoryCapacity = memoryCapacityValue.value;
    this.memoryAllocation = [
      {name: 'Requests', value: memoryRequestsValue.value},
      {name: 'Limits', value: memoryLimitsValue.value},
    ];

    this.podsAllocation = [{name: 'Allocation', value: this.node.allocatedResources.allocatedPods}];
  }