Skip to content

Commit

Permalink
fix(osc): fix old running task throw npe when enable full verify (#173)
Browse files Browse the repository at this point in the history
* 1.fix oms check data inconsistent, osc task not failed
2.clean up password in log when create oms log failed

* cleanUpSensitiveMsgInRequest

* optimize log
  • Loading branch information
krihy authored Sep 6, 2023
1 parent 561828a commit c1f5d7b
Show file tree
Hide file tree
Showing 3 changed files with 23 additions and 7 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -140,7 +140,7 @@ public void init() {

terminalErrorCodes = Lists.newArrayList(ErrorCodes.BadArgument, ErrorCodes.BadRequest,
ErrorCodes.OmsConnectivityTestFailed, ErrorCodes.Unexpected,
ErrorCodes.OmsPreCheckFailed, ErrorCodes.OscDataCheckInconsistent,
ErrorCodes.OmsPreCheckFailed, ErrorCodes.OmsDataCheckInconsistent,
ErrorCodes.OmsParamError);

expectedTaskStatus = Lists.newArrayList(TaskStatus.DONE, TaskStatus.FAILED,
Expand Down Expand Up @@ -320,20 +320,18 @@ private void continueComplete(Long scheduleId, Long scheduleTaskId) {
}
} catch (Exception e) {
log.warn("Failed to complete osc job with scheduleTaskId " + scheduleTaskId, e);
handleExceptionResult(scheduleTaskId, valveContext, e);
handleExceptionResult(valveContext, e);
}
}

private void handleExceptionResult(Long scheduleTaskId, OscValveContext valveContext, Exception e) {
private void handleExceptionResult(OscValveContext valveContext, Exception e) {
if (e instanceof OdcException) {
OdcException actual = (OdcException) e;
ErrorCode errorCode = actual.getErrorCode();
if (terminalErrorCodes.contains(errorCode)) {
log.warn("Failed to complete osc job with scheduleTaskId " + scheduleTaskId, e);
failedOscTask(valveContext);
}
} else {
log.warn("Failed to complete osc job with scheduleTaskId " + scheduleTaskId, e);
failedOscTask(valveContext);
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@
import java.text.MessageFormat;
import java.util.Objects;

import org.springframework.beans.BeanUtils;
import org.springframework.http.HttpEntity;
import org.springframework.http.HttpHeaders;
import org.springframework.http.HttpMethod;
Expand All @@ -36,6 +37,7 @@
import com.oceanbase.odc.core.shared.exception.UnexpectedException;
import com.oceanbase.odc.service.onlineschemachange.exception.OmsException;
import com.oceanbase.odc.service.onlineschemachange.oms.request.BaseOmsRequest;
import com.oceanbase.odc.service.onlineschemachange.oms.request.CreateOceanBaseDataSourceRequest;
import com.oceanbase.odc.service.onlineschemachange.oms.request.OmsApiReturnResult;

import lombok.extern.slf4j.Slf4j;
Expand Down Expand Up @@ -115,6 +117,7 @@ private <T> void resolveFailedResult(ClientRequestParams requestParams, Response
if (result.isSuccess()) {
return;
}
cleanUpSensitiveMsgInRequest(requestParams);
String msg = MessageFormat.format(
"Failed response oms result,Action={0}, Request Params={1}, Response={2}",
requestParams.getAction(), JsonUtils.toJson(requestParams.getRequest()), result);
Expand All @@ -135,6 +138,19 @@ private <T> void resolveFailedResult(ClientRequestParams requestParams, Response
responseEntity.getStatusCode());
}

private void cleanUpSensitiveMsgInRequest(ClientRequestParams requestParams) {
if ("CreateOceanBaseDataSource".equals(requestParams.getAction())
&& requestParams.getRequest() instanceof CreateOceanBaseDataSourceRequest) {
CreateOceanBaseDataSourceRequest request = (CreateOceanBaseDataSourceRequest) requestParams.getRequest();
CreateOceanBaseDataSourceRequest copiedRequest = new CreateOceanBaseDataSourceRequest();
BeanUtils.copyProperties(request, copiedRequest);
// Clean password in log
copiedRequest.setPassword(null);
copiedRequest.setDrcPassword(null);
requestParams.setRequest(copiedRequest);
}
}

protected abstract void setHttpHeaders(HttpHeaders httpHeaders);

}
Original file line number Diff line number Diff line change
Expand Up @@ -251,8 +251,10 @@ private void fillMigrateResult() {
if (enableFullVerify) {
// Set full verifier process percentage
ProjectStepVO fullVerifyStep = currentProjectStepMap.get(OmsStepName.FULL_VERIFIER);
checkerResult.setFullVerificationProgressPercentage(
BigDecimal.valueOf(fullVerifyStep.getProgress()).doubleValue());
if (fullVerifyStep != null && fullVerifyStep.getProgress() != null) {
checkerResult.setFullVerificationProgressPercentage(
BigDecimal.valueOf(fullVerifyStep.getProgress()).doubleValue());
}
}

}
Expand Down

0 comments on commit c1f5d7b

Please sign in to comment.