Skip to content

Commit

Permalink
adds lastUpdateTime to the nodeStatus
Browse files Browse the repository at this point in the history
  • Loading branch information
Maksym Trofimenko committed Feb 11, 2025
1 parent 38027de commit 7a3366a
Show file tree
Hide file tree
Showing 7 changed files with 26 additions and 6 deletions.
1 change: 1 addition & 0 deletions api-docs.md
Original file line number Diff line number Diff line change
Expand Up @@ -274,6 +274,7 @@ _Appears in:_
| `ports` _[TinyNodePortStatus](#tinynodeportstatus) array_ | |
| `status` _string_ | |
| `error` _boolean_ | |
| `lastUpdateTime` _[Time](https://kubernetes.io/docs/reference/generated/kubernetes-api/v1.27/#time-v1-meta)_ | |


#### TinySignal
Expand Down
8 changes: 5 additions & 3 deletions api/v1alpha1/tinynode_types.go
Original file line number Diff line number Diff line change
Expand Up @@ -44,9 +44,7 @@ const (

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

// ingress annotations
IngressHostNameSuffixAnnotation = "tinysystems.io/ingress-hostname-suffix"
IngressWildcardCertificateAnnotation = "tinysystems.io/ingress-wildcard-certificate"
IngressHostNameSuffixAnnotation = "tinysystems.io/ingress-hostname-suffix"
)

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

//+kubebuilder:validation:Optional
Error bool `json:"error,omitempty"`

//+kubebuilder:validation:Format:date-time
//+kubebuilder:validation:Optional
LastUpdateTime *metav1.Time `json:"lastUpdateTime,omitempty"`
}

//+kubebuilder:object:root=true
Expand Down
4 changes: 4 additions & 0 deletions api/v1alpha1/zz_generated.deepcopy.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion charts/tinysystems-crd/Chart.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ type: application
# This is the chart version. This version number should be incremented each time you make changes
# to the chart and its templates, including the app version.
# Versions are expected to follow Semantic Versioning (https://semver.org/)
version: 0.1.24
version: 0.1.25
# This is the version number of the application being deployed. This version number should be
# incremented each time you make changes to the application. Versions are not expected to
# follow Semantic Versioning. They should reflect the version the application is using.
Expand Down
5 changes: 4 additions & 1 deletion charts/tinysystems-crd/templates/tinynode-crd.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,7 @@ spec:
description: Module name - container image repo + tag
type: string
module_version:
default: '''1.0.0'''
default: 1.0.0
description: Module version semver v2 compatible (without v prefix)
type: string
ports:
Expand Down Expand Up @@ -121,6 +121,9 @@ spec:
type: object
error:
type: boolean
lastUpdateTime:
format: date-time
type: string
module:
properties:
name:
Expand Down
3 changes: 3 additions & 0 deletions config/crd/bases/operator.tinysystems.io_tinynodes.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -120,6 +120,9 @@ spec:
type: object
error:
type: boolean
lastUpdateTime:
format: date-time
type: string
module:
properties:
name:
Expand Down
9 changes: 8 additions & 1 deletion internal/controller/tinynode_controller.go
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@ import (
"github.com/tiny-systems/module/internal/scheduler"
"github.com/tiny-systems/module/module"
"k8s.io/apimachinery/pkg/api/errors"
v1 "k8s.io/apimachinery/pkg/apis/meta/v1"
"k8s.io/apimachinery/pkg/runtime"
"k8s.io/apimachinery/pkg/types"
"k8s.io/client-go/tools/record"
Expand All @@ -34,6 +35,7 @@ import (
"sigs.k8s.io/controller-runtime/pkg/log"
"sigs.k8s.io/controller-runtime/pkg/predicate"
"sigs.k8s.io/controller-runtime/pkg/reconcile"
"time"
)

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

t := v1.NewTime(time.Now())

status.LastUpdateTime = &t
// upsert in scheduler
// todo add app level context
err = r.Scheduler.Update(context.Background(), node)
Expand All @@ -119,7 +124,9 @@ func (r *TinyNodeReconciler) Reconcile(ctx context.Context, req ctrl.Request) (c
return reconcile.Result{}, err
}

return ctrl.Result{}, nil
return ctrl.Result{
RequeueAfter: time.Minute * 15,
}, nil
}

// SetupWithManager sets up the controller with the Manager.
Expand Down

0 comments on commit 7a3366a

Please sign in to comment.