Skip to content

Commit

Permalink
refactor(demand): added warning when rentHours is less than 5 min
Browse files Browse the repository at this point in the history
  • Loading branch information
mgordel committed Sep 3, 2024
1 parent 5526db4 commit 1c48145
Showing 1 changed file with 11 additions and 13 deletions.
24 changes: 11 additions & 13 deletions src/market/market.module.ts
Original file line number Diff line number Diff line change
Expand Up @@ -285,22 +285,20 @@ export class MarketModuleImpl implements MarketModule {
? await this.applyLocalGVMIServeSupport(demandOptions.workload)
: demandOptions.workload;

const expirationSec = orderOptions.rentHours * 60 * 60;

/**
* We need to publish a demand with a minimum expiration time of no less than 5 minutes.
*
* When negotiating an offer and sending a counter proposal, providers (on default settings)
* reject offers with an expirationSec of less than 5 minutes.
* By default, the expirationSec in CounterProposal value is copied from the value defined in the demand.
*
* Additionally, we want to avoid a situation when the demand expires before finding and signing
* an agreement with the provider. Therefore, we assume a minimum time of 15 minutes,
* if the value calculated based on the user-defined rentHourse is less.
* Default value on providers for MIN_AGREEMENT_EXPIRATION = 5min.
* This means that if the user declares a rentHours time of less than 5 min,
* offers will be rejected during negotiations with these providers.
*/
const MIN_EXPIRATION_SEC = 15 * 60;
const MIN_EXPIRATION_SEC_WARN = 5 * 60;

const expirationSecBasedOnRentTime = orderOptions.rentHours * 60 * 60;
const expirationSec =
expirationSecBasedOnRentTime < MIN_EXPIRATION_SEC ? MIN_EXPIRATION_SEC : expirationSecBasedOnRentTime;
if (expirationSec < MIN_EXPIRATION_SEC_WARN) {
this.logger.warn(
"The declared value of rentHours is less than 5 min. This may cause offers to be rejected during negotiations.",
);
}

const workloadConfig = new WorkloadDemandDirectorConfig({
...workloadOptions,
Expand Down

0 comments on commit 1c48145

Please sign in to comment.