Skip to content

Commit 7a3366a

Browse files
author
Maksym Trofimenko
committed
adds lastUpdateTime to the nodeStatus
1 parent 38027de commit 7a3366a

File tree

7 files changed

+26
-6
lines changed

7 files changed

+26
-6
lines changed

api-docs.md

+1
Original file line numberDiff line numberDiff line change
@@ -274,6 +274,7 @@ _Appears in:_
274274
| `ports` _[TinyNodePortStatus](#tinynodeportstatus) array_ | |
275275
| `status` _string_ | |
276276
| `error` _boolean_ | |
277+
| `lastUpdateTime` _[Time](https://kubernetes.io/docs/reference/generated/kubernetes-api/v1.27/#time-v1-meta)_ | |
277278

278279

279280
#### TinySignal

api/v1alpha1/tinynode_types.go

+5-3
Original file line numberDiff line numberDiff line change
@@ -44,9 +44,7 @@ const (
4444

4545
SuggestedHttpPortAnnotation = "tinysystems.io/suggested-http-port"
4646

47-
// ingress annotations
48-
IngressHostNameSuffixAnnotation = "tinysystems.io/ingress-hostname-suffix"
49-
IngressWildcardCertificateAnnotation = "tinysystems.io/ingress-wildcard-certificate"
47+
IngressHostNameSuffixAnnotation = "tinysystems.io/ingress-hostname-suffix"
5048
)
5149

5250
// EDIT THIS FILE! THIS IS SCAFFOLDING FOR YOU TO OWN!
@@ -159,6 +157,10 @@ type TinyNodeStatus struct {
159157

160158
//+kubebuilder:validation:Optional
161159
Error bool `json:"error,omitempty"`
160+
161+
//+kubebuilder:validation:Format:date-time
162+
//+kubebuilder:validation:Optional
163+
LastUpdateTime *metav1.Time `json:"lastUpdateTime,omitempty"`
162164
}
163165

164166
//+kubebuilder:object:root=true

api/v1alpha1/zz_generated.deepcopy.go

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

charts/tinysystems-crd/Chart.yaml

+1-1
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ type: application
1313
# This is the chart version. This version number should be incremented each time you make changes
1414
# to the chart and its templates, including the app version.
1515
# Versions are expected to follow Semantic Versioning (https://semver.org/)
16-
version: 0.1.24
16+
version: 0.1.25
1717
# This is the version number of the application being deployed. This version number should be
1818
# incremented each time you make changes to the application. Versions are not expected to
1919
# follow Semantic Versioning. They should reflect the version the application is using.

charts/tinysystems-crd/templates/tinynode-crd.yaml

+4-1
Original file line numberDiff line numberDiff line change
@@ -71,7 +71,7 @@ spec:
7171
description: Module name - container image repo + tag
7272
type: string
7373
module_version:
74-
default: '''1.0.0'''
74+
default: 1.0.0
7575
description: Module version semver v2 compatible (without v prefix)
7676
type: string
7777
ports:
@@ -121,6 +121,9 @@ spec:
121121
type: object
122122
error:
123123
type: boolean
124+
lastUpdateTime:
125+
format: date-time
126+
type: string
124127
module:
125128
properties:
126129
name:

config/crd/bases/operator.tinysystems.io_tinynodes.yaml

+3
Original file line numberDiff line numberDiff line change
@@ -120,6 +120,9 @@ spec:
120120
type: object
121121
error:
122122
type: boolean
123+
lastUpdateTime:
124+
format: date-time
125+
type: string
123126
module:
124127
properties:
125128
name:

internal/controller/tinynode_controller.go

+8-1
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,7 @@ import (
2222
"github.com/tiny-systems/module/internal/scheduler"
2323
"github.com/tiny-systems/module/module"
2424
"k8s.io/apimachinery/pkg/api/errors"
25+
v1 "k8s.io/apimachinery/pkg/apis/meta/v1"
2526
"k8s.io/apimachinery/pkg/runtime"
2627
"k8s.io/apimachinery/pkg/types"
2728
"k8s.io/client-go/tools/record"
@@ -34,6 +35,7 @@ import (
3435
"sigs.k8s.io/controller-runtime/pkg/log"
3536
"sigs.k8s.io/controller-runtime/pkg/predicate"
3637
"sigs.k8s.io/controller-runtime/pkg/reconcile"
38+
"time"
3739
)
3840

3941
// TinyNodeReconciler reconciles a TinyNode object
@@ -102,6 +104,9 @@ func (r *TinyNodeReconciler) Reconcile(ctx context.Context, req ctrl.Request) (c
102104
status.Error = false
103105
status.Status = ""
104106

107+
t := v1.NewTime(time.Now())
108+
109+
status.LastUpdateTime = &t
105110
// upsert in scheduler
106111
// todo add app level context
107112
err = r.Scheduler.Update(context.Background(), node)
@@ -119,7 +124,9 @@ func (r *TinyNodeReconciler) Reconcile(ctx context.Context, req ctrl.Request) (c
119124
return reconcile.Result{}, err
120125
}
121126

122-
return ctrl.Result{}, nil
127+
return ctrl.Result{
128+
RequeueAfter: time.Minute * 15,
129+
}, nil
123130
}
124131

125132
// SetupWithManager sets up the controller with the Manager.

0 commit comments

Comments
 (0)