@@ -124,6 +124,7 @@ var debugZipUploadOpts = struct {
124
124
from , to timestampValue
125
125
logFormat string
126
126
maxConcurrentUploads int
127
+ dryRun bool
127
128
}{
128
129
maxConcurrentUploads : system .NumCPU () * 4 ,
129
130
}
@@ -217,6 +218,10 @@ func runDebugZipUpload(cmd *cobra.Command, args []string) error {
217
218
artifactsToUpload = debugZipUploadOpts .include
218
219
}
219
220
221
+ if debugZipUploadOpts .dryRun {
222
+ fmt .Println ("DRY RUN MODE: No actual uploads will be performed" )
223
+ }
224
+
220
225
// run the upload functions for each artifact type. This can run sequentially.
221
226
// All the concurrency is contained within the upload functions.
222
227
for _ , artType := range artifactsToUpload {
@@ -238,6 +243,10 @@ func validateZipUploadReadiness() error {
238
243
artifactsToUpload = zipArtifactTypes
239
244
)
240
245
246
+ if debugZipUploadOpts .dryRun {
247
+ return nil
248
+ }
249
+
241
250
if len (debugZipUploadOpts .include ) > 0 {
242
251
artifactsToUpload = debugZipUploadOpts .include
243
252
}
@@ -896,6 +905,11 @@ func startWriterPool(
896
905
// writing to GCS. The concurrency has to be handled by the caller.
897
906
// This function implements the logUploadFunc signature.
898
907
var gcsLogUpload = func (ctx context.Context , sig logUploadSig ) (int , error ) {
908
+ data := bytes .Join (sig .logLines , []byte ("\n " ))
909
+ if debugZipUploadOpts .dryRun {
910
+ return len (data ), nil
911
+ }
912
+
899
913
gcsClient , closeGCSClient , err := newGCSClient (ctx )
900
914
if err != nil {
901
915
return 0 , err
@@ -910,7 +924,6 @@ var gcsLogUpload = func(ctx context.Context, sig logUploadSig) (int, error) {
910
924
retryOpts := base .DefaultRetryOptions ()
911
925
retryOpts .MaxRetries = zipUploadRetries
912
926
913
- data := bytes .Join (sig .logLines , []byte ("\n " ))
914
927
for retry := retry .Start (retryOpts ); retry .Next (); {
915
928
objectWriter := gcsClient .Bucket (ddArchiveBucketName ).Object (filename ).NewWriter (ctx )
916
929
w := gzip .NewWriter (objectWriter )
@@ -1137,6 +1150,10 @@ func makeDDTag(key, value string) string {
1137
1150
// There is also some error handling logic in this function. This is a variable so that
1138
1151
// we can mock this function in the tests.
1139
1152
var doUploadReq = func (req * http.Request ) ([]byte , error ) {
1153
+ if debugZipUploadOpts .dryRun {
1154
+ return []byte ("{}" ), nil
1155
+ }
1156
+
1140
1157
resp , err := http .DefaultClient .Do (req )
1141
1158
if err != nil {
1142
1159
return nil , err
0 commit comments