diff --git a/java/code/src/com/redhat/rhn/taskomatic/task/payg/PaygAuthDataExtractor.java b/java/code/src/com/redhat/rhn/taskomatic/task/payg/PaygAuthDataExtractor.java index d78f3a3da7ce..cc9c9d9cd5cd 100644 --- a/java/code/src/com/redhat/rhn/taskomatic/task/payg/PaygAuthDataExtractor.java +++ b/java/code/src/com/redhat/rhn/taskomatic/task/payg/PaygAuthDataExtractor.java @@ -46,8 +46,7 @@ public class PaygAuthDataExtractor { private static final Path PAYG_INSTANCE_INFO_JSON = Path.of("/var/cache/rhn/payg.json"); - - private static final int VALIDITY_MINUTES = 10; + private static final int VALIDITY_MINUTES = 11; private static final String CONNECTION_TIMEOUT_PROPEERRTY = "java.payg.connection_timeout"; private static final String WAIT_RESPONSE_TIMEOUT_PROPEERRTY = "java.payg.repsonse_timeout"; diff --git a/java/code/src/com/suse/cloud/CloudPaygManager.java b/java/code/src/com/suse/cloud/CloudPaygManager.java index 3df7d2f9b863..d81d9e7413bd 100644 --- a/java/code/src/com/suse/cloud/CloudPaygManager.java +++ b/java/code/src/com/suse/cloud/CloudPaygManager.java @@ -42,7 +42,9 @@ */ public class CloudPaygManager { private static final Logger LOG = LogManager.getLogger(CloudPaygManager.class); - public static final Path PAYG_COMPLIANCE_INFO_JSON = Path.of("/var/cache/rhn/payg_compliance.json"); + + private static final Path PAYG_COMPLIANCE_INFO_JSON = Path.of("/var/cache/rhn/payg_compliance.json"); + private static final int VALIDITY_MINUTES = 11; private final Gson gson = new GsonBuilder().create(); @@ -142,6 +144,12 @@ private boolean detectIsCompliant() { // Parse the compliance info from the external json file, if available complainceInfo = getInstanceComplianceInfo(); + // Verify the information is correctly updated + if (Duration.between(complainceInfo.getTimestamp(), Instant.now()).toMinutes() > VALIDITY_MINUTES) { + LOG.error("The instance compliance info is not up-to-date."); + return false; + } + // If it's not payg, it's always compliant if (!complainceInfo.isPaygInstance()) { return true;