mirror of
https://github.com/datahub-project/datahub.git
synced 2025-12-24 08:28:12 +00:00
chore(log): fix log as error instead of info (#8146)
This commit is contained in:
parent
a29b576daa
commit
0b0e4997bf
@ -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.
|
||||
*/
|
||||
|
||||
@ -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);
|
||||
|
||||
@ -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);
|
||||
|
||||
@ -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<String> lines() {
|
||||
return reportLines;
|
||||
|
||||
@ -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);
|
||||
|
||||
@ -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);
|
||||
}
|
||||
|
||||
|
||||
@ -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);
|
||||
}
|
||||
};
|
||||
|
||||
@ -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);
|
||||
|
||||
@ -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);
|
||||
|
||||
@ -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);
|
||||
|
||||
@ -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);
|
||||
|
||||
@ -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;
|
||||
}
|
||||
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user