Skip to content

Commit 00b7812

Browse files
committed
Quickly fail when deployment no longer exists
1 parent 0bdffbd commit 00b7812

File tree

1 file changed

+9
-0
lines changed

1 file changed

+9
-0
lines changed

pkg/deployment/deployment_inspector.go

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,7 @@ import (
2828

2929
api "github.com/arangodb/kube-arangodb/pkg/apis/deployment/v1alpha"
3030
"github.com/arangodb/kube-arangodb/pkg/util/k8sutil"
31+
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
3132
)
3233

3334
// inspectDeployment inspects the entire deployment, creates
@@ -44,6 +45,14 @@ func (d *Deployment) inspectDeployment(lastInterval time.Duration) time.Duration
4445
hasError := false
4546
ctx := context.Background()
4647

48+
// Check deployment still exists
49+
if _, err := d.deps.DatabaseCRCli.DatabaseV1alpha().ArangoDeployments(d.apiObject.GetNamespace()).Get(d.apiObject.GetName(), metav1.GetOptions{}); k8sutil.IsNotFound(err) {
50+
// Deployment is gone
51+
log.Info().Msg("Deployment is gone")
52+
d.Delete()
53+
return nextInterval
54+
}
55+
4756
// Is the deployment in failed state, if so, give up.
4857
if d.status.Phase == api.DeploymentPhaseFailed {
4958
log.Debug().Msg("Deployment is in Failed state.")

0 commit comments

Comments
 (0)