mirror of
https://github.com/k3s-io/kubernetes.git
synced 2025-08-01 07:47:56 +00:00
kubectl: Check for Deployment overlap annotation in reaper.
This effectively reverts the client-side changes in
cec3899b96
.
We have to maintain the old behavior on the client side to support
version skew when talking to old servers that set the annotation.
However, the new server-side behavior is still to NOT set the
annotation.
This commit is contained in:
parent
b2525d43ed
commit
725ec0cc5e
@ -67,6 +67,10 @@ const (
|
|||||||
RollbackTemplateUnchanged = "DeploymentRollbackTemplateUnchanged"
|
RollbackTemplateUnchanged = "DeploymentRollbackTemplateUnchanged"
|
||||||
// RollbackDone is the done rollback event reason
|
// RollbackDone is the done rollback event reason
|
||||||
RollbackDone = "DeploymentRollback"
|
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
|
// Reasons for deployment conditions
|
||||||
//
|
//
|
||||||
@ -287,6 +291,7 @@ var annotationsToSkip = map[string]bool{
|
|||||||
RevisionHistoryAnnotation: true,
|
RevisionHistoryAnnotation: true,
|
||||||
DesiredReplicasAnnotation: true,
|
DesiredReplicasAnnotation: true,
|
||||||
MaxReplicasAnnotation: true,
|
MaxReplicasAnnotation: true,
|
||||||
|
OverlapAnnotation: true,
|
||||||
}
|
}
|
||||||
|
|
||||||
// skipCopyAnnotation returns true if we should skip copying the annotation with the given annotation key
|
// skipCopyAnnotation returns true if we should skip copying the annotation with the given annotation key
|
||||||
|
@ -440,6 +440,13 @@ func (reaper *DeploymentReaper) Stop(namespace, name string, timeout time.Durati
|
|||||||
return err
|
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.
|
// Stop all replica sets belonging to this Deployment.
|
||||||
rss, err := deploymentutil.ListReplicaSetsInternal(deployment,
|
rss, err := deploymentutil.ListReplicaSetsInternal(deployment,
|
||||||
func(namespace string, options metav1.ListOptions) ([]*extensions.ReplicaSet, error) {
|
func(namespace string, options metav1.ListOptions) ([]*extensions.ReplicaSet, error) {
|
||||||
|
@ -2441,6 +2441,10 @@ func (dd *DeploymentDescriber) Describe(namespace, name string, describerSetting
|
|||||||
}
|
}
|
||||||
w.Write(LEVEL_0, "NewReplicaSet:\t%s\n", printReplicaSetsByLabels(newRSs))
|
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 describerSettings.ShowEvents {
|
if describerSettings.ShowEvents {
|
||||||
events, err := dd.Core().Events(namespace).Search(api.Scheme, d)
|
events, err := dd.Core().Events(namespace).Search(api.Scheme, d)
|
||||||
if err == nil && events != nil {
|
if err == nil && events != nil {
|
||||||
|
Loading…
Reference in New Issue
Block a user