validate()

in compute/instances/custom-machine-type/helperClass.js [124:165]


    validate() {
      // Check the number of cores
      if (
        this.typeLimit.allowedCores.length > 0 &&
        !this.typeLimit.allowedCores.includes(this.coreCount)
      ) {
        throw new Error(
          `Invalid number of cores requested. Allowed number of cores for ${this.cpuSeries} is: ${this.typeLimit.allowedCores}`
        );
      }

      // Memory must be a multiple of 256 MB
      if (this.memory % 256 !== 0) {
        throw new Error('Requested memory must be a multiple of 256 MB');
      }

      // Check if the requested memory isn't too little
      if (this.memory < this.coreCount * this.typeLimit.minMemPerCore) {
        throw new Error(
          `Requested memory is too low. Minimal memory for ${this.cpuSeries} is ${this.typeLimit.minMemPerCore} MB per core`
        );
      }

      // Check if the requested memory isn't too much
      if (
        this.memory > this.coreCount * this.typeLimit.maxMemPerCore &&
        !this.typeLimit.allowExtraMemory
      ) {
        throw new Error(
          `Requested memory is too large.. Maximum memory allowed for ${this.cpuSeries} is ${this.typeLimit.maxMemPerCore} MB per core`
        );
      }

      if (
        this.memory > this.typeLimit.extraMemoryLimit &&
        this.typeLimit.allowExtraMemory
      ) {
        throw new Error(
          `Requested memory is too large.. Maximum memory allowed for ${this.cpuSeries} is ${this.typeLimit.extraMemoryLimit} MB`
        );
      }
    }