未验证 提交 5972c4b6 编写于 作者: K KubeSphere CI Bot 提交者: GitHub

Merge pull request #3349 from LinuxSuRen/get-latest-resource-version

Trying to avoid the error of `Operation cannot be fulfilled on` by getting the latest resourceVersion
......@@ -251,9 +251,18 @@ func (d devopsOperator) UpdatePipelineObj(projectName string, pipeline *v1alpha3
if err != nil {
return nil, err
}
projectObj.Annotations[devopsv1alpha3.PipelineSyncStatusAnnoKey] = StatusPending
projectObj.Annotations[devopsv1alpha3.PipelineSyncTimeAnnoKey] = GetSyncNowTime()
return d.ksclient.DevopsV1alpha3().Pipelines(projectObj.Status.AdminNamespace).Update(context.Background(), pipeline, metav1.UpdateOptions{})
ctx := context.Background()
ns := projectObj.Status.AdminNamespace
name := pipeline.GetName()
// trying to avoid the error of `Operation cannot be fulfilled on` by getting the latest resourceVersion
if latestPipe, err := d.ksclient.DevopsV1alpha3().Pipelines(ns).Get(ctx, name, metav1.GetOptions{}); err == nil {
pipeline.ResourceVersion = latestPipe.ResourceVersion
} else {
return nil, fmt.Errorf("cannot found pipeline %s/%s, error: %v", ns, name, err)
}
return d.ksclient.DevopsV1alpha3().Pipelines(ns).Update(context.Background(), pipeline, metav1.UpdateOptions{})
}
func (d devopsOperator) ListPipelineObj(projectName string, sortFunc func([]*v1alpha3.Pipeline, int, int) bool, limit, offset int) (api.ListResult, error) {
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册