diff --git a/datahub-upgrade/src/main/java/com/linkedin/datahub/upgrade/UpgradeReport.java b/datahub-upgrade/src/main/java/com/linkedin/datahub/upgrade/UpgradeReport.java index 27bfc9d8a9..2ed3f105a4 100644 --- a/datahub-upgrade/src/main/java/com/linkedin/datahub/upgrade/UpgradeReport.java +++ b/datahub-upgrade/src/main/java/com/linkedin/datahub/upgrade/UpgradeReport.java @@ -13,6 +13,11 @@ public interface UpgradeReport { */ void addLine(String line); + /** + * Adds a new line to the upgrade report with exception + */ + void addLine(String line, Exception e); + /** * Retrieves the lines in the report. */ diff --git a/datahub-upgrade/src/main/java/com/linkedin/datahub/upgrade/common/steps/ClearGraphServiceStep.java b/datahub-upgrade/src/main/java/com/linkedin/datahub/upgrade/common/steps/ClearGraphServiceStep.java index 49ae629f78..4f980b11b8 100644 --- a/datahub-upgrade/src/main/java/com/linkedin/datahub/upgrade/common/steps/ClearGraphServiceStep.java +++ b/datahub-upgrade/src/main/java/com/linkedin/datahub/upgrade/common/steps/ClearGraphServiceStep.java @@ -49,7 +49,7 @@ public class ClearGraphServiceStep implements UpgradeStep { try { _graphService.clear(); } catch (Exception e) { - context.report().addLine(String.format("Failed to clear graph indices: %s", e.toString())); + context.report().addLine("Failed to clear graph indices", e); return new DefaultUpgradeStepResult(id(), UpgradeStepResult.Result.FAILED); } return new DefaultUpgradeStepResult(id(), UpgradeStepResult.Result.SUCCEEDED); diff --git a/datahub-upgrade/src/main/java/com/linkedin/datahub/upgrade/common/steps/ClearSearchServiceStep.java b/datahub-upgrade/src/main/java/com/linkedin/datahub/upgrade/common/steps/ClearSearchServiceStep.java index 6bdedb3a2c..fca8f60aef 100644 --- a/datahub-upgrade/src/main/java/com/linkedin/datahub/upgrade/common/steps/ClearSearchServiceStep.java +++ b/datahub-upgrade/src/main/java/com/linkedin/datahub/upgrade/common/steps/ClearSearchServiceStep.java @@ -47,7 +47,7 @@ public class ClearSearchServiceStep implements UpgradeStep { try { _entitySearchService.clear(); } catch (Exception e) { - context.report().addLine(String.format("Failed to clear search service: %s", e.toString())); + context.report().addLine("Failed to clear search service", e); return new DefaultUpgradeStepResult(id(), UpgradeStepResult.Result.FAILED); } return new DefaultUpgradeStepResult(id(), UpgradeStepResult.Result.SUCCEEDED); diff --git a/datahub-upgrade/src/main/java/com/linkedin/datahub/upgrade/impl/DefaultUpgradeReport.java b/datahub-upgrade/src/main/java/com/linkedin/datahub/upgrade/impl/DefaultUpgradeReport.java index 70df996047..19706937e2 100644 --- a/datahub-upgrade/src/main/java/com/linkedin/datahub/upgrade/impl/DefaultUpgradeReport.java +++ b/datahub-upgrade/src/main/java/com/linkedin/datahub/upgrade/impl/DefaultUpgradeReport.java @@ -17,6 +17,12 @@ public class DefaultUpgradeReport implements UpgradeReport { reportLines.add(line); } + @Override + public void addLine(String line, Exception e) { + log.error(line, e); + reportLines.add(line + String.format(": %s", e)); + } + @Override public List lines() { return reportLines; diff --git a/datahub-upgrade/src/main/java/com/linkedin/datahub/upgrade/nocode/CreateAspectTableStep.java b/datahub-upgrade/src/main/java/com/linkedin/datahub/upgrade/nocode/CreateAspectTableStep.java index e46f81865e..3b78e95a7b 100644 --- a/datahub-upgrade/src/main/java/com/linkedin/datahub/upgrade/nocode/CreateAspectTableStep.java +++ b/datahub-upgrade/src/main/java/com/linkedin/datahub/upgrade/nocode/CreateAspectTableStep.java @@ -76,7 +76,7 @@ public class CreateAspectTableStep implements UpgradeStep { try { _server.execute(_server.createSqlUpdate(sqlUpdateStr)); } catch (Exception e) { - context.report().addLine(String.format("Failed to create table metadata_aspect_v2: %s", e.toString())); + context.report().addLine("Failed to create table metadata_aspect_v2", e); return new DefaultUpgradeStepResult( id(), UpgradeStepResult.Result.FAILED); diff --git a/datahub-upgrade/src/main/java/com/linkedin/datahub/upgrade/nocode/DataMigrationStep.java b/datahub-upgrade/src/main/java/com/linkedin/datahub/upgrade/nocode/DataMigrationStep.java index 84bed7fc00..689b1fb997 100644 --- a/datahub-upgrade/src/main/java/com/linkedin/datahub/upgrade/nocode/DataMigrationStep.java +++ b/datahub-upgrade/src/main/java/com/linkedin/datahub/upgrade/nocode/DataMigrationStep.java @@ -86,7 +86,7 @@ public class DataMigrationStep implements UpgradeStep { Class.forName(oldAspectName).asSubclass(RecordTemplate.class), oldAspect.getMetadata()); } catch (Exception e) { - context.report().addLine(String.format("Failed to convert aspect with name %s into a RecordTemplate class: %s", oldAspectName, e.getMessage())); + context.report().addLine(String.format("Failed to convert aspect with name %s into a RecordTemplate class", oldAspectName), e); return new DefaultUpgradeStepResult(id(), UpgradeStepResult.Result.FAILED); } @@ -95,7 +95,7 @@ public class DataMigrationStep implements UpgradeStep { try { urn = Urn.createFromString(oldAspect.getKey().getUrn()); } catch (Exception e) { - throw new RuntimeException(String.format("Failed to bind Urn with value %s into Urn object: %s", oldAspect.getKey().getUrn(), e)); + throw new RuntimeException(String.format("Failed to bind Urn with value %s into Urn object", oldAspect.getKey().getUrn()), e); } // 3. Verify that the entity associated with the aspect is found in the registry. @@ -104,7 +104,7 @@ public class DataMigrationStep implements UpgradeStep { try { entitySpec = _entityRegistry.getEntitySpec(entityName); } catch (Exception e) { - context.report().addLine(String.format("Failed to find Entity with name %s in Entity Registry: %s", entityName, e)); + context.report().addLine(String.format("Failed to find Entity with name %s in Entity Registry", entityName), e); return new DefaultUpgradeStepResult(id(), UpgradeStepResult.Result.FAILED); } @@ -113,10 +113,9 @@ public class DataMigrationStep implements UpgradeStep { try { newAspectName = PegasusUtils.getAspectNameFromSchema(aspectRecord.schema()); } catch (Exception e) { - context.report().addLine(String.format("Failed to retrieve @Aspect name from schema %s, urn %s: %s", + context.report().addLine(String.format("Failed to retrieve @Aspect name from schema %s, urn %s", aspectRecord.schema().getFullName(), - entityName, - e)); + entityName), e); return new DefaultUpgradeStepResult(id(), UpgradeStepResult.Result.FAILED); } @@ -125,10 +124,9 @@ public class DataMigrationStep implements UpgradeStep { try { aspectSpec = entitySpec.getAspectSpec(newAspectName); } catch (Exception e) { - context.report().addLine(String.format("Failed to find aspect spec with name %s associated with entity named %s: %s", + context.report().addLine(String.format("Failed to find aspect spec with name %s associated with entity named %s", newAspectName, - entityName, - e)); + entityName), e); return new DefaultUpgradeStepResult(id(), UpgradeStepResult.Result.FAILED); } diff --git a/datahub-upgrade/src/main/java/com/linkedin/datahub/upgrade/nocode/UpgradeQualificationStep.java b/datahub-upgrade/src/main/java/com/linkedin/datahub/upgrade/nocode/UpgradeQualificationStep.java index 66626504b3..ec05f210f0 100644 --- a/datahub-upgrade/src/main/java/com/linkedin/datahub/upgrade/nocode/UpgradeQualificationStep.java +++ b/datahub-upgrade/src/main/java/com/linkedin/datahub/upgrade/nocode/UpgradeQualificationStep.java @@ -45,7 +45,7 @@ public class UpgradeQualificationStep implements UpgradeStep { context.report().addLine("Failed to qualify upgrade candidate. Aborting the upgrade..."); return new DefaultUpgradeStepResult(id(), UpgradeStepResult.Result.SUCCEEDED, UpgradeStepResult.Action.ABORT); } catch (Exception e) { - context.report().addLine(String.format("Failed to check if metadata_aspect_v2 table exists: %s", e.toString())); + context.report().addLine("Failed to check if metadata_aspect_v2 table exists", e); return new DefaultUpgradeStepResult(id(), UpgradeStepResult.Result.FAILED); } }; diff --git a/datahub-upgrade/src/main/java/com/linkedin/datahub/upgrade/nocodecleanup/DeleteAspectTableStep.java b/datahub-upgrade/src/main/java/com/linkedin/datahub/upgrade/nocodecleanup/DeleteAspectTableStep.java index a2e61888bf..2d435cdc28 100644 --- a/datahub-upgrade/src/main/java/com/linkedin/datahub/upgrade/nocodecleanup/DeleteAspectTableStep.java +++ b/datahub-upgrade/src/main/java/com/linkedin/datahub/upgrade/nocodecleanup/DeleteAspectTableStep.java @@ -33,7 +33,7 @@ public class DeleteAspectTableStep implements UpgradeStep { try { _server.execute(_server.createSqlUpdate("DROP TABLE IF EXISTS metadata_aspect;")); } catch (Exception e) { - context.report().addLine(String.format("Failed to delete data from legacy table metadata_aspect: %s", e.toString())); + context.report().addLine("Failed to delete data from legacy table metadata_aspect", e); return new DefaultUpgradeStepResult( id(), UpgradeStepResult.Result.FAILED); diff --git a/datahub-upgrade/src/main/java/com/linkedin/datahub/upgrade/nocodecleanup/DeleteLegacyGraphRelationshipsStep.java b/datahub-upgrade/src/main/java/com/linkedin/datahub/upgrade/nocodecleanup/DeleteLegacyGraphRelationshipsStep.java index 481554a3ce..43870f26b1 100644 --- a/datahub-upgrade/src/main/java/com/linkedin/datahub/upgrade/nocodecleanup/DeleteLegacyGraphRelationshipsStep.java +++ b/datahub-upgrade/src/main/java/com/linkedin/datahub/upgrade/nocodecleanup/DeleteLegacyGraphRelationshipsStep.java @@ -36,7 +36,7 @@ public class DeleteLegacyGraphRelationshipsStep implements UpgradeStep { try { ((Neo4jGraphService) _graphClient).removeNodesMatchingLabel(deletePattern); } catch (Exception e) { - context.report().addLine(String.format("Failed to delete legacy data from graph: %s", e.toString())); + context.report().addLine("Failed to delete legacy data from graph", e); return new DefaultUpgradeStepResult( id(), UpgradeStepResult.Result.FAILED); diff --git a/datahub-upgrade/src/main/java/com/linkedin/datahub/upgrade/nocodecleanup/DeleteLegacySearchIndicesStep.java b/datahub-upgrade/src/main/java/com/linkedin/datahub/upgrade/nocodecleanup/DeleteLegacySearchIndicesStep.java index fb0212e591..15bbe40d1e 100644 --- a/datahub-upgrade/src/main/java/com/linkedin/datahub/upgrade/nocodecleanup/DeleteLegacySearchIndicesStep.java +++ b/datahub-upgrade/src/main/java/com/linkedin/datahub/upgrade/nocodecleanup/DeleteLegacySearchIndicesStep.java @@ -42,7 +42,7 @@ public class DeleteLegacySearchIndicesStep implements UpgradeStep { try { _searchClient.indices().delete(request, RequestOptions.DEFAULT); } catch (Exception e) { - context.report().addLine(String.format("Failed to delete legacy search index: %s", e.toString())); + context.report().addLine("Failed to delete legacy search index: %s", e); return new DefaultUpgradeStepResult(id(), UpgradeStepResult.Result.FAILED); } return new DefaultUpgradeStepResult(id(), UpgradeStepResult.Result.SUCCEEDED); diff --git a/datahub-upgrade/src/main/java/com/linkedin/datahub/upgrade/nocodecleanup/NoCodeUpgradeQualificationStep.java b/datahub-upgrade/src/main/java/com/linkedin/datahub/upgrade/nocodecleanup/NoCodeUpgradeQualificationStep.java index c6f1aeb6e7..52e299d68b 100644 --- a/datahub-upgrade/src/main/java/com/linkedin/datahub/upgrade/nocodecleanup/NoCodeUpgradeQualificationStep.java +++ b/datahub-upgrade/src/main/java/com/linkedin/datahub/upgrade/nocodecleanup/NoCodeUpgradeQualificationStep.java @@ -46,7 +46,7 @@ public class NoCodeUpgradeQualificationStep implements UpgradeStep { UpgradeStepResult.Result.SUCCEEDED); } } catch (Exception e) { - context.report().addLine(String.format("Failed to check if metadata_aspect_v2 table exists: %s", e.toString())); + context.report().addLine("Failed to check if metadata_aspect_v2 table exists: %s", e); return new DefaultUpgradeStepResult( id(), UpgradeStepResult.Result.FAILED); diff --git a/datahub-upgrade/src/main/java/com/linkedin/datahub/upgrade/restorebackup/RestoreStorageStep.java b/datahub-upgrade/src/main/java/com/linkedin/datahub/upgrade/restorebackup/RestoreStorageStep.java index a17a878361..f22a52c487 100644 --- a/datahub-upgrade/src/main/java/com/linkedin/datahub/upgrade/restorebackup/RestoreStorageStep.java +++ b/datahub-upgrade/src/main/java/com/linkedin/datahub/upgrade/restorebackup/RestoreStorageStep.java @@ -138,7 +138,7 @@ public class RestoreStorageStep implements UpgradeStep { } catch (Exception e) { context.report() .addLine( - String.format("Failed to bind Urn with value %s into Urn object: %s", aspect.getKey().getUrn(), e)); + String.format("Failed to bind Urn with value %s into Urn object", aspect.getKey().getUrn()), e); continue; } @@ -149,7 +149,7 @@ public class RestoreStorageStep implements UpgradeStep { entitySpec = _entityRegistry.getEntitySpec(entityName); } catch (Exception e) { context.report() - .addLine(String.format("Failed to find Entity with name %s in Entity Registry: %s", entityName, e)); + .addLine(String.format("Failed to find Entity with name %s in Entity Registry", entityName), e); continue; } final String aspectName = aspect.getKey().getAspect(); @@ -161,8 +161,8 @@ public class RestoreStorageStep implements UpgradeStep { EntityUtils.toAspectRecord(entityName, aspectName, aspect.getMetadata(), _entityRegistry); } catch (Exception e) { context.report() - .addLine(String.format("Failed to create aspect record with name %s associated with entity named %s: %s", - aspectName, entityName, e)); + .addLine(String.format("Failed to create aspect record with name %s associated with entity named %s", + aspectName, entityName), e); continue; } @@ -172,8 +172,8 @@ public class RestoreStorageStep implements UpgradeStep { aspectSpec = entitySpec.getAspectSpec(aspectName); } catch (Exception e) { context.report() - .addLine(String.format("Failed to find aspect spec with name %s associated with entity named %s: %s", - aspectName, entityName, e)); + .addLine(String.format("Failed to find aspect spec with name %s associated with entity named %s", + aspectName, entityName), e); continue; }