Thanks Ming Ma for review and comments.
When pendingContainerInThisCycle is empty, NM will skip sending the LogAggregationReport with LogAggregationStatus.RUNNING. It means for a long running service, it is possible for a yarn client to get LogAggregationStatus.NOT_START when it calls ApplicationClientProtocol#getApplicationReport if the long running service doesn't generate any log. Without the patch, NM will send LogAggregationStatus.RUNNING regardless. So it might be better to still send LogAggregationStatus.RUNNING regardless.
Yes, it is a different behavior actually. LogAggregationReport is a report for current status, is it necessary to send a report if NM has not done log aggregation actually?
BTW: I noticed that there is no cleanup for previous LogAggregationReport, there is only 'this.context.getLogAggregationStatusForApps().add()' and no 'remove', is it a deliberate action?
When LogWriter creation throws exception and appFinished is true, NM will send a LogAggregationReport with LogAggregationStatus.SUCCEEDED. Without the patch, NM won't send any final LogAggregationReport. Maybe it is better to update the patch to send LogAggregationStatus.FAILED for such scenario.
I will update the patch to address it.