From 0265bee3c09024817698a4482fa4fe9b2928e78f Mon Sep 17 00:00:00 2001 From: khys95 Date: Fri, 22 Nov 2024 15:15:27 +0100 Subject: [PATCH] =?UTF-8?q?qos:=20QOS=20fails=20with=C2=A0'Attribute=20is?= =?UTF-8?q?=20not=20defined:=20QOS=5FPOLICY'?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Motivation: Find out where in the code we throw the above error and resolve it. Modification: Removal of redundant qos policy logic. Result: Instead of checking if the qos_policy attribute is defined AND null, we will check if it is present using one of the predefined methods. If not, set it to null and resume previous logic. Acked-by: Tigran Mkrtchyan Target: master, 10.2, 10.1, 10.0, 9.2 Require-book: no Require-notes: yes (cherry picked from commit 8b9dfb399767db4c4483ff107a24eed47f633a61) Signed-off-by: khys95 --- .../provider/PolicyBasedQoSProvider.java | 19 ++++--------------- 1 file changed, 4 insertions(+), 15 deletions(-) diff --git a/modules/dcache-qos/src/main/java/org/dcache/qos/services/engine/provider/PolicyBasedQoSProvider.java b/modules/dcache-qos/src/main/java/org/dcache/qos/services/engine/provider/PolicyBasedQoSProvider.java index 23ff30157f0..2bf9b7cad95 100644 --- a/modules/dcache-qos/src/main/java/org/dcache/qos/services/engine/provider/PolicyBasedQoSProvider.java +++ b/modules/dcache-qos/src/main/java/org/dcache/qos/services/engine/provider/PolicyBasedQoSProvider.java @@ -59,10 +59,7 @@ LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING */ package org.dcache.qos.services.engine.provider; -import static org.dcache.qos.util.QoSPermissionUtils.canModifyQos; - import diskCacheV111.util.CacheException; -import diskCacheV111.util.PermissionDeniedCacheException; import diskCacheV111.util.PnfsId; import java.util.Collections; import java.util.EnumSet; @@ -71,6 +68,7 @@ LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING import java.util.Optional; import java.util.Set; import javax.security.auth.Subject; + import org.dcache.namespace.FileAttribute; import org.dcache.poolmanager.SerializablePoolMonitor; import org.dcache.qos.QoSDiskSpecification; @@ -115,17 +113,6 @@ public FileQoSRequirements fetchRequirements(FileQoSUpdate update) throws QoSExc return null; } - FileAttributes attributes = descriptor.getAttributes(); - if (attributes.isDefined(FileAttribute.QOS_POLICY) && attributes.getQosPolicy() == null) { - /* - * This is a lazily discovered change, so - * as a matter of consistency it calls for removal - * of the pnfsid from the engine's tracking tables. - */ - engineDao.delete(update.getPnfsId()); - return super.fetchRequirements(update, descriptor); - } - return fetchRequirements(update, descriptor); } @@ -133,9 +120,11 @@ public FileQoSRequirements fetchRequirements(FileQoSUpdate update) throws QoSExc public FileQoSRequirements fetchRequirements(FileQoSUpdate update, FileQoSRequirements descriptor) throws QoSException { FileAttributes attributes = descriptor.getAttributes(); - String name = attributes.getQosPolicy(); + + String name = attributes.getQosPolicyIfPresent().orElse(null); if (name == null) { + engineDao.delete(update.getPnfsId()); return super.fetchRequirements(update, descriptor); }