Skip to content

Commit

Permalink
protection when pre_build.cluster_id is empty
Browse files Browse the repository at this point in the history
Signed-off-by: zhangyifei <[email protected]>
  • Loading branch information
zhangyifei committed Feb 17, 2022
1 parent 4a93331 commit 215d2bc
Showing 1 changed file with 7 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -1852,6 +1852,13 @@ func BuildModuleToSubTasks(args *commonmodels.BuildModuleArgs, log *zap.SugaredL
ClusterID: module.PreBuild.ClusterID,
}

// In some old build configurations, the `pre_build.cluster_id` field is empty indicating that's a local cluster.
// We do a protection here to avoid query failure.
// Resaving the build configuration after v1.8.0 will automatically populate this field.
if module.PreBuild.ClusterID == "" {
module.PreBuild.ClusterID = setting.LocalClusterID
}

clusterInfo, err := commonrepo.NewK8SClusterColl().Get(module.PreBuild.ClusterID)
if err != nil {
return nil, e.ErrConvertSubTasks.AddErr(err)
Expand Down

0 comments on commit 215d2bc

Please sign in to comment.