Skip to content
Browse files

fix to address restore/consistency handling

  • Loading branch information...
2 parents f7404ae + 53b4ecd commit 9fa21e6d52cd3b2389038e954d80aa0298a89da1 @grze grze committed
View
28 ...es/cluster-manager/src/main/java/com/eucalyptus/address/AbstractSystemAddressManager.java
@@ -3,7 +3,6 @@
import java.net.Inet4Address;
import java.net.InetAddress;
import java.net.UnknownHostException;
-import java.util.Collection;
import java.util.List;
import java.util.NoSuchElementException;
import java.util.concurrent.ConcurrentNavigableMap;
@@ -139,10 +138,7 @@ public Address allocateSystemAddress( final Partition partition ) throws NotEnou
}
public void update( final Cluster cluster, final List<ClusterAddressInfo> ccList ) {
- if ( !cluster.getState( ).isAddressingInitialized( ) ) {
- Helper.loadStoredAddresses( );
- cluster.getState( ).setAddressingInitialized( true );
- }
+ Helper.loadStoredAddresses( );
for ( final ClusterAddressInfo addrInfo : ccList ) {
try {
final Address address = Helper.lookupOrCreate( cluster, addrInfo );
@@ -274,26 +270,30 @@ private static VmInstance maybeFindVm( final String instanceId, final String pub
} catch ( NoSuchElementException ex ) {
Logs.extreme( ).error( ex );
}
- } else if ( privateIp != null ) {
+ }
+ if ( vm == null && privateIp != null ) {
try {
vm = VmInstances.lookupByPrivateIp( privateIp );
} catch ( NoSuchElementException ex ) {
Logs.extreme( ).error( ex );
}
- } else if ( publicIp != null ) {
+ }
+ if ( vm == null && publicIp != null ) {
try {
vm = VmInstances.lookupByPublicIp( publicIp );
} catch ( NoSuchElementException ex ) {
Logs.extreme( ).error( ex );
}
}
- if ( vm != null ) {
+ if ( vm != null && VmState.RUNNING.equals( vm.getState( ) ) && publicIp.equals( vm.getPublicAddress( ) ) ) {
Logs.extreme( ).debug( "Candidate vm which claims this address: " + vm.getInstanceId( ) + " " + vm.getState( ) + " " + publicIp );
if ( publicIp.equals( vm.getPublicAddress( ) ) ) {
Logs.extreme( ).debug( "Found vm which claims this address: " + vm.getInstanceId( ) + " " + vm.getState( ) + " " + publicIp );
}
+ return vm;
+ } else {
+ return null;
}
- return vm;
}
private static void ensureAllocated( final Address addr, final VmInstance vm ) {
@@ -329,10 +329,12 @@ protected static void loadStoredAddresses( ) {
final EntityTransaction db = Entities.get( Address.class );
try {
for ( Address addr : Entities.query( clusterAddr ) ) {
- try {
- addr.init( );
- } catch ( Exception ex ) {
- LOG.error( ex, ex );
+ if ( !Addresses.getInstance( ).contains( addr.getName( ) ) ) {
+ try {
+ addr.init( );
+ } catch ( Exception ex ) {
+ LOG.error( ex, ex );
+ }
}
}
db.commit( );
View
8 clc/modules/cluster-manager/src/main/java/com/eucalyptus/address/Address.java
@@ -438,19 +438,19 @@ private static void addAddress( final Address address ) {
Address addr = address;
EntityWrapper<Address> db = EntityWrapper.get( Address.class );
try {
- addr = db.getUnique( new Address( address.getName( ) ) {
+ addr = db.getUnique( new Address( ) {
{
- this.setOwnerAccountNumber( address.getOwnerAccountNumber( ) );
+ this.setDisplayName( address.getName( ) );
}
} );
+ addr.setOwner( address.getOwner( ) );
db.commit( );
} catch ( RuntimeException e ) {
db.rollback( );
LOG.error( e, e );
} catch ( EucalyptusCloudException e ) {
- addr = new Address( address.getName( ) );
try {
- db.add( addr );
+ db.add( address );
db.commit( );
} catch ( Exception e1 ) {
db.rollback( );

0 comments on commit 9fa21e6

Please sign in to comment.
Something went wrong with that request. Please try again.