chore(log): fix log as error instead of info (#8146)

This commit is contained in:
Aseem Bansal 2023-05-31 15:30:50 +05:30 committed by GitHub
parent a29b576daa
commit 0b0e4997bf
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
12 changed files with 32 additions and 23 deletions

View File

@ -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.
*/

View File

@ -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);

View File

@ -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);

View File

@ -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;

View File

@ -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);

View File

@ -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);
}

View File

@ -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);
}
};

View File

@ -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);

View File

@ -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);

View File

@ -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);

View File

@ -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);

View File

@ -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;
}