Skip to content

Commit

Permalink
GH-36 dns record lifecycle
Browse files Browse the repository at this point in the history
  • Loading branch information
maksymvavilov committed Apr 3, 2024
1 parent 1deaa27 commit 4e02c5f
Show file tree
Hide file tree
Showing 12 changed files with 158 additions and 54 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 @@ -65,6 +65,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.

2 changes: 1 addition & 1 deletion bundle/manifests/dns-operator.clusterserviceversion.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,7 @@ metadata:
capabilities: Basic Install
categories: Integration & Delivery
containerImage: quay.io/kuadrant/dns-operator:latest
createdAt: "2024-03-15T11:01:46Z"
createdAt: "2024-04-03T14:02:57Z"
description: A Kubernetes Operator to manage the lifecycle of DNS resources
operators.operatorframework.io/builder: operator-sdk-v1.33.0
operators.operatorframework.io/project_layout: go.kubebuilder.io/v4
Expand Down
20 changes: 20 additions & 0 deletions bundle/manifests/kuadrant.io_dnsrecords.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -242,6 +242,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 @@ -242,6 +242,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 4e02c5f

Please sign in to comment.