You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@brooklyn.apache.org by sv...@apache.org on 2016/11/16 07:09:15 UTC

[1/4] brooklyn-server git commit: BROOKLYN-386: adds CreateUserPolicyRebindTest

Repository: brooklyn-server
Updated Branches:
  refs/heads/master ec6c0d0b8 -> 37986c725


BROOKLYN-386: adds CreateUserPolicyRebindTest


Project: http://git-wip-us.apache.org/repos/asf/brooklyn-server/repo
Commit: http://git-wip-us.apache.org/repos/asf/brooklyn-server/commit/67adc686
Tree: http://git-wip-us.apache.org/repos/asf/brooklyn-server/tree/67adc686
Diff: http://git-wip-us.apache.org/repos/asf/brooklyn-server/diff/67adc686

Branch: refs/heads/master
Commit: 67adc68623becc5c7f0a7ed62b9ade1b233e96c7
Parents: b42210e
Author: Aled Sage <al...@gmail.com>
Authored: Tue Nov 15 09:57:56 2016 +0000
Committer: Aled Sage <al...@gmail.com>
Committed: Tue Nov 15 10:24:34 2016 +0000

----------------------------------------------------------------------
 .../mgmt/rebind/RebindTestFixtureWithApp.java   |  13 ++-
 .../jclouds/os/CreateUserPolicyRebindTest.java  | 115 +++++++++++++++++++
 2 files changed, 127 insertions(+), 1 deletion(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/brooklyn-server/blob/67adc686/core/src/test/java/org/apache/brooklyn/core/mgmt/rebind/RebindTestFixtureWithApp.java
----------------------------------------------------------------------
diff --git a/core/src/test/java/org/apache/brooklyn/core/mgmt/rebind/RebindTestFixtureWithApp.java b/core/src/test/java/org/apache/brooklyn/core/mgmt/rebind/RebindTestFixtureWithApp.java
index e609a02..8c4bae7 100644
--- a/core/src/test/java/org/apache/brooklyn/core/mgmt/rebind/RebindTestFixtureWithApp.java
+++ b/core/src/test/java/org/apache/brooklyn/core/mgmt/rebind/RebindTestFixtureWithApp.java
@@ -22,6 +22,7 @@ import java.util.Collection;
 
 import org.apache.brooklyn.api.entity.Application;
 import org.apache.brooklyn.api.entity.EntitySpec;
+import org.apache.brooklyn.core.entity.BrooklynConfigKeys;
 import org.apache.brooklyn.core.test.entity.TestApplication;
 import org.apache.brooklyn.core.test.entity.TestApplicationNoEnrichersImpl;
 
@@ -31,8 +32,18 @@ import com.google.common.collect.Iterables;
 
 public class RebindTestFixtureWithApp extends RebindTestFixture<TestApplication> {
 
+    /** set null not to set, or a boolean to set explicitly */
+    protected Boolean shouldSkipOnBoxBaseDirResolution() {
+        // TODO Change default to true; starting with this as null for backwards compatibility!
+        return null;
+    }
+
     protected TestApplication createApp() {
-        return origManagementContext.getEntityManager().createEntity(EntitySpec.create(TestApplication.class, TestApplicationNoEnrichersImpl.class));
+        EntitySpec<TestApplication> spec = EntitySpec.create(TestApplication.class, TestApplicationNoEnrichersImpl.class);
+        if (shouldSkipOnBoxBaseDirResolution()!=null) {
+            spec.configure(BrooklynConfigKeys.SKIP_ON_BOX_BASE_DIR_RESOLUTION, shouldSkipOnBoxBaseDirResolution());
+        }
+        return origManagementContext.getEntityManager().createEntity(spec);
     }
     
     @Override

http://git-wip-us.apache.org/repos/asf/brooklyn-server/blob/67adc686/locations/jclouds/src/test/java/org/apache/brooklyn/policy/jclouds/os/CreateUserPolicyRebindTest.java
----------------------------------------------------------------------
diff --git a/locations/jclouds/src/test/java/org/apache/brooklyn/policy/jclouds/os/CreateUserPolicyRebindTest.java b/locations/jclouds/src/test/java/org/apache/brooklyn/policy/jclouds/os/CreateUserPolicyRebindTest.java
new file mode 100644
index 0000000..7b677a1
--- /dev/null
+++ b/locations/jclouds/src/test/java/org/apache/brooklyn/policy/jclouds/os/CreateUserPolicyRebindTest.java
@@ -0,0 +1,115 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.brooklyn.policy.jclouds.os;
+
+import static org.testng.Assert.assertEquals;
+import static org.testng.Assert.fail;
+
+import org.apache.brooklyn.api.entity.EntitySpec;
+import org.apache.brooklyn.api.location.LocationSpec;
+import org.apache.brooklyn.api.policy.PolicySpec;
+import org.apache.brooklyn.core.entity.EntityAsserts;
+import org.apache.brooklyn.core.mgmt.rebind.RebindTestFixtureWithApp;
+import org.apache.brooklyn.core.test.entity.TestEntity;
+import org.apache.brooklyn.location.ssh.SshMachineLocation;
+import org.apache.brooklyn.test.Asserts;
+import org.apache.brooklyn.util.core.internal.ssh.RecordingSshTool;
+import org.apache.brooklyn.util.core.internal.ssh.RecordingSshTool.ExecCmd;
+import org.apache.brooklyn.util.time.Duration;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+import org.testng.annotations.AfterMethod;
+import org.testng.annotations.BeforeMethod;
+import org.testng.annotations.Test;
+
+import com.google.common.collect.ImmutableList;
+import com.google.common.collect.ImmutableMap;
+import com.google.common.collect.Iterables;
+
+public class CreateUserPolicyRebindTest extends RebindTestFixtureWithApp {
+
+    @SuppressWarnings("unused")
+    private static final Logger LOG = LoggerFactory.getLogger(CreateUserPolicyRebindTest.class);
+
+    @BeforeMethod(alwaysRun=true)
+    @Override
+    public void setUp() throws Exception {
+        super.setUp();
+        RecordingSshTool.clear();
+    }
+
+    @AfterMethod(alwaysRun=true)
+    @Override
+    public void tearDown() throws Exception {
+        try {
+            super.tearDown();
+        } finally {
+            RecordingSshTool.clear();
+        }
+    }
+    
+    @Override
+    protected Boolean shouldSkipOnBoxBaseDirResolution() {
+        return true;
+    }
+
+    protected boolean isUseraddExecuted() {
+        for (ExecCmd cmds : RecordingSshTool.getExecCmds()) {
+            if (cmds.commands.toString().contains("useradd")) {
+                return true;
+            }
+        }
+        return false;
+    }
+
+    // See BROOKLYN-386
+    @Test
+    public void testNotCallCreateUserOnRebind() throws Exception {
+        SshMachineLocation machine = mgmt().getLocationManager().createLocation(LocationSpec.create(SshMachineLocation.class)
+                .configure(SshMachineLocation.SSH_TOOL_CLASS, RecordingSshTool.class.getName())
+                .configure("address", "1.2.3.4"));
+    
+        String newUsername = "mynewuser";
+        
+        app().createAndManageChild(EntitySpec.create(TestEntity.class)
+                .policy(PolicySpec.create(CreateUserPolicy.class)
+                        .configure(CreateUserPolicy.GRANT_SUDO, true)
+                        .configure(CreateUserPolicy.RESET_LOGIN_USER, false)
+                        .configure(CreateUserPolicy.VM_USERNAME, newUsername)));
+        TestEntity entity = (TestEntity) Iterables.getOnlyElement(app().getChildren());
+        app().start(ImmutableList.of(machine));
+        
+        String creds = EntityAsserts.assertAttributeEventuallyNonNull(entity, CreateUserPolicy.VM_USER_CREDENTIALS);
+        if (!isUseraddExecuted()) {
+            fail("useradd not found in: "+RecordingSshTool.getExecCmds());
+        }
+        RecordingSshTool.clear();
+        
+        rebind();
+        TestEntity newEntity = (TestEntity) Iterables.getOnlyElement(app().getChildren());
+        
+        Asserts.succeedsContinually(ImmutableMap.of("timeout", Duration.millis(250)), new Runnable() {
+            @Override public void run() {
+                if (isUseraddExecuted()) {
+                    fail("useradd found in: "+RecordingSshTool.getExecCmds());
+                }
+            }});
+        assertEquals(newEntity.sensors().get(CreateUserPolicy.VM_USER_CREDENTIALS), creds);
+    }
+}


[3/4] brooklyn-server git commit: BROOKLYN-386: Avoid NPE in JcloudsSshMachineLocation.getOptionalNode

Posted by sv...@apache.org.
BROOKLYN-386: Avoid NPE in JcloudsSshMachineLocation.getOptionalNode


Project: http://git-wip-us.apache.org/repos/asf/brooklyn-server/repo
Commit: http://git-wip-us.apache.org/repos/asf/brooklyn-server/commit/83d8626d
Tree: http://git-wip-us.apache.org/repos/asf/brooklyn-server/tree/83d8626d
Diff: http://git-wip-us.apache.org/repos/asf/brooklyn-server/diff/83d8626d

Branch: refs/heads/master
Commit: 83d8626d2fc19c4446ec73a025c30ec72eb4aea1
Parents: eb0fbad
Author: Aled Sage <al...@gmail.com>
Authored: Tue Nov 15 07:43:38 2016 +0000
Committer: Aled Sage <al...@gmail.com>
Committed: Tue Nov 15 10:24:34 2016 +0000

----------------------------------------------------------------------
 .../jclouds/JcloudsSshMachineLocation.java      | 32 +++++++++++++++-----
 1 file changed, 25 insertions(+), 7 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/brooklyn-server/blob/83d8626d/locations/jclouds/src/main/java/org/apache/brooklyn/location/jclouds/JcloudsSshMachineLocation.java
----------------------------------------------------------------------
diff --git a/locations/jclouds/src/main/java/org/apache/brooklyn/location/jclouds/JcloudsSshMachineLocation.java b/locations/jclouds/src/main/java/org/apache/brooklyn/location/jclouds/JcloudsSshMachineLocation.java
index 0ec99e5..3688aa8 100644
--- a/locations/jclouds/src/main/java/org/apache/brooklyn/location/jclouds/JcloudsSshMachineLocation.java
+++ b/locations/jclouds/src/main/java/org/apache/brooklyn/location/jclouds/JcloudsSshMachineLocation.java
@@ -43,6 +43,7 @@ import org.apache.brooklyn.util.core.flags.SetFromFlag;
 import org.apache.brooklyn.util.exceptions.Exceptions;
 import org.apache.brooklyn.util.net.Networking;
 import org.apache.brooklyn.util.text.Strings;
+import org.jclouds.compute.ComputeService;
 import org.jclouds.compute.ComputeServiceContext;
 import org.jclouds.compute.callables.RunScriptOnNode;
 import org.jclouds.compute.domain.ExecResponse;
@@ -212,11 +213,22 @@ public class JcloudsSshMachineLocation extends SshMachineLocation implements Jcl
         _image = Optional.fromNullable(template.getImage());
     }
 
+    protected ComputeService getComputeServiceOrNull() {
+        JcloudsLocation parent = getParent();
+        return (parent != null) ? parent.getComputeService() : null;
+    }
+    
     @Override
     public Optional<NodeMetadata> getOptionalNode() {
       if (_node == null) {
           try {
-              _node = Optional.fromNullable(getParent().getComputeService().getNodeMetadata(nodeId));
+              ComputeService computeService = getComputeServiceOrNull();
+              if (computeService == null) {
+                  if (LOG.isDebugEnabled()) LOG.debug("Cannot get node for {}, because cannot get compute-service from parent {}", this, getParent());
+                  _node = Optional.absent();
+              } else {
+                  _node = Optional.fromNullable(computeService.getNodeMetadata(nodeId));
+              }
           } catch (Exception e) {
               Exceptions.propagateIfFatal(e);
               if (LOG.isDebugEnabled()) LOG.debug("Problem getting node-metadata for " + this + ", node id " + nodeId + " (continuing)", e);
@@ -232,7 +244,13 @@ public class JcloudsSshMachineLocation extends SshMachineLocation implements Jcl
               _image = Optional.absent(); // can happen with JcloudsLocation.resumeMachine() usage
           } else {
               try {
-                  _image = Optional.fromNullable(getParent().getComputeService().getImage(imageId));
+                  ComputeService computeService = getComputeServiceOrNull();
+                  if (computeService == null) {
+                      if (LOG.isDebugEnabled()) LOG.debug("Cannot get image (with id {}) for {}, because cannot get compute-service from parent {}", new Object[] {imageId, this, getParent()});
+                      _node = Optional.absent();
+                  } else {
+                      _image = Optional.fromNullable(computeService.getImage(imageId));
+                  }
               } catch (Exception e) {
                   Exceptions.propagateIfFatal(e);
                   if (LOG.isDebugEnabled()) LOG.debug("Problem getting image for " + this + ", image id " + imageId + " (continuing)", e);
@@ -440,7 +458,7 @@ public class JcloudsSshMachineLocation extends SshMachineLocation implements Jcl
         Optional<NodeMetadata> node = getOptionalNode();
 
         if (!node.isPresent()) {
-            throw new IllegalStateException("Node "+nodeId+" not present in "+getParent());
+            throw new IllegalStateException("Node "+nodeId+" not present in "+jcloudsParent);
         }
         if (jcloudsParent == null) {
             throw new IllegalStateException("No jclouds parent location for "+this+"; cannot retrieve jclouds script-runner");
@@ -596,16 +614,16 @@ public class JcloudsSshMachineLocation extends SshMachineLocation implements Jcl
 
     @Override
     public Map<String, String> toMetadataRecord() {
+        JcloudsLocation parent = getParent();
         Optional<NodeMetadata> node = getOptionalNode();
-        
         Optional<Hardware> hardware = getOptionalHardware();
         List<? extends Processor> processors = hardware.isPresent() ? hardware.get().getProcessors() : null;
         
         ImmutableMap.Builder<String, String> builder = ImmutableMap.builder();
         builder.putAll(super.toMetadataRecord());
-        putIfNotNull(builder, "provider", getParent().getProvider());
-        putIfNotNull(builder, "account", getParent().getIdentity());
-        putIfNotNull(builder, "region", getParent().getRegion());
+        putIfNotNull(builder, "provider", (parent != null) ? parent.getProvider() : null);
+        putIfNotNull(builder, "account", (parent != null) ? parent.getIdentity() : null);
+        putIfNotNull(builder, "region", (parent != null) ? parent.getRegion() : null);
         putIfNotNull(builder, "serverId", getJcloudsId());
         putIfNotNull(builder, "imageId", getImageId());
         putIfNotNull(builder, "instanceTypeName", (hardware.isPresent() ? hardware.get().getName() : null));


[4/4] brooklyn-server git commit: Closes #438

Posted by sv...@apache.org.
Closes #438

Fix BROOKLYN-386: avoid locationAdded events on rebind


Project: http://git-wip-us.apache.org/repos/asf/brooklyn-server/repo
Commit: http://git-wip-us.apache.org/repos/asf/brooklyn-server/commit/37986c72
Tree: http://git-wip-us.apache.org/repos/asf/brooklyn-server/tree/37986c72
Diff: http://git-wip-us.apache.org/repos/asf/brooklyn-server/diff/37986c72

Branch: refs/heads/master
Commit: 37986c7257dbcbd31af7c858c0294705dba7133a
Parents: ec6c0d0 67adc68
Author: Svetoslav Neykov <sv...@cloudsoftcorp.com>
Authored: Wed Nov 16 09:09:08 2016 +0200
Committer: Svetoslav Neykov <sv...@cloudsoftcorp.com>
Committed: Wed Nov 16 09:09:08 2016 +0200

----------------------------------------------------------------------
 .../brooklyn/core/entity/AbstractEntity.java    |  30 +++--
 .../brooklyn/core/entity/EntityInternal.java    |  15 ++-
 .../mgmt/rebind/BasicEntityRebindSupport.java   |   4 +-
 .../mgmt/rebind/RebindTestFixtureWithApp.java   |  13 ++-
 .../jclouds/JcloudsSshMachineLocation.java      |  32 ++++--
 .../jclouds/os/CreateUserPolicyRebindTest.java  | 115 +++++++++++++++++++
 6 files changed, 187 insertions(+), 22 deletions(-)
----------------------------------------------------------------------



[2/4] brooklyn-server git commit: BROOKLYN-386: avoid locationAdded events on rebind

Posted by sv...@apache.org.
BROOKLYN-386: avoid locationAdded events on rebind

Project: http://git-wip-us.apache.org/repos/asf/brooklyn-server/repo
Commit: http://git-wip-us.apache.org/repos/asf/brooklyn-server/commit/b42210ee
Tree: http://git-wip-us.apache.org/repos/asf/brooklyn-server/tree/b42210ee
Diff: http://git-wip-us.apache.org/repos/asf/brooklyn-server/diff/b42210ee

Branch: refs/heads/master
Commit: b42210ee2556bc2a97a53387f6ffc4f4ee01efe6
Parents: 83d8626
Author: Aled Sage <al...@gmail.com>
Authored: Tue Nov 15 09:57:31 2016 +0000
Committer: Aled Sage <al...@gmail.com>
Committed: Tue Nov 15 10:24:34 2016 +0000

----------------------------------------------------------------------
 .../brooklyn/core/entity/AbstractEntity.java    | 30 +++++++++++++++-----
 .../brooklyn/core/entity/EntityInternal.java    | 15 ++++++----
 .../mgmt/rebind/BasicEntityRebindSupport.java   |  4 +--
 3 files changed, 35 insertions(+), 14 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/brooklyn-server/blob/b42210ee/core/src/main/java/org/apache/brooklyn/core/entity/AbstractEntity.java
----------------------------------------------------------------------
diff --git a/core/src/main/java/org/apache/brooklyn/core/entity/AbstractEntity.java b/core/src/main/java/org/apache/brooklyn/core/entity/AbstractEntity.java
index fd7a403..26da5d6 100644
--- a/core/src/main/java/org/apache/brooklyn/core/entity/AbstractEntity.java
+++ b/core/src/main/java/org/apache/brooklyn/core/entity/AbstractEntity.java
@@ -891,6 +891,17 @@ public abstract class AbstractEntity extends AbstractBrooklynObject implements E
 
     @Override
     public void addLocations(Collection<? extends Location> newLocations) {
+        addLocationsImpl(newLocations, true);
+    }
+
+    @Override
+    @Beta
+    public void addLocationsWithoutPublishing(Collection<? extends Location> newLocations) {
+        addLocationsImpl(newLocations, false);
+    }
+    
+    @Beta
+    protected void addLocationsImpl(Collection<? extends Location> newLocations, boolean publish) {
         if (newLocations==null || newLocations.isEmpty()) {
             return;
         }
@@ -918,18 +929,23 @@ public abstract class AbstractEntity extends AbstractBrooklynObject implements E
                 locations.set(ImmutableList.<Location>builder().addAll(oldLocations).addAll(trulyNewLocations).build());
             }
             
-            for (Location loc : trulyNewLocations) {
-                sensors().emit(AbstractEntity.LOCATION_ADDED, loc);
+            if (publish) {
+                for (Location loc : trulyNewLocations) {
+                    sensors().emit(AbstractEntity.LOCATION_ADDED, loc);
+                }
             }
         }
         
-        if (getManagementSupport().isDeployed()) {
-            for (Location newLocation : newLocations) {
-                // Location is now reachable, so manage it
-                // TODO will not be required in future releases when creating locations always goes through LocationManager.createLocation(LocationSpec).
-                Locations.manage(newLocation, getManagementContext());
+        if (publish) {
+            if (getManagementSupport().isDeployed()) {
+                for (Location newLocation : newLocations) {
+                    // Location is now reachable, so manage it
+                    // TODO will not be required in future releases when creating locations always goes through LocationManager.createLocation(LocationSpec).
+                    Locations.manage(newLocation, getManagementContext());
+                }
             }
         }
+        
         getManagementSupport().getEntityChangeListener().onLocationsChanged();
     }
 

http://git-wip-us.apache.org/repos/asf/brooklyn-server/blob/b42210ee/core/src/main/java/org/apache/brooklyn/core/entity/EntityInternal.java
----------------------------------------------------------------------
diff --git a/core/src/main/java/org/apache/brooklyn/core/entity/EntityInternal.java b/core/src/main/java/org/apache/brooklyn/core/entity/EntityInternal.java
index 5610903..bd0fcce 100644
--- a/core/src/main/java/org/apache/brooklyn/core/entity/EntityInternal.java
+++ b/core/src/main/java/org/apache/brooklyn/core/entity/EntityInternal.java
@@ -23,8 +23,6 @@ import java.util.Map;
 
 import javax.annotation.Nullable;
 
-import com.google.common.annotations.Beta;
-
 import org.apache.brooklyn.api.effector.Effector;
 import org.apache.brooklyn.api.entity.Entity;
 import org.apache.brooklyn.api.entity.EntityLocal;
@@ -38,11 +36,10 @@ import org.apache.brooklyn.api.mgmt.rebind.Rebindable;
 import org.apache.brooklyn.api.mgmt.rebind.mementos.EntityMemento;
 import org.apache.brooklyn.api.sensor.AttributeSensor;
 import org.apache.brooklyn.api.sensor.Feed;
-import org.apache.brooklyn.config.ConfigKey;
-import org.apache.brooklyn.core.entity.internal.EntityConfigMap;
 import org.apache.brooklyn.core.mgmt.internal.EntityManagementSupport;
 import org.apache.brooklyn.core.objs.BrooklynObjectInternal;
-import org.apache.brooklyn.util.core.config.ConfigBag;
+
+import com.google.common.annotations.Beta;
 
 /** 
  * Extended Entity interface with additional functionality that is purely-internal (i.e. intended 
@@ -55,6 +52,14 @@ public interface EntityInternal extends BrooklynObjectInternal, EntityLocal, Reb
 
     void removeLocations(Collection<? extends Location> locations);
 
+    /**
+     * Adds the given locations to this entity, but without emitting {@link AbstractEntity#LOCATION_ADDED} 
+     * events, and without auto-managing the locations. This is for internal purposes only; it is primarily 
+     * intended for use during rebind.
+     */
+    @Beta
+    void addLocationsWithoutPublishing(@Nullable Collection<? extends Location> locations);
+
     void clearLocations();
 
     /**

http://git-wip-us.apache.org/repos/asf/brooklyn-server/blob/b42210ee/core/src/main/java/org/apache/brooklyn/core/mgmt/rebind/BasicEntityRebindSupport.java
----------------------------------------------------------------------
diff --git a/core/src/main/java/org/apache/brooklyn/core/mgmt/rebind/BasicEntityRebindSupport.java b/core/src/main/java/org/apache/brooklyn/core/mgmt/rebind/BasicEntityRebindSupport.java
index 29a39f8..b85b768 100644
--- a/core/src/main/java/org/apache/brooklyn/core/mgmt/rebind/BasicEntityRebindSupport.java
+++ b/core/src/main/java/org/apache/brooklyn/core/mgmt/rebind/BasicEntityRebindSupport.java
@@ -90,7 +90,7 @@ public class BasicEntityRebindSupport extends AbstractBrooklynObjectRebindSuppor
                 Object value = entry.getValue();
                 @SuppressWarnings("unused") // just to ensure we can load the declared type? or maybe not needed
                 Class<?> type = (key.getType() != null) ? key.getType() : rebindContext.loadClass(key.getTypeName());
-                ((EntityInternal)entity).setAttributeWithoutPublishing((AttributeSensor<Object>)key, value);
+                ((EntityInternal)entity).sensors().setWithoutPublishing((AttributeSensor<Object>)key, value);
             } catch (Exception e) {
                 LOG.warn("Error adding custom sensor "+entry+" when rebinding "+entity+" (rethrowing): "+e);
                 throw Exceptions.propagate(e);
@@ -232,7 +232,7 @@ public class BasicEntityRebindSupport extends AbstractBrooklynObjectRebindSuppor
         for (String id : memento.getLocations()) {
             Location loc = rebindContext.lookup().lookupLocation(id);
             if (loc != null) {
-                ((EntityInternal)entity).addLocations(ImmutableList.of(loc));
+                ((EntityInternal)entity).addLocationsWithoutPublishing(ImmutableList.of(loc));
             } else {
                 LOG.warn("Location not found; discarding location {} of entity {}({})",
                         new Object[] {id, memento.getType(), memento.getId()});