File tree Expand file tree Collapse file tree 3 files changed +25
-4
lines changed Expand file tree Collapse file tree 3 files changed +25
-4
lines changed Original file line number Diff line number Diff line change @@ -157,6 +157,7 @@ func runUpload(cmd *cobra.Command, args []string) error {
157
157
os .Exit (2 )
158
158
}
159
159
160
+ var err error
160
161
if uploadDiskSizeInspect {
161
162
imageInfo , err := util .GetImageInfo (uploadFile )
162
163
if err != nil {
@@ -172,8 +173,15 @@ func runUpload(cmd *cobra.Command, args []string) error {
172
173
}
173
174
}
174
175
176
+ if uploadSourceSnapshot != "" {
177
+ uploadDiskSizeGiB , err = API .FindSnapshotDiskSizeGiB (uploadSourceSnapshot )
178
+ if err != nil {
179
+ fmt .Fprintf (os .Stderr , "Unable to query size of disk from snapshot: %v\n " , err )
180
+ os .Exit (1 )
181
+ }
182
+ }
183
+
175
184
var s3URL * url.URL
176
- var err error
177
185
if uploadSourceObject != "" {
178
186
s3URL , err = url .Parse (uploadSourceObject )
179
187
if err != nil {
Original file line number Diff line number Diff line change @@ -852,3 +852,18 @@ func getImageSnapshotID(image *ec2.Image) (string, error) {
852
852
// and it's just a sorta eventual consistency thing
853
853
return "" , fmt .Errorf ("no backing block device for %v" , image .ImageId )
854
854
}
855
+
856
+ func (a * API ) FindSnapshotDiskSizeGiB (snapshotID string ) (uint , error ) {
857
+ result , err := a .ec2 .DescribeSnapshots (& ec2.DescribeSnapshotsInput {
858
+ SnapshotIds : []* string {& snapshotID },
859
+ })
860
+ if err != nil {
861
+ return 0 , fmt .Errorf ("failed to describe snapshot: %v" , err )
862
+ }
863
+
864
+ if len (result .Snapshots ) == 0 {
865
+ return 0 , fmt .Errorf ("no snapshot found with ID %s" , snapshotID )
866
+ }
867
+
868
+ return uint (aws .Int64Value (result .Snapshots [0 ].VolumeSize )), nil
869
+ }
Original file line number Diff line number Diff line change @@ -157,9 +157,7 @@ def aws_run_ore(build, args):
157
157
'--billing-product-code' , f"{ args .winli_billing_product } "
158
158
])
159
159
else :
160
- ore_args .extend ([
161
- '--disk-size-inspect'
162
- ])
160
+ ore_args .extend (['--disk-size-inspect' ])
163
161
winli_name = ""
164
162
winli_description = ""
165
163
buildmeta_key = "amis"
You can’t perform that action at this time.
0 commit comments