Skip to content

Commit f0d1dec

Browse files
authored
improve 400 delivery version ua (#4282)
Signed-off-by: Patrick Zhao <[email protected]>
1 parent 71495fc commit f0d1dec

File tree

1 file changed

+21
-5
lines changed
  • pkg/cli/upgradeassistant/cmd/migrate

1 file changed

+21
-5
lines changed

pkg/cli/upgradeassistant/cmd/migrate/400.go

Lines changed: 21 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -90,6 +90,7 @@ func migrateDeliveryVersionV2(ctx *internalhandler.Context, migrationInfo *inter
9090
return fmt.Errorf("failed to decode delivery version, err: %s", err)
9191
}
9292

93+
IsContinue := false
9394
versionV2 := &models.DeliveryVersionV2{
9495
ProjectName: versionV1.ProductName,
9596
Version: versionV1.Version,
@@ -115,7 +116,9 @@ func migrateDeliveryVersionV2(ctx *internalhandler.Context, migrationInfo *inter
115116
createArgument := &models.DeliveryVersionYamlData{}
116117
err = models.IToi(versionV1.CreateArgument, createArgument)
117118
if err != nil {
118-
return fmt.Errorf("failed to convert create argument, err: %s", err)
119+
log.Errorf("failed to convert create argument, versionName: %s, err: %s", versionV1.Version, err)
120+
IsContinue = true
121+
goto ContinueLabel
119122
}
120123
versionV2.ImageRegistryID = createArgument.ImageRegistryID
121124

@@ -128,7 +131,9 @@ func migrateDeliveryVersionV2(ctx *internalhandler.Context, migrationInfo *inter
128131
for _, imageData := range yamlData.ImageDatas {
129132
tagArr := strings.Split(imageData.Image, ":")
130133
if len(tagArr) == 1 {
131-
return fmt.Errorf("invalid image format: %s", imageData.Image)
134+
log.Errorf("invalid image format, versionName: %s, image: %s", versionV1.Version, imageData.Image)
135+
IsContinue = true
136+
goto ContinueLabel
132137
}
133138

134139
tag := tagArr[len(tagArr)-1]
@@ -149,7 +154,9 @@ func migrateDeliveryVersionV2(ctx *internalhandler.Context, migrationInfo *inter
149154
createArgument := &models.DeliveryVersionChartData{}
150155
err = models.IToi(versionV1.CreateArgument, createArgument)
151156
if err != nil {
152-
return fmt.Errorf("failed to convert create argument, err: %s", err)
157+
log.Errorf("failed to convert create argument, versionName: %s, err: %s", versionV1.Version, err)
158+
IsContinue = true
159+
goto ContinueLabel
153160
}
154161
versionV2.ImageRegistryID = createArgument.ImageRegistryID
155162
versionV2.ChartRepoName = createArgument.ChartRepoName
@@ -159,7 +166,9 @@ func migrateDeliveryVersionV2(ctx *internalhandler.Context, migrationInfo *inter
159166
DistributeType: config.Chart,
160167
})
161168
if err != nil {
162-
return fmt.Errorf("failed to find delivery distribute, err: %s", err)
169+
log.Errorf("failed to find delivery distribute, versionName: %s, err: %s", versionV1.Version, err)
170+
IsContinue = true
171+
goto ContinueLabel
163172
}
164173

165174
successChartMap := make(map[string]bool)
@@ -185,7 +194,9 @@ func migrateDeliveryVersionV2(ctx *internalhandler.Context, migrationInfo *inter
185194
for _, imageData := range chartData.ImageData {
186195
tagArr := strings.Split(imageData.Image, ":")
187196
if len(tagArr) == 1 {
188-
return fmt.Errorf("invalid image format: %s", imageData.Image)
197+
log.Errorf("invalid image format, versionName: %s, image: %s", versionV1.Version, imageData.Image)
198+
IsContinue = true
199+
goto ContinueLabel
189200
}
190201

191202
tag := tagArr[len(tagArr)-1]
@@ -243,6 +254,11 @@ func migrateDeliveryVersionV2(ctx *internalhandler.Context, migrationInfo *inter
243254
if err != nil {
244255
return fmt.Errorf("failed to create delivery version v2, projectName: %s, version: %s, err: %s", versionV2.ProjectName, versionV2.Version, err)
245256
}
257+
258+
ContinueLabel:
259+
if IsContinue {
260+
continue
261+
}
246262
}
247263
}
248264

0 commit comments

Comments
 (0)