Skip to content

Commit

Permalink
add attention banner to upgrade errors
Browse files Browse the repository at this point in the history
  • Loading branch information
lmossman committed Nov 11, 2021
1 parent 9d05b1c commit 5b43c00
Show file tree
Hide file tree
Showing 3 changed files with 33 additions and 11 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@
import io.airbyte.analytics.TrackingClient;
import io.airbyte.api.model.LogRead;
import io.airbyte.commons.json.Jsons;
import io.airbyte.commons.resources.MoreResources;
import io.airbyte.commons.version.AirbyteVersion;
import io.airbyte.config.ConfigSchema;
import io.airbyte.config.Configs;
Expand Down Expand Up @@ -188,13 +189,17 @@ static void migrateAllDefinitionsToContainSpec(final ConfigRepository configRepo
}

if (failedBackfillImages.size() > 0 && !configs.getVersion31ForceUpgrade()) {
throw new RuntimeException(String.format(
"migrateAllDefinitionsToContainSpec - Specs could not be retrieved for the following connector images: %s. Upgrading to version %s "
final String attentionBanner = MoreResources.readResource("banner/attention-banner.txt");
LOGGER.error(attentionBanner);
final String errorMessage = String.format(
"Specs could not be retrieved for the following connector images: %s. Upgrading to version %s "
+ "requires specs to be retrieved for all connector definitions, so you must either fix the images or restart the deployment with "
+ "the VERSION_0_31_0_FORCE_UPGRADE environment variable set to true, which will cause any connector definitions for which specs "
+ "cannot be retrieved to be deleted, as well as their associated connections/syncs.",
failedBackfillImages.toString(),
VERSION_BREAK));
VERSION_BREAK);
LOGGER.error(errorMessage);
throw new RuntimeException(errorMessage);
}
}

Expand Down
20 changes: 12 additions & 8 deletions airbyte-server/src/main/java/io/airbyte/server/ServerApp.java
Original file line number Diff line number Diff line change
Expand Up @@ -74,8 +74,9 @@ public class ServerApp implements ServerRunnable {
private static final AirbyteVersion VERSION_BREAK = new AirbyteVersion("0.31.0-alpha");

/**
* We can't support automatic migration for kube before this version because we had a bug in kube which would cause airbyte db to erase state upon
* termination, as a result the automatic migration wouldn't run
* We can't support automatic migration for kube before this version because we had a bug in kube
* which would cause airbyte db to erase state upon termination, as a result the automatic migration
* wouldn't run
*/
private static final AirbyteVersion KUBE_SUPPORT_FOR_AUTOMATIC_MIGRATION = new AirbyteVersion("0.26.5-alpha");
private final AirbyteVersion airbyteVersion;
Expand Down Expand Up @@ -171,7 +172,7 @@ public static ServerRunnable getServer(final ServerFactory apiFactory, final Con
configs.getConfigDatabaseUser(),
configs.getConfigDatabasePassword(),
configs.getConfigDatabaseUrl())
.getAndInitialize();
.getAndInitialize();
final DatabaseConfigPersistence configPersistence = new DatabaseConfigPersistence(configDatabase).migrateFileConfigs(configs);

final SecretsHydrator secretsHydrator = SecretPersistence.getSecretsHydrator(configs);
Expand All @@ -186,7 +187,7 @@ public static ServerRunnable getServer(final ServerFactory apiFactory, final Con
configs.getDatabaseUser(),
configs.getDatabasePassword(),
configs.getDatabaseUrl())
.getAndInitialize();
.getAndInitialize();
final JobPersistence jobPersistence = new DefaultJobPersistence(jobDatabase);

createDeploymentIfNoneExists(jobPersistence);
Expand Down Expand Up @@ -235,6 +236,8 @@ public static ServerRunnable getServer(final ServerFactory apiFactory, final Con
final HttpClient httpClient = HttpClient.newBuilder().version(HttpClient.Version.HTTP_1_1).build();

if (!isLegalUpgrade(airbyteDatabaseVersion.orElse(null), airbyteVersion)) {
final String attentionBanner = MoreResources.readResource("banner/attention-banner.txt");
LOGGER.error(attentionBanner);
final String message = String.format(
"Cannot upgrade from version %s to version %s directly. First you must upgrade to version %s. After that upgrade is complete, you may upgrade to version %s",
airbyteDatabaseVersion.get(),
Expand Down Expand Up @@ -299,11 +302,11 @@ static boolean isLegalUpgrade(final AirbyteVersion airbyteDatabaseVersion, final
}

/**
* Check to see if given the current version of the app and the version we are trying to upgrade if it passes through a version break (i.e. a major
* version bump).
* Check to see if given the current version of the app and the version we are trying to upgrade if
* it passes through a version break (i.e. a major version bump).
*
* @param airbyteDatabaseVersion - current version of the app
* @param airbyteVersion - version we are trying to upgrade to
* @param airbyteVersion - version we are trying to upgrade to
* @return true if upgrading through a major version, otherwise false.
*/
private static boolean isUpgradingThroughVersionBreak(final AirbyteVersion airbyteDatabaseVersion, final AirbyteVersion airbyteVersion) {
Expand Down Expand Up @@ -344,7 +347,8 @@ public static void main(final String[] args) throws Exception {
}

/**
* Ideally when automatic migration runs, we should make sure that we acquire a lock on database and no other operation is allowed
* Ideally when automatic migration runs, we should make sure that we acquire a lock on database and
* no other operation is allowed
*/
private static void runAutomaticMigration(final ConfigRepository configRepository,
final JobPersistence jobPersistence,
Expand Down
13 changes: 13 additions & 0 deletions airbyte-server/src/main/resources/banner/attention-banner.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
___ ___________________ ________________ _ __
/ |/_ __/_ __/ ____/ | / /_ __/ _/ __ \/ | / /
________________________ / /| | / / / / / __/ / |/ / / / / // / / / |/ / ________________________
/_____/_____/_____/_____/ / ___ |/ / / / / /___/ /| / / / _/ // /_/ / /| / /_____/_____/_____/_____/
__ _______ __________ /_/ _|_/_/ _/_/_/_____/_/_|_/_/_/ /___/\____/_/_|_/ __ __________ __________
/ / / / ___// ____/ __ \ / _/ | / / __ \/ / / /_ __/ / __ \/ ____/ __ \/ / / / _/ __ \/ ____/ __ \
/ / / /\__ \/ __/ / /_/ / / // |/ / /_/ / / / / / / / /_/ / __/ / / / / / / // // /_/ / __/ / / / /
/ /_/ /___/ / /___/ _, _/ _/ // /| / ____/ /_/ / / / / _, _/ /___/ /_/ / /_/ // // _, _/ /___/ /_/ /
\____//____/_____/_/ |_| /___/_/ |_/_/ \____/ /_/ /_/ |_/_____/\___\_\____/___/_/ |_/_____/_____/

-------------------
See details below
-------------------

0 comments on commit 5b43c00

Please sign in to comment.