mirror of
https://github.com/k3s-io/kubernetes.git
synced 2025-08-12 05:21:58 +00:00
Delete evicted pet
If pet was evicted by kubelet - it will stuck in this state forever. By analogy to regular pod we need to re-create pet so that it will be re-scheduled to another node, so in order to re-create pet and preserve consitent naming we will delete it in petset controller and create after that. Change-Id: Ib98bf7f34b3f2ab1582b9de34b5f4c5f84cd5215
This commit is contained in:
parent
ebe733e469
commit
200f8c5c39
@ -96,7 +96,13 @@ func (p *petSyncer) Sync(pet *pcb) error {
|
||||
if err := p.SyncPVCs(pet); err != nil {
|
||||
return err
|
||||
}
|
||||
if exists {
|
||||
// if pet was evicted - we need to remove old one because of consistent naming
|
||||
if exists && isEvicted(realPet.pod) {
|
||||
glog.V(4).Infof("Delete evicted pod %v", realPet.pod.Name)
|
||||
if err := p.petClient.Delete(realPet); err != nil {
|
||||
return err
|
||||
}
|
||||
} else if exists {
|
||||
if !p.isHealthy(realPet.pod) {
|
||||
glog.Infof("PetSet %v waiting on unhealthy pet %v", pet.parent.Name, realPet.pod.Name)
|
||||
}
|
||||
@ -311,3 +317,7 @@ func (d *defaultPetHealthChecker) isHealthy(pod *api.Pod) bool {
|
||||
func (d *defaultPetHealthChecker) isDying(pod *api.Pod) bool {
|
||||
return pod != nil && pod.DeletionTimestamp != nil
|
||||
}
|
||||
|
||||
func isEvicted(pod *api.Pod) bool {
|
||||
return pod != nil && pod.Status.Phase == api.PodFailed && pod.Status.Reason == "Evicted"
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user