Skip to content

Commit

Permalink
Fix checking of passed arguments to ensure rollback works correctly. …
Browse files Browse the repository at this point in the history
…Related to EUCA-4250.
  • Loading branch information
chris grzegorczyk committed Dec 8, 2012
1 parent 7354bab commit d47e18e
Showing 1 changed file with 13 additions and 2 deletions.
Expand Up @@ -331,7 +331,7 @@ public static Version getLastUpgradedVersion( ) {
}

private static boolean create( ) {
if ( !Databases.getBootstrapper( ).listTables( Databases.Events.INSTANCE.getName( ) ).contains( UpgradeEventLog.INSTANCE.tableName ) ) {
if ( !exists( ) ) {
Sql sql = null;
try {
sql = Databases.Events.getConnection( );
Expand All @@ -349,6 +349,10 @@ private static boolean create( ) {
return false;
}
}

public static boolean exists( ) {
return Databases.getBootstrapper( ).listTables( Databases.Events.INSTANCE.getName( ) ).contains( UpgradeEventLog.INSTANCE.tableName );
}
}

@RunDuring( Bootstrap.Stage.UpgradeDatabase )
Expand Down Expand Up @@ -450,6 +454,12 @@ public String getVersionedName( String origName ) {
*/
enum UpgradeState implements Callable<Boolean> {
START {
@Override
public boolean callAndLog( ) throws Exception {
return this.call( );
}
},
PARSE_ARGS {

@Override
public boolean callAndLog( ) throws Exception {
Expand All @@ -474,7 +484,7 @@ public boolean callAndLog( ) throws Exception {

@Override
public Boolean call( ) throws Exception {
if ( BootstrapArgs.isCloudController( ) && BootstrapArgs.isUpgradeSystem( ) ) {
if ( BootstrapArgs.isCloudController( ) && ( BootstrapArgs.isUpgradeSystem( ) || !UpgradeEventLog.exists( ) ) ) {
return true;
} else {
return false;
Expand Down Expand Up @@ -524,6 +534,7 @@ public Boolean call( ) throws Exception {
boolean continueUpgrade = false;
switch ( previousState ) {
case START:
case PARSE_ARGS:
case CHECK_ARGS:
case CHECK_UPGRADE_LOG:
case PRE_SCHEMA_UPDATE:
Expand Down

0 comments on commit d47e18e

Please sign in to comment.