mirror of
https://github.com/k3s-io/kubernetes.git
synced 2025-08-04 18:00:08 +00:00
Deployment: Always set BlockOwnerDeletion in ControllerRef.
This commit is contained in:
parent
57fb5e2bba
commit
37534b66df
@ -296,7 +296,7 @@ func (m *ReplicaSetControllerRefManager) AdoptReplicaSet(replicaSet *extensions.
|
|||||||
// Note that ValidateOwnerReferences() will reject this patch if another
|
// Note that ValidateOwnerReferences() will reject this patch if another
|
||||||
// OwnerReference exists with controller=true.
|
// OwnerReference exists with controller=true.
|
||||||
addControllerPatch := fmt.Sprintf(
|
addControllerPatch := fmt.Sprintf(
|
||||||
`{"metadata":{"ownerReferences":[{"apiVersion":"%s","kind":"%s","name":"%s","uid":"%s","controller":true}],"uid":"%s"}}`,
|
`{"metadata":{"ownerReferences":[{"apiVersion":"%s","kind":"%s","name":"%s","uid":"%s","controller":true,"blockOwnerDeletion":true}],"uid":"%s"}}`,
|
||||||
m.controllerKind.GroupVersion(), m.controllerKind.Kind,
|
m.controllerKind.GroupVersion(), m.controllerKind.Kind,
|
||||||
m.controller.GetName(), m.controller.GetUID(), replicaSet.UID)
|
m.controller.GetName(), m.controller.GetUID(), replicaSet.UID)
|
||||||
return m.rsControl.PatchReplicaSet(replicaSet.Namespace, replicaSet.Name, []byte(addControllerPatch))
|
return m.rsControl.PatchReplicaSet(replicaSet.Namespace, replicaSet.Name, []byte(addControllerPatch))
|
||||||
|
@ -616,12 +616,14 @@ func (dc *DeploymentController) isScalingEvent(d *extensions.Deployment, rsList
|
|||||||
|
|
||||||
// newControllerRef returns a ControllerRef pointing to the deployment.
|
// newControllerRef returns a ControllerRef pointing to the deployment.
|
||||||
func newControllerRef(d *extensions.Deployment) *metav1.OwnerReference {
|
func newControllerRef(d *extensions.Deployment) *metav1.OwnerReference {
|
||||||
|
blockOwnerDeletion := true
|
||||||
isController := true
|
isController := true
|
||||||
return &metav1.OwnerReference{
|
return &metav1.OwnerReference{
|
||||||
APIVersion: controllerKind.GroupVersion().String(),
|
APIVersion: controllerKind.GroupVersion().String(),
|
||||||
Kind: controllerKind.Kind,
|
Kind: controllerKind.Kind,
|
||||||
Name: d.Name,
|
Name: d.Name,
|
||||||
UID: d.UID,
|
UID: d.UID,
|
||||||
Controller: &isController,
|
BlockOwnerDeletion: &blockOwnerDeletion,
|
||||||
|
Controller: &isController,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user