Browse files

net index fix, max volume reduciton in NC, CC independent terminate/u…

…nassign pairing, fix leak in tx.begin() error path, fix to dev naming for detach issue
  • Loading branch information...
2 parents b41ec49 + eb4ebd4 commit 84808f21a9c5a84cc0714d7eb0416b2c95263cb4 @grze grze committed Feb 1, 2012
View
4 clc/modules/cluster-manager/src/main/java/com/eucalyptus/vm/VmControl.java
@@ -99,6 +99,7 @@
import com.eucalyptus.entities.Entities;
import com.eucalyptus.entities.TransactionException;
import com.eucalyptus.images.BlockStorageImageInfo;
+import com.eucalyptus.network.PrivateNetworkIndex;
import com.eucalyptus.records.EventRecord;
import com.eucalyptus.records.EventType;
import com.eucalyptus.records.Logs;
@@ -436,6 +437,9 @@ public StartInstancesResponseType startInstances( final StartInstancesType reque
Allocation allocInfo = Allocations.start( vm );
try {//scope for allocInfo
AdmissionControl.run( ).apply( allocInfo );
+ PrivateNetworkIndex vmIdx = allocInfo.getAllocationTokens( ).get( 0 ).getNetworkIndex( );
+ vmIdx.set( vm );
+ vm.setNetworkIndex( vmIdx );
vm.setState( VmState.PENDING );
ClusterAllocator.get( ).apply( allocInfo );
final int oldCode = vm.getState( ).getCode( ), newCode = VmState.PENDING.getCode( );
View
9 clc/modules/cluster-manager/src/main/java/com/eucalyptus/vm/VmInstance.java
@@ -657,6 +657,13 @@ public VmInstance apply( final VmInstance v ) {
vm.setState( VmState.STOPPING, Reason.USER_STOPPED );
} else if ( VmState.STOPPING.equals( vm.getState( ) ) ) {
vm.setState( VmState.STOPPED, Reason.USER_STOPPED );
+ PrivateNetworkIndex vmIdx = vm.getNetworkIndex( );
+ if ( vmIdx != null ) {
+ vmIdx.release( );
+ vmIdx.teardown( );
+ vmIdx = null;
+ }
+ vm.setNetworkIndex( null );
}
db.commit( );
return vm;
@@ -1214,7 +1221,7 @@ public String toString( ) {
}
- private PrivateNetworkIndex getNetworkIndex( ) {
+ PrivateNetworkIndex getNetworkIndex( ) {
return this.networkIndex;
}
View
4 clc/modules/cluster-manager/src/main/java/com/eucalyptus/vm/VmVolumeAttachment.java
@@ -230,8 +230,8 @@ public AttachedVolume apply( VmVolumeAttachment vol ) {
}
attachment.setAttachTime( vol.getAttachTime( ) );
attachment.setStatus( vol.getStatus( ) );
- if ( !attachment.getDevice( ).startsWith( "/dev/" ) ) {
- attachment.setDevice( "/dev/" + attachment.getDevice( ) );
+ if ( !attachment.getDevice( ).replaceAll( "unknown,requested:", "" ).startsWith( "/dev/" ) ) {
+ attachment.setDevice( "/dev/" + attachment.getDevice( ).replaceAll( "unknown,requested:", "" ) );
}
return attachment;
}
View
23 clc/modules/msgs/src/main/java/com/eucalyptus/entities/Entities.java
@@ -196,14 +196,23 @@ private static String makeTxRootName( final CascadingTx tx ) {
private static CascadingTx createTransaction( final Object obj ) throws RecoverablePersistenceException, RuntimeException {
final String ctx = lookatPersistenceContext( obj );
final CascadingTx ret = new CascadingTx( ctx );
- ret.begin( );
- if ( txRootThreadLocal.get( ) == null ) {
- final String txId = makeTxRootName( ret );
- LOG.trace( "Creating root entry for transaction tree: " + txId + " at: \n" + Threads.currentStackString( ) );
- txRootThreadLocal.set( txId );
+ try {
+ ret.begin( );
+ if ( txRootThreadLocal.get( ) == null ) {
+ final String txId = makeTxRootName( ret );
+ LOG.trace( "Creating root entry for transaction tree: " + txId + " at: \n" + Threads.currentStackString( ) );
+ txRootThreadLocal.set( txId );
+ }
+ txStateThreadLocal.get( ).put( ctx, ret );
+ return ret;
+ } catch ( RuntimeException ex ) {
+ try {
+ ret.rollback( );
+ } catch ( RuntimeException ex1 ) {
+ throw ex1;
+ }
+ throw ex;
}
- txStateThreadLocal.get( ).put( ctx, ret );
- return ret;
}
public static EntityTransaction get( final Object obj ) {
View
77 cluster/handlers.c
@@ -925,7 +925,8 @@ int doAssignAddress(ncMetadata *ccMeta, char *uuid, char *src, char *dst) {
logprintfl(EUCADEBUG, "doAssignAddress(): bad input params\n");
return(1);
}
-
+ set_dirty_instanceCache();
+
sem_mywait(RESCACHE);
memcpy(&resourceCacheLocal, resourceCache, sizeof(ccResourceCache));
sem_mypost(RESCACHE);
@@ -1031,12 +1032,14 @@ int doUnassignAddress(ncMetadata *ccMeta, char *src, char *dst) {
return(1);
}
logprintfl(EUCAINFO,"UnassignAddress(): called \n");
+
logprintfl(EUCADEBUG,"UnassignAddress(): params: userId=%s, src=%s, dst=%s\n", SP(ccMeta ? ccMeta->userId : "UNSET"), SP(src), SP(dst));
if (!src || !dst || !strcmp(src, "0.0.0.0")) {
logprintfl(EUCADEBUG, "UnassignAddress(): bad input params\n");
return(1);
}
+ set_dirty_instanceCache();
sem_mywait(RESCACHE);
memcpy(&resourceCacheLocal, resourceCache, sizeof(ccResourceCache));
@@ -1465,6 +1468,8 @@ int refresh_instances(ncMetadata *ccMeta, int timeout, int dolock) {
op_start = time(NULL);
logprintfl(EUCAINFO,"refresh_instances(): called\n");
+
+ set_clean_instanceCache();
// critical NC call section
sem_mywait(RESCACHE);
@@ -2481,6 +2486,8 @@ int doTerminateInstances(ncMetadata *ccMeta, char **instIds, int instIdsLen, int
if (rc || ccIsEnabled()) {
return(1);
}
+ set_dirty_instanceCache();
+
logprintfl(EUCAINFO,"TerminateInstances(): called \n");
logprintfl(EUCADEBUG,"TerminateInstances(): params: userId=%s, instIdsLen=%d, firstInstId=%s, force=%d\n", SP(ccMeta ? ccMeta->userId : "UNSET"), instIdsLen, SP(instIdsLen ? instIds[0] : "UNSET"), force);
@@ -2539,6 +2546,11 @@ int doTerminateInstances(ncMetadata *ccMeta, char **instIds, int instIdsLen, int
ret = 0;
done++;
}
+ rc = ncClientCall(ccMeta, 0, resourceCacheStage->resources[j].lockidx, resourceCacheStage->resources[j].ncURL, "ncAssignAddress", instId, "0.0.0.0");
+ if (rc) {
+ // problem, but will retry next time
+ logprintfl(EUCAWARN, "TerminateInstances(): could not send AssignAddress to NC\n");
+ }
}
}
}
@@ -3006,28 +3018,36 @@ void *monitor_thread(void *in) {
}
if (ncRefresh) {
+ if (is_clean_instanceCache()) {
// Network state operations
- logprintfl(EUCADEBUG, "monitor_thread(): syncing network state\n");
- rc = syncNetworkState();
- if (rc) {
- logprintfl(EUCADEBUG, "monitor_thread(): syncNetworkState() triggering network restore\n");
- config->kick_network = 1;
- }
-
- if (config->kick_network) {
- logprintfl(EUCADEBUG, "monitor_thread(): restoring network state\n");
- rc = restoreNetworkState();
+ // sem_mywait(RESCACHE);
+
+ logprintfl(EUCADEBUG, "monitor_thread(): syncing network state\n");
+ rc = syncNetworkState();
if (rc) {
- // failed to restore network state, continue
- logprintfl(EUCAWARN, "monitor_thread(): restoreNetworkState returned false (may be already restored)\n");
- } else {
- sem_mywait(CONFIG);
- config->kick_network = 0;
- sem_mypost(CONFIG);
+ logprintfl(EUCADEBUG, "monitor_thread(): syncNetworkState() triggering network restore\n");
+ config->kick_network = 1;
+ }
+ // sem_mypost(RESCACHE);
+
+ if (config->kick_network) {
+ logprintfl(EUCADEBUG, "monitor_thread(): restoring network state\n");
+ rc = restoreNetworkState();
+ if (rc) {
+ // failed to restore network state, continue
+ logprintfl(EUCAWARN, "monitor_thread(): restoreNetworkState returned false (may be already restored)\n");
+ } else {
+ sem_mywait(CONFIG);
+ config->kick_network = 0;
+ sem_mypost(CONFIG);
+ }
}
+ } else {
+ logprintfl(EUCADEBUG, "monitor_thread(): instanceCache is dirty, skipping network update\n");
}
}
+
if (clcRefresh) {
logprintfl(EUCADEBUG, "monitor_thread(): syncing CLC network rules ground truth with local state\n");
rc = reconfigureNetworkFromCLC();
@@ -4584,6 +4604,29 @@ void print_ccInstance(char *tag, ccInstance *in) {
free(groupbuf);
}
+void set_clean_instanceCache(void) {
+ sem_mywait(INSTCACHE);
+ instanceCache->dirty = 0;
+ sem_mypost(INSTCACHE);
+}
+void set_dirty_instanceCache(void) {
+ sem_mywait(INSTCACHE);
+ instanceCache->dirty = 1;
+ sem_mypost(INSTCACHE);
+}
+
+int is_clean_instanceCache(void) {
+ int ret=1;
+ sem_mywait(INSTCACHE);
+ if (instanceCache->dirty) {
+ ret = 0;
+ } else {
+ ret = 1;
+ }
+ sem_mypost(INSTCACHE);
+ return(ret);
+}
+
void invalidate_instanceCache(void) {
int i;
View
4 cluster/handlers.h
@@ -210,6 +210,7 @@ typedef struct ccInstanceCache_t {
int cacheState[MAXINSTANCES];
int numInsts;
int instanceCacheUpdate;
+ int dirty;
} ccInstanceCache;
typedef struct ccConfig_t {
@@ -278,6 +279,9 @@ int find_instanceCacheId(char *instanceId, ccInstance **out);
int find_instanceCacheIP(char *ip, ccInstance **out);
void print_instanceCache(void);
void invalidate_instanceCache(void);
+void set_clean_instanceCache(void);
+void set_dirty_instanceCache(void);
+int is_clean_instanceCache(void);
int map_instanceCache(int (*match)(ccInstance *, void *), void *matchParam, int (*operate)(ccInstance *, void *), void *operateParam);
int privIpCmp(ccInstance *inst, void *ip);
int privIpSet(ccInstance *inst, void *ip);
View
2 util/eucalyptus.h
@@ -129,7 +129,7 @@ permission notice:
#define MAXINSTANCES 2048
#define MAXLOGFILESIZE 32768000
#define EUCA_MAX_GROUPS 64
-#define EUCA_MAX_VOLUMES 256
+#define EUCA_MAX_VOLUMES 64
#define EUCA_MAX_VBRS 64
#define EUCA_MAX_PATH 4096
#define EUCA_MAX_PARTITIONS 32 // partitions per disk

0 comments on commit 84808f2

Please sign in to comment.