summaryrefslogtreecommitdiffstats
path: root/adapters/mso-openstack-adapters
diff options
context:
space:
mode:
authorRob Daugherty <rd472p@att.com>2018-08-21 18:42:55 -0400
committerRob Daugherty <rd472p@att.com>2018-08-21 18:42:55 -0400
commit5bea41b162b9c4d6a24640790028fa7750ff15f3 (patch)
tree72f3853aa6bde8806e24ea86e89ccda448d53ddf /adapters/mso-openstack-adapters
parent539776c6a387e25f0c428be1f8c6912d94c50e88 (diff)
openstack_adapter container fails to start
The reported problem occurs because the openstack-adapters app is attempting to do a migration on top of a migration already performed by the catalog-db app. I'm adding these options to flyway in openstack-adapters: baseline-on-migrate: true validate-on-migrate: false Another issue is that the java-based CloudConfig migration class was looking for CloudConfig data only in the application.yaml file in the classpath. It was not looking for CloudConfig data in the override file. I've changed this logic to look in the override file first and then in application.yaml. Ideally, these sources would be merged, but I don't see a reasonable way to do it. Change-Id: I7ba07c1f8f00b4c628e825393ee31502950fe592 Issue-ID: SO-868 Signed-off-by: Rob Daugherty <rd472p@att.com>
Diffstat (limited to 'adapters/mso-openstack-adapters')
-rw-r--r--adapters/mso-openstack-adapters/src/main/java/db/migration/R__CloudConfigMigration.java40
-rw-r--r--adapters/mso-openstack-adapters/src/main/resources/application.yaml4
2 files changed, 35 insertions, 9 deletions
diff --git a/adapters/mso-openstack-adapters/src/main/java/db/migration/R__CloudConfigMigration.java b/adapters/mso-openstack-adapters/src/main/java/db/migration/R__CloudConfigMigration.java
index fd2ec179dc..87ea49ee5e 100644
--- a/adapters/mso-openstack-adapters/src/main/java/db/migration/R__CloudConfigMigration.java
+++ b/adapters/mso-openstack-adapters/src/main/java/db/migration/R__CloudConfigMigration.java
@@ -13,6 +13,8 @@ import org.onap.so.db.catalog.beans.CloudSite;
import org.onap.so.db.catalog.beans.CloudifyManager;
import org.onap.so.logger.MsoLogger;
+import java.io.FileInputStream;
+import java.io.InputStream;
import java.sql.Connection;
import java.sql.PreparedStatement;
import java.sql.ResultSet;
@@ -33,10 +35,31 @@ public class R__CloudConfigMigration implements JdbcMigration , MigrationInfoPro
@Override
public void migrate(Connection connection) throws Exception {
LOGGER.debug("Starting migration for CloudConfig");
- CloudConfig cloudConfig = loadCloudConfig();
- if(cloudConfig == null){
- LOGGER.debug("No CloudConfig defined in :"+getApplicationYamlName()+" exiting.");
- }else{
+
+ CloudConfig cloudConfig = null;
+
+ // Try the override file
+ String configLocation = System.getProperty("spring.config.location");
+ if (configLocation != null) {
+ try (InputStream stream = new FileInputStream(configLocation)) {
+ cloudConfig = loadCloudConfig(stream);
+ }
+ }
+
+ if (cloudConfig == null) {
+ LOGGER.debug("No CloudConfig defined in " + configLocation);
+
+ // Try the application.yaml file
+ try (InputStream stream = R__CloudConfigMigration.class.getResourceAsStream(getApplicationYamlName())) {
+ cloudConfig = loadCloudConfig(stream);
+ }
+
+ if (cloudConfig == null) {
+ LOGGER.debug("No CloudConfig defined in " + getApplicationYamlName());
+ }
+ }
+
+ if(cloudConfig != null){
migrateCloudIdentity(cloudConfig.getIdentityServices().values(), connection);
migrateCloudSite(cloudConfig.getCloudSites().values(), connection);
migrateCloudifyManagers(cloudConfig.getCloudifyManagers().values(), connection);
@@ -51,13 +74,14 @@ public class R__CloudConfigMigration implements JdbcMigration , MigrationInfoPro
this.cloudConfig = cloudConfig;
}
- private CloudConfig loadCloudConfig() throws Exception {
+ private CloudConfig loadCloudConfig(InputStream stream) throws Exception {
ObjectMapper mapper = new ObjectMapper(new YAMLFactory());
- R__CloudConfigMigration cloudConfigMigration = mapper.readValue(R__CloudConfigMigration.class
- .getResourceAsStream(getApplicationYamlName()), R__CloudConfigMigration.class);
+ R__CloudConfigMigration cloudConfigMigration =
+ mapper.readValue(stream, R__CloudConfigMigration.class);
CloudConfig cloudConfig = cloudConfigMigration.getCloudConfig();
+
if(cloudConfig != null){
- cloudConfig.populateId();
+ cloudConfig.populateId();
}
return cloudConfig;
diff --git a/adapters/mso-openstack-adapters/src/main/resources/application.yaml b/adapters/mso-openstack-adapters/src/main/resources/application.yaml
index 4a4c83e4a5..4b2cf8eb60 100644
--- a/adapters/mso-openstack-adapters/src/main/resources/application.yaml
+++ b/adapters/mso-openstack-adapters/src/main/resources/application.yaml
@@ -41,4 +41,6 @@ management:
flyway:
outOfOrder: true
- ignoreMissingMigrations: true \ No newline at end of file
+ ignoreMissingMigrations: true
+ baseline-on-migrate: true
+ validate-on-migrate: false