未验证 提交 ff384d30 编写于 作者: LinuxSuRen's avatar LinuxSuRen

trying to avoid the error of `Operation cannot be fulfilled on` by getting the...

trying to avoid the error of `Operation cannot be fulfilled on` by getting the latest resourceVersion
Signed-off-by: LinuxSuRen's avatarrick <rick@jenkins-zh.cn>
上级 166dd4ff
......@@ -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.
先完成此消息的编辑!
想要评论请 注册