CSS: handle features with no version 65/67165/3
authorStephen Kitt <skitt@redhat.com>
Mon, 15 Jan 2018 13:44:47 +0000 (14:44 +0100)
committerMichael Vorburger <vorburger@redhat.com>
Mon, 15 Jan 2018 16:22:04 +0000 (16:22 +0000)
When a feature has no version, it can end up interpreted as having
version 0.0.0 (which is the default version). CSS ends up looking for
features with version 0.0.0, which fail to compare with versionless
features. This patch deals with this case explicitly.

Change-Id: I354c7d679e194c38a6aa6883deb2da2b24cda29e
Signed-off-by: Stephen Kitt <skitt@redhat.com>
opendaylight/config/config-persister-feature-adapter/src/main/java/org/opendaylight/controller/configpusherfeature/internal/FeatureConfigPusher.java

index 49077dcc6f382a7c3f744a16c838be37f5107501..2737954884814464dfc1f71615217b073c9d236b 100644 (file)
@@ -10,7 +10,6 @@ package org.opendaylight.controller.configpusherfeature.internal;
 import com.google.common.base.Optional;
 import com.google.common.collect.LinkedHashMultimap;
 import java.util.ArrayList;
-import java.util.Arrays;
 import java.util.Collections;
 import java.util.LinkedHashSet;
 import java.util.List;
@@ -133,9 +132,16 @@ public class FeatureConfigPusher {
     private boolean isInstalled(final Feature feature) throws InterruptedException {
         for (int retries = 0; retries < MAX_RETRIES; retries++) {
             try {
-                List<Feature> installedFeatures = Arrays.asList(featuresService.listInstalledFeatures());
-                if (installedFeatures.contains(feature)) {
-                    return true;
+                // We process the installed features manually to handle the special "0.0.0" version
+                // which is the representation for null
+                for (Feature installedFeature : featuresService.listInstalledFeatures()) {
+                    if (feature.equals(installedFeature)) {
+                        return true;
+                    }
+                    if ("0.0.0".equals(feature.getVersion()) && feature.getName().equals(installedFeature.getName())
+                            && !installedFeature.hasVersion()) {
+                        return true;
+                    }
                 }
 
                 LOG.debug("Karaf Feature Service has not yet finished installing feature {}/{} (retry {})", feature
@@ -147,15 +153,8 @@ public class FeatureConfigPusher {
             TimeUnit.MILLISECONDS.sleep(RETRY_PAUSE_MILLIS);
         }
 
-        // In karaf  4.1.3 we see this error logged for 2 system features, "jaas-boot" and "wrap", many times. It's
-        // unclear why listInstalledFeatures doesn't return them but it doesn't really matter since we're only
-        // interested in ODL features that have CSS files. Maybe the common denominator is that they don't have a
-        // version (ie it's 0.0.0) hence the following check to avoid logging the error. This check would not
-        // exclude any ODL feature since all ODL features are versioned (should be anyway).
-        if (!"0.0.0".equals(feature.getVersion())) {
-            LOG.error("Giving up (after {} retries) on Karaf featuresService.listInstalledFeatures() which has not yet "
-                    + "finished installing feature {} {}", MAX_RETRIES, feature.getName(), feature.getVersion());
-        }
+        LOG.error("Giving up (after {} retries) on Karaf featuresService.listInstalledFeatures() which has not yet "
+                + "finished installing feature {} {}", MAX_RETRIES, feature.getName(), feature.getVersion());
         return false;
     }
 }