Skip to content

Commit

Permalink
Merge pull request #66 from Kuadrant/GH-36
Browse files Browse the repository at this point in the history
 GH-36 dns record lifecycle
  • Loading branch information
maleck13 authored Apr 11, 2024
2 parents 9e88ad4 + 1bb751a commit 0fd59e6
Show file tree
Hide file tree
Showing 12 changed files with 223 additions and 73 deletions.
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package conditions
package v1alpha1

type ConditionType string
type ConditionReason string
Expand Down
13 changes: 13 additions & 0 deletions api/v1alpha1/dnsrecord_types.go
Original file line number Diff line number Diff line change
Expand Up @@ -87,6 +87,19 @@ type DNSRecordStatus struct {
// +optional
ObservedGeneration int64 `json:"observedGeneration,omitempty"`

// QueuedAt is a time when DNS record was received for the reconciliation
QueuedAt metav1.Time `json:"queuedAt,omitempty"`

// QueuedFor is a time when we expect a DNS record to be reconciled again
QueuedFor metav1.Time `json:"queuedFor,omitempty"`

// ValidFor indicates duration since the last reconciliation we consider data in the record to be valid
ValidFor string `json:"validFor,omitempty"`

// WriteCounter represent a number of consecutive write attempts on the same generation of the record.
// It is being reset to 0 when the generation changes or there are no changes to write.
WriteCounter int64 `json:"writeCounter,omitempty"`

// endpoints are the last endpoints that were successfully published by the provider
//
// Provides a simple mechanism to store the current provider records in order to
Expand Down
2 changes: 2 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.

20 changes: 20 additions & 0 deletions bundle/manifests/kuadrant.io_dnsrecords.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -330,6 +330,26 @@ spec:
it needs to retry the update for that specific zone.
format: int64
type: integer
queuedAt:
description: QueuedAt is a time when DNS record was received for the
reconciliation
format: date-time
type: string
queuedFor:
description: QueuedFor is a time when we expect a DNS record to be
reconciled again
format: date-time
type: string
validFor:
description: ValidFor indicates duration since the last reconciliation
we consider data in the record to be valid
type: string
writeCounter:
description: WriteCounter represent a number of consecutive write
attempts on the same generation of the record. It is being reset
to 0 when the generation changes or there are no changes to write.
format: int64
type: integer
type: object
type: object
served: true
Expand Down
16 changes: 15 additions & 1 deletion cmd/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ package main
import (
"flag"
"os"
"time"

"k8s.io/apimachinery/pkg/runtime"
utilruntime "k8s.io/apimachinery/pkg/util/runtime"
Expand All @@ -43,6 +44,11 @@ var (
setupLog = ctrl.Log.WithName("setup")
)

const (
RequeueDuration = time.Minute * 15
ValidityDuration = time.Minute * 14
)

func init() {
utilruntime.Must(clientgoscheme.AddToScheme(scheme))

Expand All @@ -54,11 +60,19 @@ func main() {
var metricsAddr string
var enableLeaderElection bool
var probeAddr string
var requeueTime time.Duration
var validFor time.Duration
flag.StringVar(&metricsAddr, "metrics-bind-address", ":8080", "The address the metric endpoint binds to.")
flag.StringVar(&probeAddr, "health-probe-bind-address", ":8081", "The address the probe endpoint binds to.")
flag.BoolVar(&enableLeaderElection, "leader-elect", false,
"Enable leader election for controller manager. "+
"Enabling this will ensure there is only one active controller manager.")
flag.DurationVar(&requeueTime, "requeue-time", RequeueDuration,
"Duration for the validation reconciliation loop. "+
"Controls how ofter record is reconciled")
flag.DurationVar(&validFor, "valid-for", ValidityDuration,
"Duration when the record is considered to hold valid information"+
"Controls if we commit to the full reconcile loop")
opts := zap.Options{
Development: true,
}
Expand Down Expand Up @@ -94,7 +108,7 @@ func main() {
Client: mgr.GetClient(),
Scheme: mgr.GetScheme(),
ProviderFactory: providerFactory,
}).SetupWithManager(mgr); err != nil {
}).SetupWithManager(mgr, requeueTime, validFor); err != nil {
setupLog.Error(err, "unable to create controller", "controller", "DNSRecord")
os.Exit(1)
}
Expand Down
20 changes: 20 additions & 0 deletions config/crd/bases/kuadrant.io_dnsrecords.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -330,6 +330,26 @@ spec:
it needs to retry the update for that specific zone.
format: int64
type: integer
queuedAt:
description: QueuedAt is a time when DNS record was received for the
reconciliation
format: date-time
type: string
queuedFor:
description: QueuedFor is a time when we expect a DNS record to be
reconciled again
format: date-time
type: string
validFor:
description: ValidFor indicates duration since the last reconciliation
we consider data in the record to be valid
type: string
writeCounter:
description: WriteCounter represent a number of consecutive write
attempts on the same generation of the record. It is being reset
to 0 when the generation changes or there are no changes to write.
format: int64
type: integer
type: object
type: object
served: true
Expand Down
Loading

0 comments on commit 0fd59e6

Please sign in to comment.