-
Notifications
You must be signed in to change notification settings - Fork 588
HDDS-13251. Support dynamic Byteman scripts via bmsubmit in ozonesecure-ha #8654
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
Changes from 4 commits
Commits
Show all changes
17 commits
Select commit
Hold shift + click to select a range
7bbccd6
Adding Byteman support in acceptance test suites via new docker-compose
ssulav 24096c0
Reused ozonesecure-ha config
ssulav 840dd49
Addressed review comments
ssulav b7cf25a
Add BYTEMAN_HOME in .env
ssulav 61bd2c2
Updating the image version for CI
ssulav 0a937ae
Add Apache license header to all files
ssulav 7a8074b
Updated runner version adn Cleaned up code based on review
ssulav 97e3801
Removed extra variables
ssulav 4bae053
Updated OZONE_OPTS to OZONE_SERVER_OPTS
ssulav c73cc3d
Added more methods for wider control
ssulav 50f6067
Add #suite:HA-secure to enable acceptance-suites run
ssulav 47e5d53
Updating interface to address in java opts
ssulav 16527c9
Add README
ssulav a84fed4
Merge branch 'apache:master' into HDDS-13251-Byteman
ssulav fdc3bbc
Added License info in README
ssulav bc9ba58
Bump ozone-runner to 20250625-1-jdk21
adoroszlai bbd2eca
Updated logger from console to info for cleaner log
ssulav File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,10 @@ | ||
| RULE skip notifyGroupRemove | ||
| CLASS org.apache.hadoop.ozone.container.common.transport.server.ratis.ContainerStateMachine | ||
| METHOD notifyGroupRemove | ||
| AT ENTRY | ||
| IF TRUE | ||
| DO | ||
| System.out.println("[" + java.time.LocalDateTime.now() + "] BYTEMAN: " + | ||
| "Skip notifyGroupRemove in ContainerStateMachine"); | ||
| return; | ||
| ENDRULE |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,10 @@ | ||
| RULE Block putBlock | ||
| CLASS org.apache.hadoop.ozone.container.keyvalue.impl.BlockManagerImpl | ||
| METHOD putBlock | ||
| AT ENTRY | ||
| IF TRUE | ||
| DO | ||
| System.out.println("[" + java.time.LocalDateTime.now() + "] BYTEMAN: " + | ||
| "Blocking putBlock in BlockManagerImpl"); | ||
| return 0; | ||
| ENDRULE |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
47 changes: 47 additions & 0 deletions
47
hadoop-ozone/dist/src/main/compose/ozonesecure-ha/byteman.yaml
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,47 @@ | ||
| # 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. | ||
| x-byteman-config: | ||
| &byteman-config | ||
| environment: | ||
| BYTEMAN_HOME: /opt/byteman/ | ||
| OZONE_OPTS: -javaagent:/opt/byteman.jar=listener:true,interface:0.0.0.0,port:${BYTEMAN_PORT} | ||
| BYTEMAN_PORT: ${BYTEMAN_PORT} | ||
|
|
||
| services: | ||
| datanode1: | ||
| <<: *byteman-config | ||
| datanode2: | ||
| <<: *byteman-config | ||
| datanode3: | ||
| <<: *byteman-config | ||
| om1: | ||
| <<: *byteman-config | ||
| om2: | ||
| <<: *byteman-config | ||
| om3: | ||
| <<: *byteman-config | ||
| httpfs: | ||
| <<: *byteman-config | ||
| s3g: | ||
| <<: *byteman-config | ||
| scm1.org: | ||
| <<: *byteman-config | ||
| scm2.org: | ||
| <<: *byteman-config | ||
| scm3.org: | ||
| <<: *byteman-config | ||
| recon: | ||
| <<: *byteman-config | ||
36 changes: 36 additions & 0 deletions
36
hadoop-ozone/dist/src/main/compose/ozonesecure-ha/test-byteman.sh
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,36 @@ | ||
| #!/usr/bin/env bash | ||
| # 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. | ||
|
|
||
| #suite:misc | ||
|
|
||
| set -u -o pipefail | ||
|
|
||
| COMPOSE_DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" >/dev/null 2>&1 && pwd )" | ||
| export COMPOSE_DIR | ||
|
|
||
| export SECURITY_ENABLED=true | ||
| export OM_SERVICE_ID="omservice" | ||
| export SCM=scm1.org | ||
| export COMPOSE_FILE=docker-compose.yaml:byteman.yaml | ||
|
|
||
| # shellcheck source=/dev/null | ||
| source "$COMPOSE_DIR/../testlib.sh" | ||
|
|
||
| start_docker_env | ||
|
|
||
| ## Run virtual host test cases | ||
| execute_robot_test om1 ozone-fi/byteman_faults_sample.robot |
63 changes: 63 additions & 0 deletions
63
hadoop-ozone/dist/src/main/smoketest/lib/BytemanLibrary.py
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,63 @@ | ||
| #!/usr/bin/env python3 | ||
| # Licensed to the Apache Software Foundation (ASF) under one | ||
| # or more contributor license agreements. See the NOTICE file | ||
| # distributed with this work for additional consolermation | ||
| # 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. | ||
|
|
||
| import subprocess | ||
| import json | ||
| from robot.api import logger | ||
|
|
||
| class BytemanLibrary: | ||
| def __init__(self): | ||
| self.byteman_clients = {} | ||
|
|
||
| def connect_to_byteman_agent(self, component_name, host="localhost", port=9091): | ||
| """Connect to Byteman agent on specific component""" | ||
| self.byteman_clients[component_name] = {'host': host, 'port': port, | ||
| 'base_url': f"http://{host}:{port}"} | ||
| logger.console(f"Connected to Byteman agent for {component_name} at {host}:{port}") | ||
|
|
||
| def add_byteman_rule(self, component_name, rule_file): | ||
| """Add Byteman rule into specific component""" | ||
| client = self.byteman_clients[component_name] | ||
|
|
||
| # Use bmsubmit command to load rule | ||
| cmd = ["bmsubmit", "-h", component_name, "-p", str(client['port']), "-l", rule_file] | ||
| result = subprocess.run(cmd, capture_output=True, text=True) | ||
| if result.returncode != 0: | ||
| raise RuntimeError(f"Failed to load rule: {result.stderr}") | ||
| logger.console(f"Loaded Byteman rule {rule_file} into {component_name}") | ||
|
|
||
| def remove_byteman_rule(self, component_name, rule_file): | ||
| """Remove Byteman rule for specific component""" | ||
| client = self.byteman_clients[component_name] | ||
|
|
||
| cmd = ["bmsubmit", "-h", component_name, "-p", str(client['port']), "-u", rule_file] | ||
| logger.console(cmd) | ||
| result = subprocess.run(cmd, capture_output=True, text=True) | ||
| if result.returncode != 0: | ||
| raise RuntimeError(f"Failed to unload rule: {result.stderr}") | ||
| logger.console(f"Unloaded Byteman rule {rule_file} from {component_name}") | ||
ssulav marked this conversation as resolved.
Outdated
Show resolved
Hide resolved
|
||
|
|
||
| def list_byteman_rules(self, component_name): | ||
| """List all Byteman rules for specific component""" | ||
| client = self.byteman_clients[component_name] | ||
|
|
||
| cmd = ["bmsubmit", "-h", component_name, "-p", str(client['port']), "-l"] | ||
| result = subprocess.run(cmd, capture_output=True, text=True) | ||
|
|
||
| logger.console(f"Active rules in {component_name}: {result.stdout}") | ||
| return result.stdout | ||
52 changes: 52 additions & 0 deletions
52
hadoop-ozone/dist/src/main/smoketest/ozone-fi/BytemanKeywords.robot
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,52 @@ | ||
| *** Settings *** | ||
| Library ../lib/BytemanLibrary.py | ||
| Library String | ||
|
|
||
| *** Variables *** | ||
| ${BYTEMAN_PORT} 9091 | ||
| ${DATANODE1_BYTEMAN_HOST_PORT} datanode1:${BYTEMAN_PORT} | ||
| ${DATANODE2_BYTEMAN_HOST_PORT} datanode2:${BYTEMAN_PORT} | ||
| ${DATANODE3_BYTEMAN_HOST_PORT} datanode3:${BYTEMAN_PORT} | ||
| ${OM1_BYTEMAN_HOST_PORT} om1:${BYTEMAN_PORT} | ||
| ${OM2_BYTEMAN_HOST_PORT} om2:${BYTEMAN_PORT} | ||
| ${OM3_BYTEMAN_HOST_PORT} om3:${BYTEMAN_PORT} | ||
| ${RECON_BYTEMAN_HOST_PORT} recon:${BYTEMAN_PORT} | ||
| ${SCM1_BYTEMAN_HOST_PORT} scm1.org:${BYTEMAN_PORT} | ||
| ${SCM2_BYTEMAN_HOST_PORT} scm2.org:${BYTEMAN_PORT} | ||
| ${SCM3_BYTEMAN_HOST_PORT} scm3:${BYTEMAN_PORT} | ||
| ${HTTPFS_BYTEMAN_HOST_PORT} httpfs:${BYTEMAN_PORT} | ||
| ${S3G_BYTEMAN_HOST_PORT} s3g:${BYTEMAN_PORT} | ||
|
|
||
| *** Keywords *** | ||
| Setup Byteman For Component | ||
| [Arguments] ${component} ${host_port} | ||
| ${host} ${port} = Split String ${host_port} : | ||
| Connect To Byteman Agent ${component} ${host} ${port} | ||
|
|
||
| Setup All Byteman Agents | ||
| Log Inside Setup All Byteman Agents | ||
| Setup Byteman For Component datanode1 ${DATANODE1_BYTEMAN_HOST_PORT} | ||
| Setup Byteman For Component datanode2 ${DATANODE2_BYTEMAN_HOST_PORT} | ||
| Setup Byteman For Component datanode3 ${DATANODE3_BYTEMAN_HOST_PORT} | ||
| Setup Byteman For Component om1 ${OM1_BYTEMAN_HOST_PORT} | ||
| Setup Byteman For Component om2 ${OM2_BYTEMAN_HOST_PORT} | ||
| Setup Byteman For Component om3 ${OM3_BYTEMAN_HOST_PORT} | ||
| Setup Byteman For Component recon ${RECON_BYTEMAN_HOST_PORT} | ||
| Setup Byteman For Component scm1 ${SCM1_BYTEMAN_HOST_PORT} | ||
| Setup Byteman For Component scm2 ${SCM2_BYTEMAN_HOST_PORT} | ||
| Setup Byteman For Component scm3 ${SCM3_BYTEMAN_HOST_PORT} | ||
| Setup Byteman For Component https ${HTTPFS_BYTEMAN_HOST_PORT} | ||
| Setup Byteman For Component s3g ${S3G_BYTEMAN_HOST_PORT} | ||
ssulav marked this conversation as resolved.
Outdated
Show resolved
Hide resolved
|
||
|
|
||
| Inject Fault Into Component | ||
| [Arguments] ${component} ${rule_file} | ||
| Add Byteman Rule ${component} ${rule_file} | ||
|
|
||
| Remove Fault From Component | ||
| [Arguments] ${component} ${rule_file} | ||
| Remove Byteman Rule ${component} ${rule_file} | ||
|
|
||
| Verify Byteman Rules Active | ||
| [Arguments] ${component} | ||
| ${rules} = List all Byteman Rules ${component} | ||
| Should Not Be Empty ${rules} | ||
32 changes: 32 additions & 0 deletions
32
hadoop-ozone/dist/src/main/smoketest/ozone-fi/byteman_faults_sample.robot
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,32 @@ | ||
| *** Variables *** | ||
| ${RULE} /opt/hadoop/share/ozone/byteman/skip-put-block.btm | ||
| ${vol} vol1 | ||
| ${buck} buck1 | ||
| ${key} key1 | ||
| ${SECURITY_ENABLED} true | ||
|
|
||
| *** Settings *** | ||
| Resource BytemanKeywords.robot | ||
| Resource os.robot | ||
| Resource ../lib/os.robot | ||
ssulav marked this conversation as resolved.
Outdated
Show resolved
Hide resolved
|
||
| Resource ../commonlib.robot | ||
| Resource ../ozone-lib/shell.robot | ||
| Suite Setup Setup Suite | ||
| Suite Teardown Teardown Suite | ||
|
|
||
|
|
||
| *** Keywords *** | ||
| Setup Suite | ||
| Setup All Byteman Agents | ||
| Inject Fault Into Component datanode1 ${RULE} | ||
| Log To Console Kinit | ||
ssulav marked this conversation as resolved.
Outdated
Show resolved
Hide resolved
|
||
| Execute And Ignore Error kinit -kt /etc/security/keytabs/testuser.keytab testuser/om | ||
ssulav marked this conversation as resolved.
Outdated
Show resolved
Hide resolved
|
||
|
|
||
|
|
||
| Teardown Suite | ||
| Remove Fault From Component datanode1 ${RULE} | ||
|
|
||
| *** Test Cases *** | ||
| Print Byteman Port | ||
| ${BYTEMAN_PORT} = Get Environment Variable BYTEMAN_PORT | ||
| Log ${BYTEMAN_PORT} | ||
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.