Skip to content

Commit 815cd47

Browse files
committed
Add field to tell if a workload is deleted
This state is usually temporary and should be resolved within minutes Fixes #64
1 parent b0671cd commit 815cd47

File tree

6 files changed

+86
-0
lines changed

6 files changed

+86
-0
lines changed

data/k8s/dev/devteam/no-logs-for-you.yaml

+1
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@ metadata:
66
nais.io/deploymentCorrelationID: f8c04f82-6a84-4a8e-9f8b-563b5894d0cf
77
nais.io/skipDeploymentMessage: "true"
88
creationTimestamp: "2023-01-20T10:51:47Z"
9+
deletionTimestamp: "2023-01-20T10:51:47Z"
910
finalizers:
1011
- naiserator.nais.io/finalizer
1112
generation: 407981

internal/graph/gengql/generated.go

+65
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

internal/graph/schema/applications.graphqls

+5
Original file line numberDiff line numberDiff line change
@@ -167,6 +167,11 @@ type Application implements Node & Workload {
167167
"""
168168
before: Cursor
169169
): ApplicationInstanceConnection!
170+
171+
"""
172+
If set, when the application was marked for deletion.
173+
"""
174+
deletedAt: Time
170175
}
171176

172177
"""

internal/workload/application/models.go

+7
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@ import (
1818
corev1 "k8s.io/api/core/v1"
1919
"k8s.io/apimachinery/pkg/api/resource"
2020
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
21+
"k8s.io/utils/ptr"
2122
)
2223

2324
type (
@@ -302,9 +303,15 @@ func toGraphApplication(application *nais_io_v1alpha1.Application, environmentNa
302303
logging = application.Spec.Observability.Logging
303304
}
304305

306+
var deletedAt *time.Time
307+
if application.DeletionTimestamp != nil {
308+
deletedAt = ptr.To(application.DeletionTimestamp.Time)
309+
}
310+
305311
return &Application{
306312
Base: workload.Base{
307313
Name: application.Name,
314+
DeletedAt: deletedAt,
308315
EnvironmentName: environmentName,
309316
TeamSlug: slug.Slug(application.Namespace),
310317
ImageString: application.Spec.Image,

internal/workload/job/models.go

+6
Original file line numberDiff line numberDiff line change
@@ -327,9 +327,15 @@ func toGraphJob(job *nais_io_v1.Naisjob, environmentName string) *Job {
327327
logging = job.Spec.Observability.Logging
328328
}
329329

330+
var deletedAt *time.Time
331+
if job.DeletionTimestamp != nil {
332+
deletedAt = ptr.To(job.DeletionTimestamp.Time)
333+
}
334+
330335
return &Job{
331336
Base: workload.Base{
332337
Name: job.Name,
338+
DeletedAt: deletedAt,
333339
EnvironmentName: environmentName,
334340
TeamSlug: slug.Slug(job.Namespace),
335341
ImageString: job.Spec.Image,

internal/workload/models.go

+2
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@ import (
55
"io"
66
"strconv"
77
"strings"
8+
"time"
89

910
"github.com/nais/api/internal/graph/ident"
1011
"github.com/nais/api/internal/graph/model"
@@ -49,6 +50,7 @@ type Base struct {
4950
RolloutCompleteTime int64 `json:"-"`
5051
Type Type `json:"-"`
5152
Logging *nais_io_v1.Logging `json:"-"`
53+
DeletedAt *time.Time `json:"deletedAt"`
5254
}
5355

5456
func (b Base) Image() *ContainerImage {

0 commit comments

Comments
 (0)