Skip to content

Commit

Permalink
WORKAROUND: add possibility to mark disks as ssd (#10431)
Browse files Browse the repository at this point in the history
* WORKAROUND: add possiblility to mark disks as ssd

Signed-off-by: Daniel Horak <[email protected]>
  • Loading branch information
dahorak committed Sep 18, 2024
1 parent 5a46d37 commit e111fa2
Show file tree
Hide file tree
Showing 5 changed files with 82 additions and 2 deletions.
2 changes: 1 addition & 1 deletion conf/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -335,7 +335,7 @@ higher priority).
* `skip_upgrade_checks` - If set to true Rook won't perform any upgrade checks on Ceph daemons during an upgrade.
* `continue_upgrade_after_checks_even_if_not_healthy` - if set to true Rook will continue the OSD daemon upgrade process even if the PGs are not clean.
* `upgrade_osd_requires_healthy_pgs` - If set to true OSD upgrade process won't start until PGs are healthy.

* `workaround_mark_disks_as_ssd` - WORKAROUND: mark disks as SSD (not rotational - `0` in `/sys/block/*d*/queue/rotational`)

#### UPGRADE

Expand Down
4 changes: 4 additions & 0 deletions ocs_ci/deployment/deployment.py
Original file line number Diff line number Diff line change
Expand Up @@ -116,6 +116,7 @@
from ocs_ci.utility.deployment import (
create_external_secret,
get_and_apply_icsp_from_catalog,
workaround_mark_disks_as_ssd,
)
from ocs_ci.utility.flexy import load_cluster_info
from ocs_ci.utility import (
Expand Down Expand Up @@ -632,6 +633,9 @@ def deploy_cluster(self, log_cli_level="DEBUG"):
"""
self.do_deploy_ocp(log_cli_level)

if config.ENV_DATA.get("workaround_mark_disks_as_ssd"):
workaround_mark_disks_as_ssd()

# TODO: use temporary directory for all temporary files of
# ocs-deployment, not just here in this particular case
tmp_path = Path(tempfile.mkdtemp(prefix="ocs-ci-deployment-"))
Expand Down
5 changes: 5 additions & 0 deletions ocs_ci/ocs/constants.py
Original file line number Diff line number Diff line change
Expand Up @@ -2990,3 +2990,8 @@
FILE_CREATOR_IO = os.path.join(
TEMPLATE_WORKLOAD_DIR, "helper_scripts/file_creator_io.py"
)

# workaround: marking disks as ssd
MC_WORKAROUND_SSD = os.path.join(
TEMPLATE_DEPLOYMENT_DIR_OCP, "workaround-ssd-machine-config.yaml"
)
49 changes: 49 additions & 0 deletions ocs_ci/templates/ocp-deployment/workaround-ssd-machine-config.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,49 @@
---
apiVersion: machineconfiguration.openshift.io/v1
kind: MachineConfig
metadata:
labels:
machineconfiguration.openshift.io/role: worker
name: 99-worker-workaround-ssd
spec:
config:
ignition:
version: 3.2.0
storage:
files:
- contents:
source: data:text/plain;charset=utf-8;base64,IyEvYmluL2Jhc2gKCmZvciBkZXYgaW4gL3N5cy9ibG9jay8qZCovcXVldWUvcm90YXRpb25hbCA7IGRvCiAgZWNobyAwID4gJHtkZXZ9CmRvbmUK
group:
name: root
mode: 500
path: /etc/workaround-ssd.sh
user:
name: root
systemd:
units:
- contents: '[Unit]
Description=WORKAROUND: force disks to behave as SSD
[Service]
Type=oneshot
RemainAfterExit=yes
Restart=no
ExecStart=/usr/bin/bash -c "/etc/workaround-ssd.sh"
User=root
Group=root
[Install]
WantedBy=multi-user.target
'
name: workaround-ssd.service
enabled: true
24 changes: 23 additions & 1 deletion ocs_ci/utility/deployment.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,8 @@

from ocs_ci.framework import config
from ocs_ci.ocs import constants
from ocs_ci.ocs.exceptions import ExternalClusterDetailsException
from ocs_ci.ocs.exceptions import CommandFailed, ExternalClusterDetailsException
from ocs_ci.ocs.resources.ocs import OCS
from ocs_ci.utility import templating
from ocs_ci.utility.utils import (
create_directory_path,
Expand Down Expand Up @@ -200,3 +201,24 @@ def get_ocp_release_image_from_installer():
for line in proc.stdout.decode().split("\n"):
if "release image" in line:
return line.split(" ")[2].strip()


def workaround_mark_disks_as_ssd():
"""
This function creates MachineConfig defining new service `workaround-ssd`, which configures all disks as SSD
(not rotational).
This is useful for example on some Bare metal servers where are SSD disks not properly recognized as SSD, because of
wrong RAID controller configuration or issue.
"""
try:
logger.info("WORKAROUND: mark disks as ssd (non rotational)")
mc_yaml_file = templating.load_yaml(constants.MC_WORKAROUND_SSD)
mc_yaml = OCS(**mc_yaml_file)
mc_yaml.create()
wait_for_machineconfigpool_status("all")
logger.info("WORKAROUND: disks marked as ssd (non rotational)")
except CommandFailed as err:
if "AlreadyExists" in str(err):
logger.info("Workaround already applied.")
else:
raise err

0 comments on commit e111fa2

Please sign in to comment.