-
Notifications
You must be signed in to change notification settings - Fork 44
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Extract disk wiping from disk partitioning (#91)
## Description Extracting the Wipe functionality and add it as a dedicated command, where user can only wipe disks without any partitioning, using the metadata of the Hardware. ## Why is this needed This is very helpful, when the provisioned machine, is gonna be used by some storage specific services or SDS operator, as some of those operators don't use disks that are in a specific status(for example if the disks have partitions, the storage operator would considered this disk is being used by anther software and wouldn't use and utilize it). Fixes: #90 ## How Has This Been Tested? It was tested by using this commit and build an image out of it, where this image has been use as a workflow to de provision a machine. ## How are existing users impacted? What migration steps/scripts do we need? NA ## Checklist: I have: - [ ] updated the documentation and/or roadmap (if required) - [ ] added unit or e2e tests - [ ] provided instructions on how to upgrade
- Loading branch information
Showing
3 changed files
with
57 additions
and
25 deletions.
There are no files selected for viewing
This file contains 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
This file contains 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
This file contains 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,33 @@ | ||
package storage | ||
|
||
import ( | ||
"os" | ||
|
||
log "github.com/sirupsen/logrus" | ||
"github.com/tinkerbell/hub/actions/rootio/v1/pkg/types.go" | ||
) | ||
|
||
// Wipe will clean the table from a disk. | ||
func Wipe(d types.Disk) error { | ||
disk, err := os.OpenFile(d.Device, os.O_CREATE|os.O_WRONLY, 0o644) | ||
if err != nil { | ||
return err | ||
} | ||
defer disk.Close() | ||
bigBuff := make([]byte, 1024*1024*1024) | ||
n, err := disk.Write(bigBuff) | ||
if err != nil { | ||
return err | ||
} | ||
log.Infof("Wrote [%d] bytes to [%s]", n, d.Device) | ||
log.Infoln("Flushing writes to new partition") | ||
err = disk.Sync() | ||
if err != nil { | ||
return err | ||
} | ||
err = disk.Close() | ||
if err != nil { | ||
return err | ||
} | ||
return nil | ||
} |