@@ -321,16 +321,20 @@ func (c *Controller) updateHelmRequestStatus(helmRequest *alpha1.HelmRequest) er
321321 // NEVER modify objects from the store. It's a read-only, local cache.
322322 // You can use DeepCopy() to make a deep copy of original object and modify this copy
323323 // Or create a copy manually for better performance
324+ h := hash .GenHashStr (helmRequest .Spec )
325+ // Note: we have to generate the hash before the deepcopy, because somehow the deepcopy
326+ // can create a spec that have different hash value.
324327 request := helmRequest .DeepCopy ()
325- request .Status .LastSpecHash = hash . GenHashStr ( request . Spec )
328+ request .Status .LastSpecHash = h
326329 return c .updateHelmRequestPhase (request , alpha1 .HelmRequestSynced )
327330}
328331
329332// setPartialSyncedStatus set spec hash and partial-synced status for helm-request
330333//TODO: merge with updateHelmRequestStatus
331334func (c * Controller ) setPartialSyncedStatus (helmRequest * alpha1.HelmRequest ) error {
335+ h := hash .GenHashStr (helmRequest .Spec )
332336 request := helmRequest .DeepCopy ()
333- request .Status .LastSpecHash = hash . GenHashStr ( request . Spec )
337+ request .Status .LastSpecHash = h
334338 return c .updateHelmRequestPhase (request , alpha1 .HelmRequestPartialSynced )
335339}
336340
@@ -351,14 +355,18 @@ func (c *Controller) updateHelmRequestPhase(helmRequest *alpha1.HelmRequest, pha
351355 // which is ideal for ensuring nothing other than resource status has been updated.
352356 _ , err := c .hrClientSet .AppV1alpha1 ().HelmRequests (helmRequest .Namespace ).UpdateStatus (request )
353357 if err != nil {
354- klog .Warning ("update helm request status conflict, retry..." )
355358 if apierrors .IsConflict (err ) {
359+ klog .Warning ("update helm request status conflict, retry..." )
356360 origin , err := c .hrClientSet .AppV1alpha1 ().HelmRequests (helmRequest .Namespace ).Get (helmRequest .Name , metav1.GetOptions {})
357361 if err != nil {
358362 return err
359363 }
364+ klog .Warningf ("origin status: %+v, current: %+v" , origin .Status , request .Status )
360365 origin .Status = * request .Status .DeepCopy ()
361366 _ , err = c .hrClientSet .AppV1alpha1 ().HelmRequests (helmRequest .Namespace ).UpdateStatus (origin )
367+ if err != nil {
368+ klog .Error ("retrying update helmrequest status error:" , err )
369+ }
362370 return err
363371 }
364372 klog .Errorf ("update status for helmrequest %s error: %s" , helmRequest .Name , err .Error ())
0 commit comments