Enhance blkdiscard for Improved Disk Initialization & Pre-commit Linting #41
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.
Enhance blkdiscard for Improved Disk Initialization & Pre-commit Linting
Description
This PR includes the following improvements:
1. Enhanced
blkdiscard
Functionalityblkdiscard
function to accept multiple commands, enabling dynamic disk initialization.blkdiscard
process:blkdiscard
command ensures that existing data on the disk is erased. The behavior varies by environment:blkdiscard
command forces zeros to the first 8MB of the disk header, making the disk "Aerospike-ready".2. Improved Pre-commit Configuration for Linting
.pre-commit-config.yaml
file to ensuregolangci-lint
runs on the entire codebase.pass_filenames: false
to the configuration, resolving type-check errors by ensuring that all files are linted, not just the modified ones.Background & Context
In dynamic setups like AWS, where the OpenEBS LVM provisioner is used, disks are created on-the-fly during PVC creation. The previous approach, which used
dd
for disk initialization, led to significant delays (up to an hour) when adding new nodes to an Aerospike cluster.To optimize this process, the
blkdiscard
command was enhanced to:dd
operations.The updated solution has been tested on an AWS setup and was found to be suitable for the team's needs. However, there was an internal discussion about potentially creating a more configurable option, such as a new
initMethod
, to handle more diverse use cases.Key Changes
Disk Initialization Enhancements:
blkdiscard
to accept multiple commands.blkdiscard
process:blkdiscard
(random or zeros) to erase existing content.blkdiscard
to zero out the first 8MB header.Pre-commit Configuration:
golangci-lint
covers the entire codebase.Testing & Validation
blkdiscard
approach has been successfully tested in an AWS environment using the OpenEBS LVM provisioner. The solution was found to significantly reduce node initialization times compared to the previousdd
method.golangci-lint
runs comprehensively across the entire project.Potential Future Enhancements
initMethod
option:blkdiscard-aws
could be introduced for environments requiring specialized initialization (e.g., randomized writes on AWS).Closing Notes
This PR aims to provide an immediate performance boost for disk initialization in dynamic environments, while also leaving room for future enhancements if more flexibility is desired. Thank you for your feedback and consideration!