Skip to content

Commit

Permalink
Merge pull request #59 from Cray-HPE/CASMHMS-6018
Browse files Browse the repository at this point in the history
CASMHMS-6018 Pre-signed URL support `root=live:`
  • Loading branch information
rustydb authored May 23, 2023
2 parents c682c2e + 0a1196f commit 2ed3d26
Show file tree
Hide file tree
Showing 4 changed files with 33 additions and 5 deletions.
2 changes: 1 addition & 1 deletion .version
Original file line number Diff line number Diff line change
@@ -1 +1 @@
1.24.0
1.25.0
4 changes: 4 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,10 @@ All notable changes to this project will be documented in this file.
The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/),
and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).

## [1.25.0] - 2023-05-22

- CASMHMS-6018: Add support for creating pre-signed URLs for `root=live:` parameters, enabling native dmsquash-live dracut usage.

## [1.24.0] - 2023-03-28

### Changed
Expand Down
2 changes: 1 addition & 1 deletion cmd/boot-script-service/default_api.go
Original file line number Diff line number Diff line change
Expand Up @@ -76,7 +76,7 @@ var gwURI = getEnvVal("BSS_GW_URI", "/apis/bss")
var s3Client *hms_s3.S3Client

// regex for matching s3 URIs in the params field
var s3ParamsRegex = "(^|[ ])((metal.server=)(s3://[^ ]*))"
var s3ParamsRegex = "(^|[ ])((metal.server=|root=live:)(s3://[^ ]*))"

type (
// function interface for checkURL()
Expand Down
30 changes: 27 additions & 3 deletions cmd/boot-script-service/default_api_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -83,15 +83,16 @@ func TestReplaceS3Params_regex(t *testing.T) {
}
}

func TestReplaceS3Params_replace(t *testing.T) {
params := fmt.Sprintf("%s %s %s %s %s",
// TestReplaceS3Params_replace_kernel_metal tests that the “metal.server=s3://<url>“ argument is recognized and given a pre-signed URL.
func TestReplaceS3Params_replace_kernel_metal(t *testing.T) {
params := fmt.Sprintf("%s %s %s %s %s",
"metal.server=s3://ncn-images/k8s/0.2.78/filesystem.squashfs",
"bond=bond0",
"metal.server=s3://bucket/path",
"root=craycps-s3:s3://boot-images",
"m=s3://b/p")

expected_params := fmt.Sprintf("%s %s %s %s %s",
expected_params := fmt.Sprintf("%s %s %s %s %s",
"metal.server=s3://ncn-images/k8s/0.2.78/filesystem.squashfs_signed",
"bond=bond0",
"metal.server=s3://bucket/path_signed",
Expand All @@ -107,6 +108,29 @@ func TestReplaceS3Params_replace(t *testing.T) {
}
}

// TestReplaceS3Params_replace_kernel_live tests that the dmsquash-live “root=live:s3://<url>“ argument is recognized and given a pre-signed URL.
func TestReplaceS3Params_replace_kernel_live(t *testing.T) {
params := fmt.Sprintf("%s %s %s %s",
"root=live:s3://boot-images/k8s/0.2.78/rootfs",
"bond=bond0",
"root=live:s3://bucket/path",
"m=s3://b/p")

expected_params := fmt.Sprintf("%s %s %s %s",
"root=live:s3://boot-images/k8s/0.2.78/rootfs_signed",
"bond=bond0",
"root=live:s3://bucket/path_signed",
"m=s3://b/p")

newParams, err := replaceS3Params(params, mockGetSignedS3Url)
if err != nil {
t.Errorf("replaceS3Params returned an error for params: %s, error: %v\n", params, err)
}
if newParams != expected_params {
t.Errorf("replaceS3Params failed.\n expected: %s\n actual: %s\n", expected_params, newParams)
}
}

func TestReplaceS3Params_replace2(t *testing.T) {
params := fmt.Sprintf("%s %s",
"xmetal.server=s3://ncn-images/k8s/0.2.78/filesystem.squashfs",
Expand Down

0 comments on commit 2ed3d26

Please sign in to comment.