Skip to content

Commit 4bc0380

Browse files
committed
ore/aws/upload: add winli option back to ore
Creating the winli image without uploading anything means that we dont discover the disk size from the upload file leading to a mismatch between the default (8) and the actual disk size (16). Restoring the winli option to ore allows us to override the rule and specify uploadisksize with uploadsourcesnapshot when winli is set. This enables disk size discover and AMI creation based on a snapshot without uploading anything. This will require a change to the cloud-upload job to buildfetch the vmdk file before creating the AMI.
1 parent 8f58c28 commit 4bc0380

File tree

2 files changed

+17
-10
lines changed

2 files changed

+17
-10
lines changed

mantle/cmd/ore/aws/upload.go

Lines changed: 11 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -68,6 +68,7 @@ After a successful run, the final line of output will be a line of JSON describi
6868
uploadVolumeType string
6969
uploadX86BootMode string
7070
uploadBillingProductCode string
71+
uploadCreateWinLIAMI bool
7172
)
7273

7374
func init() {
@@ -93,6 +94,8 @@ func init() {
9394
cmdUpload.Flags().StringVar(&uploadVolumeType, "volume-type", "gp3", "EBS volume type (gp3, gp2, io1, st1, sc1, standard, etc.)")
9495
cmdUpload.Flags().StringVar(&uploadX86BootMode, "x86-boot-mode", "uefi-preferred", "Set boot mode (uefi-preferred, uefi)")
9596
cmdUpload.Flags().StringVar(&uploadBillingProductCode, "billing-product-code", "", "set billing product code")
97+
cmdUpload.Flags().BoolVar(&uploadCreateWinLIAMI, "winli", false, "Create a Windows LI AMI")
98+
9699
}
97100

98101
func defaultBucketNameForRegion(region string) string {
@@ -140,9 +143,14 @@ func runUpload(cmd *cobra.Command, args []string) error {
140143
fmt.Fprintf(os.Stderr, "At most one of --source-object and --source-snapshot may be specified.\n")
141144
os.Exit(2)
142145
}
143-
if uploadDiskSizeInspect && (uploadSourceObject != "" || uploadSourceSnapshot != "") {
144-
fmt.Fprintf(os.Stderr, "--disk-size-inspect cannot be used with --source-object or --source-snapshot.\n")
145-
os.Exit(2)
146+
// The Windows License Included (winli) image is built using a source snapshot, but the disk size is not known.
147+
// Allow setting uploadDIskSIzeInspect when using a source snapshot to discover the size of the disk from the
148+
// aws upload file that was used to create the snapshot.
149+
if !uploadCreateWinLIAMI {
150+
if uploadDiskSizeInspect && (uploadSourceObject != "" || uploadSourceSnapshot != "") {
151+
fmt.Fprintf(os.Stderr, "--disk-size-inspect cannot be used with --source-object or --source-snapshot.\n")
152+
os.Exit(2)
153+
}
146154
}
147155
if uploadFile == "" {
148156
fmt.Fprintf(os.Stderr, "specify --file\n")

src/cosalib/aws.py

Lines changed: 6 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -138,6 +138,10 @@ def aws_run_ore(build, args):
138138
assert bool(args.winli) == bool(args.winli_billing_product), \
139139
"--winli-billing-product and --winli must be specified together"
140140

141+
winli_name = ""
142+
winli_description = ""
143+
buildmeta_key = "amis"
144+
141145
if args.winli:
142146
winli_name = "-winli"
143147
winli_description = " Windows License Included"
@@ -153,16 +157,10 @@ def aws_run_ore(build, args):
153157
raise Exception(("Unable to find AMI source snapshot for "
154158
f"{region} region"))
155159
ore_args.extend([
160+
'--winli',
156161
'--source-snapshot', f"{source_snapshot}",
157162
'--billing-product-code', f"{args.winli_billing_product}"
158163
])
159-
else:
160-
ore_args.extend([
161-
'--disk-size-inspect'
162-
])
163-
winli_name = ""
164-
winli_description = ""
165-
buildmeta_key = "amis"
166164

167165
if args.bucket:
168166
ore_args.extend(['--bucket', f"{args.bucket}"])
@@ -174,6 +172,7 @@ def aws_run_ore(build, args):
174172
'--ami-description', f"{build.summary} {build.build_id} {build.basearch}{winli_description}",
175173
'--arch', f"{build.basearch}",
176174
'--file', f"{build.image_path}",
175+
'--disk-size-inspect',
177176
'--delete-object'
178177
])
179178
for user in args.grant_user:

0 commit comments

Comments
 (0)