mirror of
				https://github.com/optim-enterprises-bv/kubernetes.git
				synced 2025-11-04 04:08:16 +00:00 
			
		
		
		
	Clean up Deployment overlap annotation code
This commit is contained in:
		@@ -594,20 +594,6 @@ func (dc *DeploymentController) syncDeployment(key string) error {
 | 
			
		||||
		return nil
 | 
			
		||||
	}
 | 
			
		||||
 | 
			
		||||
	// This is the point at which we used to add/remove the overlap annotation.
 | 
			
		||||
	// Now we always remove it if it exists, because it is obsolete as of 1.6.
 | 
			
		||||
	// Although the server no longer adds or looks at the annotation,
 | 
			
		||||
	// it's important to remove it from controllers created before the upgrade,
 | 
			
		||||
	// so that old clients (e.g. kubectl reaper) know they can no longer assume
 | 
			
		||||
	// the controller is blocked due to selector overlap and has no dependents.
 | 
			
		||||
	if _, ok := d.Annotations[util.OverlapAnnotation]; ok {
 | 
			
		||||
		delete(d.Annotations, util.OverlapAnnotation)
 | 
			
		||||
		d, err = dc.client.ExtensionsV1beta1().Deployments(d.Namespace).UpdateStatus(d)
 | 
			
		||||
		if err != nil {
 | 
			
		||||
			return fmt.Errorf("couldn't remove obsolete overlap annotation from deployment %v: %v", key, err)
 | 
			
		||||
		}
 | 
			
		||||
	}
 | 
			
		||||
 | 
			
		||||
	// List ReplicaSets owned by this Deployment, while reconciling ControllerRef
 | 
			
		||||
	// through adoption/orphaning.
 | 
			
		||||
	rsList, err := dc.getReplicaSetsForDeployment(d)
 | 
			
		||||
 
 | 
			
		||||
@@ -271,32 +271,6 @@ func TestSyncDeploymentCreatesReplicaSet(t *testing.T) {
 | 
			
		||||
	f.run(getKey(d, t))
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
func TestSyncDeploymentClearsOverlapAnnotation(t *testing.T) {
 | 
			
		||||
	f := newFixture(t)
 | 
			
		||||
 | 
			
		||||
	d := newDeployment("foo", 1, nil, nil, nil, map[string]string{"foo": "bar"})
 | 
			
		||||
	d.Annotations[util.OverlapAnnotation] = "overlap"
 | 
			
		||||
	f.dLister = append(f.dLister, d)
 | 
			
		||||
	f.objects = append(f.objects, d)
 | 
			
		||||
 | 
			
		||||
	rs := newReplicaSet(d, "deploymentrs-4186632231", 1)
 | 
			
		||||
 | 
			
		||||
	f.expectUpdateDeploymentStatusAction(d)
 | 
			
		||||
	f.expectCreateRSAction(rs)
 | 
			
		||||
	f.expectUpdateDeploymentStatusAction(d)
 | 
			
		||||
	f.expectUpdateDeploymentStatusAction(d)
 | 
			
		||||
 | 
			
		||||
	f.run(getKey(d, t))
 | 
			
		||||
 | 
			
		||||
	d, err := f.client.ExtensionsV1beta1().Deployments(d.Namespace).Get(d.Name, metav1.GetOptions{})
 | 
			
		||||
	if err != nil {
 | 
			
		||||
		t.Fatalf("can't get deployment: %v", err)
 | 
			
		||||
	}
 | 
			
		||||
	if _, ok := d.Annotations[util.OverlapAnnotation]; ok {
 | 
			
		||||
		t.Errorf("OverlapAnnotation = %q, wanted absent", d.Annotations[util.OverlapAnnotation])
 | 
			
		||||
	}
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
func TestSyncDeploymentDontDoAnythingDuringDeletion(t *testing.T) {
 | 
			
		||||
	f := newFixture(t)
 | 
			
		||||
 | 
			
		||||
 
 | 
			
		||||
@@ -65,11 +65,6 @@ const (
 | 
			
		||||
	RollbackTemplateUnchanged = "DeploymentRollbackTemplateUnchanged"
 | 
			
		||||
	// RollbackDone is the done rollback event reason
 | 
			
		||||
	RollbackDone = "DeploymentRollback"
 | 
			
		||||
	// OverlapAnnotation marks deployments with overlapping selector with other deployments
 | 
			
		||||
	// TODO: Delete this annotation when we no longer need to support a client
 | 
			
		||||
	//       talking to a server older than v1.6.
 | 
			
		||||
	OverlapAnnotation = "deployment.kubernetes.io/error-selector-overlapping-with"
 | 
			
		||||
 | 
			
		||||
	// Reasons for deployment conditions
 | 
			
		||||
	//
 | 
			
		||||
	// Progressing:
 | 
			
		||||
@@ -289,7 +284,6 @@ var annotationsToSkip = map[string]bool{
 | 
			
		||||
	RevisionHistoryAnnotation:      true,
 | 
			
		||||
	DesiredReplicasAnnotation:      true,
 | 
			
		||||
	MaxReplicasAnnotation:          true,
 | 
			
		||||
	OverlapAnnotation:              true,
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
// skipCopyAnnotation returns true if we should skip copying the annotation with the given annotation key
 | 
			
		||||
 
 | 
			
		||||
@@ -418,13 +418,6 @@ func (reaper *DeploymentReaper) Stop(namespace, name string, timeout time.Durati
 | 
			
		||||
		return err
 | 
			
		||||
	}
 | 
			
		||||
 | 
			
		||||
	// Do not cascade deletion for overlapping deployments.
 | 
			
		||||
	// A Deployment with this annotation will not create or manage anything,
 | 
			
		||||
	// so we can assume any matching ReplicaSets belong to another Deployment.
 | 
			
		||||
	if len(deployment.Annotations[deploymentutil.OverlapAnnotation]) > 0 {
 | 
			
		||||
		return deployments.Delete(name, nil)
 | 
			
		||||
	}
 | 
			
		||||
 | 
			
		||||
	// Stop all replica sets belonging to this Deployment.
 | 
			
		||||
	rss, err := deploymentutil.ListReplicaSetsInternal(deployment,
 | 
			
		||||
		func(namespace string, options metav1.ListOptions) ([]*extensions.ReplicaSet, error) {
 | 
			
		||||
 
 | 
			
		||||
@@ -2816,10 +2816,6 @@ func describeDeployment(d *versionedextension.Deployment, selector labels.Select
 | 
			
		||||
			}
 | 
			
		||||
			w.Write(LEVEL_0, "NewReplicaSet:\t%s\n", printReplicaSetsByLabels(newRSs))
 | 
			
		||||
		}
 | 
			
		||||
		overlapWith := d.Annotations[deploymentutil.OverlapAnnotation]
 | 
			
		||||
		if len(overlapWith) > 0 {
 | 
			
		||||
			w.Write(LEVEL_0, "!!!WARNING!!! This deployment has overlapping label selector with deployment %q and won't behave as expected. Please fix it before continuing.\n", overlapWith)
 | 
			
		||||
		}
 | 
			
		||||
		if events != nil {
 | 
			
		||||
			DescribeEvents(events, w)
 | 
			
		||||
		}
 | 
			
		||||
 
 | 
			
		||||
		Reference in New Issue
	
	Block a user