Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -450,6 +450,8 @@ StatusAndMessages queryUpgradeFinalizationProgress(
String upgradeClientID, boolean force, boolean readonly)
throws IOException;

HddsProtos.UpgradeStatus queryUpgradeStatus() throws IOException;

DecommissionScmResponseProto decommissionScm(
String scmId) throws IOException;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -484,6 +484,8 @@ StatusAndMessages queryUpgradeFinalizationProgress(
String upgradeClientID, boolean force, boolean readonly)
throws IOException;

HddsProtos.UpgradeStatus queryUpgradeStatus() throws IOException;

/**
* Obtain a token which can be used to let datanodes verify authentication of
* commands operating on {@code containerID}.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -1151,6 +1151,19 @@ public StatusAndMessages queryUpgradeFinalizationProgress(
status.getMessagesList());
}

@Override
public HddsProtos.UpgradeStatus queryUpgradeStatus() throws IOException {
StorageContainerLocationProtocolProtos.QueryUpgradeStatusRequestProto req =
StorageContainerLocationProtocolProtos.QueryUpgradeStatusRequestProto
.newBuilder()
.build();

StorageContainerLocationProtocolProtos.QueryUpgradeStatusResponseProto response =
submitRequest(Type.QueryUpgradeStatus, builder -> builder.setQueryUpgradeStatusRequest(req))
.getQueryUpgradeStatusResponse();
return response.getStatus();
}

@Override
public Token<?> getContainerToken(
ContainerID containerID) throws IOException {
Expand Down
10 changes: 10 additions & 0 deletions hadoop-hdds/interface-admin/src/main/proto/ScmAdminProtocol.proto
Original file line number Diff line number Diff line change
Expand Up @@ -87,6 +87,7 @@ message ScmContainerLocationRequest {
optional ContainerBalancerStatusInfoRequestProto containerBalancerStatusInfoRequest = 48;
optional ReconcileContainerRequestProto reconcileContainerRequest = 49;
optional GetDeletedBlocksTxnSummaryRequestProto getDeletedBlocksTxnSummaryRequest = 50;
optional QueryUpgradeStatusRequestProto queryUpgradeStatusRequest = 51;
}

message ScmContainerLocationResponse {
Expand Down Expand Up @@ -145,6 +146,7 @@ message ScmContainerLocationResponse {
optional ContainerBalancerStatusInfoResponseProto containerBalancerStatusInfoResponse = 48;
optional ReconcileContainerResponseProto reconcileContainerResponse = 49;
optional GetDeletedBlocksTxnSummaryResponseProto getDeletedBlocksTxnSummaryResponse = 50;
optional QueryUpgradeStatusResponseProto queryUpgradeStatusResponse = 51;

enum Status {
OK = 1;
Expand Down Expand Up @@ -202,6 +204,7 @@ enum Type {
GetContainerBalancerStatusInfo = 44;
ReconcileContainer = 45;
GetDeletedBlocksTransactionSummary = 46;
QueryUpgradeStatus = 47;
}

/**
Expand Down Expand Up @@ -570,6 +573,13 @@ message QueryUpgradeFinalizationProgressResponseProto {
required hadoop.hdds.UpgradeFinalizationStatus status = 1;
}

message QueryUpgradeStatusRequestProto {
}

message QueryUpgradeStatusResponseProto {
required hadoop.hdds.UpgradeStatus status = 1;
}

message ContainerTokenSecretProto {
required string ownerId = 1;
required ContainerID containerId = 2;
Expand Down
7 changes: 7 additions & 0 deletions hadoop-hdds/interface-client/src/main/proto/hdds.proto
Original file line number Diff line number Diff line change
Expand Up @@ -426,6 +426,13 @@ message UpgradeFinalizationStatus {
repeated string messages = 2;
}

message UpgradeStatus {
optional bool scmFinalized = 1;
optional int32 numDatanodesFinalized = 2;
optional int32 numDatanodesTotal = 3;
optional bool shouldFinalize = 4;
}

/**
* Information for Certificate Revocation List.
*/
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -748,6 +748,12 @@ public ScmContainerLocationResponse processRequest(
.setStatus(Status.OK)
.setReconcileContainerResponse(reconcileContainer(request.getReconcileContainerRequest()))
.build();
case QueryUpgradeStatus:
return ScmContainerLocationResponse.newBuilder()
.setCmdType(request.getCmdType())
.setStatus(Status.OK)
.setQueryUpgradeStatusResponse(getQueryUpgradeStatus(request.getQueryUpgradeStatusRequest()))
.build();
default:
throw new IllegalArgumentException(
"Unknown command type: " + request.getCmdType());
Expand Down Expand Up @@ -1088,6 +1094,16 @@ public FinalizeScmUpgradeResponseProto getFinalizeScmUpgrade(
.build();
}

public StorageContainerLocationProtocolProtos.QueryUpgradeStatusResponseProto getQueryUpgradeStatus(
StorageContainerLocationProtocolProtos.QueryUpgradeStatusRequestProto request) throws IOException {

HddsProtos.UpgradeStatus response = impl.queryUpgradeStatus();
return StorageContainerLocationProtocolProtos.QueryUpgradeStatusResponseProto
.newBuilder()
.setStatus(response)
.build();
}

public ForceExitSafeModeResponseProto forceExitSafeMode(
ForceExitSafeModeRequestProto request)
throws IOException {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -1148,6 +1148,26 @@ public StatusAndMessages queryUpgradeFinalizationProgress(
}
}

@Override
public HddsProtos.UpgradeStatus queryUpgradeStatus() throws IOException {
try {
getScm().checkAdminAccess(getRemoteUser(), true);

// Returning a placeholder for now.
HddsProtos.UpgradeStatus result = HddsProtos.UpgradeStatus.newBuilder()
.setScmFinalized(true)
.setNumDatanodesFinalized(10)
.setNumDatanodesTotal(10)
.setShouldFinalize(true)
.build();
AUDIT.logReadSuccess(buildAuditMessageForSuccess(SCMAction.QUERY_UPGRADE_STATUS, null));
return result;
} catch (IOException ex) {
AUDIT.logReadFailure(buildAuditMessageForFailure(SCMAction.QUERY_UPGRADE_STATUS, null, ex));
throw ex;
}
}

@Override
public StartContainerBalancerResponseProto startContainerBalancer(
Optional<Double> threshold, Optional<Integer> iterations,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -60,6 +60,7 @@ public enum SCMAction implements AuditAction {
GET_SAFE_MODE_RULE_STATUSES,
FINALIZE_SCM_UPGRADE,
QUERY_UPGRADE_FINALIZATION_PROGRESS,
QUERY_UPGRADE_STATUS,
GET_DATANODE_USAGE_INFO,
GET_CONTAINER_TOKEN,
GET_CONTAINER_COUNT,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -582,6 +582,11 @@ public StatusAndMessages queryUpgradeFinalizationProgress(
upgradeClientID, force, readonly);
}

@Override
public HddsProtos.UpgradeStatus queryUpgradeStatus() throws IOException {
return storageContainerLocationClient.queryUpgradeStatus();
}

@Override
public DecommissionScmResponseProto decommissionScm(
String scmId)
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,49 @@
/*
* Licensed to the Apache Software Foundation (ASF) under one or more
* contributor license agreements. See the NOTICE file distributed with
* this work for additional information regarding copyright ownership.
* The ASF licenses this file to You under the Apache License, Version 2.0
* (the "License"); you may not use this file except in compliance with
* the License. You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/

package org.apache.hadoop.ozone.admin.upgrade;

import java.io.IOException;
import org.apache.hadoop.hdds.cli.HddsVersionProvider;
import org.apache.hadoop.hdds.protocol.proto.HddsProtos;
import org.apache.hadoop.hdds.scm.cli.ScmSubcommand;
import org.apache.hadoop.hdds.scm.client.ScmClient;
import picocli.CommandLine;

/**
* Sub command to query the overall upgrade status of the cluster, returning information about the finalization
* status of SCM, the datanodes and OM.
*/
@CommandLine.Command(
name = "status",
description = "Show status of the cluster upgrade",
mixinStandardHelpOptions = true,
versionProvider = HddsVersionProvider.class)
public class StatusSubCommand extends ScmSubcommand {

@Override
public void execute(ScmClient client) throws IOException {
HddsProtos.UpgradeStatus status = client.queryUpgradeStatus();

// Temporary output to validate the command is working.
out().println("Update status:");
out().println(" SCM Finalized: " + status.getScmFinalized());
out().println(" Datanodes finalized: " + status.getNumDatanodesFinalized());
out().println(" Total Datanodes: " + status.getNumDatanodesTotal());
out().println(" Should Finalize: " + status.getShouldFinalize());
Comment on lines +42 to +47

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is fine for now. I'm thinking the final output would have a "human" version:

OM is not finalized
SCM is finalized
3/10 Datanodes are finalized

and then a --json version for scripting:

{
  "omFinalized": false,
  "scmFinalized": true,
  "finalizedDatanodes": 3,
  "totalDatanodes": 10
}

Note that the final version of this command will also query OM for its finalization status.

We also don't need to print the shouldFinalize parameter. That is for SCM to explicitly tell OM when it should finalize so OM does not need to infer this from datanode counts.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I vote +1 on the human and JSON versions.

If we don't print the shouldFinalize parameter though (and probably even if we do), it would make a lot of sense to log it when it changes. That would be useful for troubleshooting.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yea the JSON can final output in human readable for can be finalized later when we have the OM status included too. This change was just to get the basic path through the system setup so we can build on it with further small changes.

}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
/*
* Licensed to the Apache Software Foundation (ASF) under one or more
* contributor license agreements. See the NOTICE file distributed with
* this work for additional information regarding copyright ownership.
* The ASF licenses this file to You under the Apache License, Version 2.0
* (the "License"); you may not use this file except in compliance with
* the License. You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/

package org.apache.hadoop.ozone.admin.upgrade;

import org.apache.hadoop.hdds.cli.AdminSubcommand;
import org.apache.hadoop.hdds.cli.HddsVersionProvider;
import org.kohsuke.MetaInfServices;
import picocli.CommandLine;

/**
* Subcommand to group upgrade related operations.
*/
@CommandLine.Command(
name = "upgrade",
description = "Operations related to Ozone cluster upgrade",
mixinStandardHelpOptions = true,
versionProvider = HddsVersionProvider.class,
subcommands = {
StatusSubCommand.class
})
@MetaInfServices(AdminSubcommand.class)
public class UpgradeCommands implements AdminSubcommand {
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
/*
* Licensed to the Apache Software Foundation (ASF) under one or more
* contributor license agreements. See the NOTICE file distributed with
* this work for additional information regarding copyright ownership.
* The ASF licenses this file to You under the Apache License, Version 2.0
* (the "License"); you may not use this file except in compliance with
* the License. You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/

/**
* Ozone upgrade cli tools.
*/
package org.apache.hadoop.ozone.admin.upgrade;
Loading