@@ -445,11 +445,6 @@ func (c *Controller) preprocessTApp(tapp *tappv1.TApp) error {
445
445
return err
446
446
}
447
447
448
- if err := c .updateTemplateHash (newTapp ); err != nil {
449
- klog .Errorf ("Failed to update template hash for tapp: %s" , util .GetTAppFullName (tapp ))
450
- return err
451
- }
452
-
453
448
err = c .setLabelSelector (newTapp )
454
449
if err != nil {
455
450
klog .Errorf ("Failed to setLabelSelector for tapp %s: %v" , util .GetTAppFullName (tapp ), err )
@@ -514,7 +509,7 @@ func (c *Controller) removeUnusedTemplate(tapp *tappv1.TApp) error {
514
509
}
515
510
516
511
// updateTemplateHash will generate and update templates hash if needed.
517
- func (c * Controller ) updateTemplateHash (tapp * tappv1.TApp ) error {
512
+ func (c * Controller ) updateTemplateHash (tapp * tappv1.TApp ) {
518
513
updateHash := func (template * corev1.PodTemplateSpec ) {
519
514
if c .tappHash .SetTemplateHash (template ) {
520
515
c .tappHash .SetUniqHash (template )
@@ -526,8 +521,6 @@ func (c *Controller) updateTemplateHash(tapp *tappv1.TApp) error {
526
521
for _ , template := range tapp .Spec .TemplatePool {
527
522
updateHash (& template )
528
523
}
529
-
530
- return nil
531
524
}
532
525
533
526
func (c * Controller ) setLabelSelector (tapp * tappv1.TApp ) error {
@@ -660,6 +653,8 @@ func makePodMap(pods []*corev1.Pod) map[string]*corev1.Pod {
660
653
}
661
654
662
655
func (c * Controller ) instanceToSync (tapp * tappv1.TApp , pods []* corev1.Pod ) (add , del , forceDel , update []* Instance ) {
656
+ tapp = tapp .DeepCopy ()
657
+ c .updateTemplateHash (tapp )
663
658
podMap := makePodMap (pods )
664
659
665
660
desiredRunningPods , desiredCompletedPods := getDesiredInstance (tapp )
@@ -722,6 +717,9 @@ func (c *Controller) syncRunningPods(tapp *tappv1.TApp, desiredRunningPods sets.
722
717
klog .V (6 ).Infof ("Skip migrating pod %s, status:%s" , getPodFullName (pod ), pod .Status .Phase )
723
718
}
724
719
} else if c .isTemplateHashChanged (tapp , id , pod ) {
720
+ if template , err := getPodTemplate (& tapp .Spec , id ); err != nil {
721
+ klog .V (4 ).Infof ("Pod %s template changed: %+v -> %+v" , getPodFullName (pod ), pod , template )
722
+ }
725
723
// If template hash changes, it means some thing in pod spec got updated.
726
724
// If image is updated, we only need restart corresponding container, otherwise
727
725
// we need recreate the pod because k8s does not support restarting it.
0 commit comments