Skip to content
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

CASMHMS-6018 Pre-signed URL support root=live: #59

Merged
merged 1 commit into from
May 23, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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://[^ ]*))"
rustydb marked this conversation as resolved.
Show resolved Hide resolved

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