mirror of
				https://github.com/optim-enterprises-bv/kubernetes.git
				synced 2025-11-04 04:08:16 +00:00 
			
		
		
		
	Avoid unnecessary DaemonSet collisionCount bump
This commit is contained in:
		@@ -19,6 +19,7 @@ package daemon
 | 
				
			|||||||
import (
 | 
					import (
 | 
				
			||||||
	"bytes"
 | 
						"bytes"
 | 
				
			||||||
	"fmt"
 | 
						"fmt"
 | 
				
			||||||
 | 
						"reflect"
 | 
				
			||||||
	"sort"
 | 
						"sort"
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	"github.com/golang/glog"
 | 
						"github.com/golang/glog"
 | 
				
			||||||
@@ -346,11 +347,15 @@ func (dsc *DaemonSetsController) snapshot(ds *apps.DaemonSet, revision int64) (*
 | 
				
			|||||||
		}
 | 
							}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
		// Handle name collisions between different history
 | 
							// Handle name collisions between different history
 | 
				
			||||||
		// TODO: Is it okay to get from dsLister?
 | 
							// Get the latest DaemonSet from the API server to make sure collision count is only increased when necessary
 | 
				
			||||||
		currDS, getErr := dsc.kubeClient.ExtensionsV1beta1().DaemonSets(ds.Namespace).Get(ds.Name, metav1.GetOptions{})
 | 
							currDS, getErr := dsc.kubeClient.ExtensionsV1beta1().DaemonSets(ds.Namespace).Get(ds.Name, metav1.GetOptions{})
 | 
				
			||||||
		if getErr != nil {
 | 
							if getErr != nil {
 | 
				
			||||||
			return nil, getErr
 | 
								return nil, getErr
 | 
				
			||||||
		}
 | 
							}
 | 
				
			||||||
 | 
							// If the collision count used to compute hash was in fact stale, there's no need to bump collision count; retry again
 | 
				
			||||||
 | 
							if !reflect.DeepEqual(currDS.Status.CollisionCount, ds.Status.CollisionCount) {
 | 
				
			||||||
 | 
								return nil, fmt.Errorf("found a stale collision count (%d, expected %d) of DaemonSet %q while processing; will retry until it is updated", ds.Status.CollisionCount, currDS.Status.CollisionCount, ds.Name)
 | 
				
			||||||
 | 
							}
 | 
				
			||||||
		if currDS.Status.CollisionCount == nil {
 | 
							if currDS.Status.CollisionCount == nil {
 | 
				
			||||||
			currDS.Status.CollisionCount = new(int32)
 | 
								currDS.Status.CollisionCount = new(int32)
 | 
				
			||||||
		}
 | 
							}
 | 
				
			||||||
 
 | 
				
			|||||||
		Reference in New Issue
	
	Block a user