This is an automated email from the ASF dual-hosted git repository.
nanda pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/ozone.git
The following commit(s) were added to refs/heads/master by this push:
new cb313f6b67 HDDS-10272. Container Report admin command displays
incorrect value immediately after SCM restart (#6148)
cb313f6b67 is described below
commit cb313f6b67a59b5690bd636639e693968ce9bc08
Author: Stephen O'Donnell <[email protected]>
AuthorDate: Sun Feb 4 14:29:49 2024 +0000
HDDS-10272. Container Report admin command displays incorrect value
immediately after SCM restart (#6148)
---
.../hdds/scm/cli/container/ReportSubcommand.java | 8 +++++++-
.../hdds/scm/cli/container/TestReportSubCommand.java | 18 ++++++++++++------
2 files changed, 19 insertions(+), 7 deletions(-)
diff --git
a/hadoop-hdds/tools/src/main/java/org/apache/hadoop/hdds/scm/cli/container/ReportSubcommand.java
b/hadoop-hdds/tools/src/main/java/org/apache/hadoop/hdds/scm/cli/container/ReportSubcommand.java
index 554316c2e9..7ef34236bf 100644
---
a/hadoop-hdds/tools/src/main/java/org/apache/hadoop/hdds/scm/cli/container/ReportSubcommand.java
+++
b/hadoop-hdds/tools/src/main/java/org/apache/hadoop/hdds/scm/cli/container/ReportSubcommand.java
@@ -52,6 +52,10 @@ public class ReportSubcommand extends ScmSubcommand {
@Override
public void execute(ScmClient scmClient) throws IOException {
ReplicationManagerReport report = scmClient.getReplicationManagerReport();
+ if (report.getReportTimeStamp() == 0) {
+ System.err.println("The Container Report is not available until
Replication Manager completes" +
+ " its first run after startup or fail over. All values will be zero
until that time.\n");
+ }
if (json) {
output(JsonUtils.toJsonStringWithDefaultPrettyPrinter(report));
@@ -68,9 +72,11 @@ public class ReportSubcommand extends ScmSubcommand {
}
private void outputHeader(long epochMs) {
+ if (epochMs == 0) {
+ epochMs = Instant.now().toEpochMilli();
+ }
Instant reportTime = Instant.ofEpochSecond(epochMs / 1000);
outputHeading("Container Summary Report generated at " + reportTime);
-
}
private void outputContainerStats(ReplicationManagerReport report) {
diff --git
a/hadoop-hdds/tools/src/test/java/org/apache/hadoop/hdds/scm/cli/container/TestReportSubCommand.java
b/hadoop-hdds/tools/src/test/java/org/apache/hadoop/hdds/scm/cli/container/TestReportSubCommand.java
index 58eeaee3d2..87d88617e7 100644
---
a/hadoop-hdds/tools/src/test/java/org/apache/hadoop/hdds/scm/cli/container/TestReportSubCommand.java
+++
b/hadoop-hdds/tools/src/test/java/org/apache/hadoop/hdds/scm/cli/container/TestReportSubCommand.java
@@ -74,18 +74,20 @@ public class TestReportSubCommand {
cmd.execute(scmClient);
+ Pattern p = Pattern.compile("^The Container Report is not available until
Replication Manager completes.*");
+ Matcher m = p.matcher(errContent.toString(DEFAULT_ENCODING));
+ assertTrue(m.find());
+
for (HddsProtos.LifeCycleState state : HddsProtos.LifeCycleState.values())
{
- Pattern p = Pattern.compile(
- "^" + state.toString() + ": 0$", Pattern.MULTILINE);
- Matcher m = p.matcher(outContent.toString(DEFAULT_ENCODING));
+ p = Pattern.compile("^" + state.toString() + ": 0$", Pattern.MULTILINE);
+ m = p.matcher(outContent.toString(DEFAULT_ENCODING));
assertTrue(m.find());
}
for (ReplicationManagerReport.HealthState state :
ReplicationManagerReport.HealthState.values()) {
- Pattern p = Pattern.compile(
- "^" + state.toString() + ": 0$", Pattern.MULTILINE);
- Matcher m = p.matcher(outContent.toString(DEFAULT_ENCODING));
+ p = Pattern.compile("^" + state.toString() + ": 0$", Pattern.MULTILINE);
+ m = p.matcher(outContent.toString(DEFAULT_ENCODING));
assertTrue(m.find());
}
}
@@ -101,6 +103,10 @@ public class TestReportSubCommand {
c.parseArgs("--json");
cmd.execute(scmClient);
+ Pattern p = Pattern.compile("^The Container Report is not available until
Replication Manager completes.*");
+ Matcher m = p.matcher(errContent.toString(DEFAULT_ENCODING));
+ assertTrue(m.find());
+
ObjectMapper mapper = new ObjectMapper();
JsonNode json = mapper.readTree(outContent.toString("UTF-8"));
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]