mirror of
https://github.com/arangodb/kube-arangodb.git
synced 2024-12-14 11:57:37 +00:00
[Bugfix] Prevent deployment removal in case of invalid K8S API response (#1063)
This commit is contained in:
parent
4e5015a2e5
commit
72a6535191
4 changed files with 5 additions and 16 deletions
|
@ -10,6 +10,7 @@
|
||||||
- (Feature) Add 'crd install' subcommand
|
- (Feature) Add 'crd install' subcommand
|
||||||
- (Bugfix) Fix `internal` metrics mode
|
- (Bugfix) Fix `internal` metrics mode
|
||||||
- (Bugfix) Create agency dump if auth is disabled
|
- (Bugfix) Create agency dump if auth is disabled
|
||||||
|
- (Bugfix) Prevent deployment removal in case of invalid K8S API response
|
||||||
|
|
||||||
## [1.2.14](https://github.com/arangodb/kube-arangodb/tree/1.2.14) (2022-07-14)
|
## [1.2.14](https://github.com/arangodb/kube-arangodb/tree/1.2.14) (2022-07-14)
|
||||||
- (Feature) Add ArangoSync TLS based rotation
|
- (Feature) Add ArangoSync TLS based rotation
|
||||||
|
|
|
@ -293,9 +293,9 @@ func (d *Deployment) Update(apiObject *api.ArangoDeployment) {
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
// Delete the deployment.
|
// Stop the deployment.
|
||||||
// Called when the deployment was deleted by the user.
|
// Called when the deployment was deleted by the user.
|
||||||
func (d *Deployment) Delete() {
|
func (d *Deployment) Stop() {
|
||||||
d.log.Info("deployment is deleted by user")
|
d.log.Info("deployment is deleted by user")
|
||||||
if atomic.CompareAndSwapInt32(&d.stopped, 0, 1) {
|
if atomic.CompareAndSwapInt32(&d.stopped, 0, 1) {
|
||||||
close(d.stopCh)
|
close(d.stopCh)
|
||||||
|
@ -359,18 +359,6 @@ func (d *Deployment) run() {
|
||||||
for {
|
for {
|
||||||
select {
|
select {
|
||||||
case <-d.stopCh:
|
case <-d.stopCh:
|
||||||
err := d.acs.CurrentClusterCache().Refresh(context.Background())
|
|
||||||
if err != nil {
|
|
||||||
log.Err(err).Error("Unable to get resources")
|
|
||||||
}
|
|
||||||
// Remove finalizers from created resources
|
|
||||||
log.Info("Deployment removed, removing finalizers to prevent orphaned resources")
|
|
||||||
if _, err := d.removePodFinalizers(context.TODO(), d.GetCachedStatus()); err != nil {
|
|
||||||
log.Err(err).Warn("Failed to remove Pod finalizers")
|
|
||||||
}
|
|
||||||
if _, err := d.removePVCFinalizers(context.TODO(), d.GetCachedStatus()); err != nil {
|
|
||||||
log.Err(err).Warn("Failed to remove PVC finalizers")
|
|
||||||
}
|
|
||||||
// We're being stopped.
|
// We're being stopped.
|
||||||
return
|
return
|
||||||
|
|
||||||
|
|
|
@ -74,7 +74,7 @@ func (d *Deployment) inspectDeployment(lastInterval util.Interval) util.Interval
|
||||||
if k8sutil.IsNotFound(err) {
|
if k8sutil.IsNotFound(err) {
|
||||||
// Deployment is gone
|
// Deployment is gone
|
||||||
d.log.Info("Deployment is gone")
|
d.log.Info("Deployment is gone")
|
||||||
d.Delete()
|
d.Stop()
|
||||||
return nextInterval
|
return nextInterval
|
||||||
} else if updated != nil && updated.GetDeletionTimestamp() != nil {
|
} else if updated != nil && updated.GetDeletionTimestamp() != nil {
|
||||||
// Deployment is marked for deletion
|
// Deployment is marked for deletion
|
||||||
|
|
|
@ -185,7 +185,7 @@ func (o *Operator) handleDeploymentEvent(event *Event) error {
|
||||||
if !ok {
|
if !ok {
|
||||||
return errors.WithStack(errors.Newf("unsafe state. deployment (%s) was never created but we received event (%s)", apiObject.Name, event.Type))
|
return errors.WithStack(errors.Newf("unsafe state. deployment (%s) was never created but we received event (%s)", apiObject.Name, event.Type))
|
||||||
}
|
}
|
||||||
depl.Delete()
|
depl.Stop()
|
||||||
delete(o.deployments, apiObject.Name)
|
delete(o.deployments, apiObject.Name)
|
||||||
deploymentsDeleted.Inc()
|
deploymentsDeleted.Inc()
|
||||||
deploymentsCurrent.Set(float64(len(o.deployments)))
|
deploymentsCurrent.Set(float64(len(o.deployments)))
|
||||||
|
|
Loading…
Reference in a new issue