Skip to content

Commit

Permalink
Fixed minor issues
Browse files Browse the repository at this point in the history
Signed-off-by: Patryk Strusiewicz-Surmacki <[email protected]>
  • Loading branch information
p-strusiewiczsurmacki-mobica committed Aug 19, 2024
1 parent 0d73d3c commit 672e19a
Show file tree
Hide file tree
Showing 7 changed files with 29 additions and 18 deletions.
2 changes: 1 addition & 1 deletion Dockerfile
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
# Build the manager binary
FROM docker.io/library/golang:1.21-alpine as builder
FROM docker.io/library/golang:1.21-alpine AS builder


WORKDIR /workspace
Expand Down
2 changes: 1 addition & 1 deletion agent.Dockerfile
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
# Build the manager binary
FROM docker.io/library/golang:1.21-alpine as builder
FROM docker.io/library/golang:1.21-alpine AS builder


WORKDIR /workspace
Expand Down
4 changes: 2 additions & 2 deletions api/v1alpha1/networkconfigrevision_types.go
Original file line number Diff line number Diff line change
Expand Up @@ -50,10 +50,10 @@ type NetworkConfigRevisionStatus struct {
//+kubebuilder:subresource:status
//+kubebuilder:resource:shortName=ncr,scope=Cluster
//+kubebuilder:printcolumn:name="Invalid",type=string,JSONPath=`.status.isInvalid`
//+kubebuilder:printcolumn:name="Queued",type="integer",JSONPath=".status.queued"
//+kubebuilder:printcolumn:name="Ongoing",type="integer",JSONPath=".status.ongoing"
//+kubebuilder:printcolumn:name="Ready",type="integer",JSONPath=".status.ready"
//+kubebuilder:printcolumn:name="Queued",type="integer",JSONPath=".status.queued"
//+kubebuilder:printcolumn:name="Available",type="integer",JSONPath=".status.available"
//+kubebuilder:printcolumn:name="Total",type="integer",JSONPath=".status.total"
//+kubebuilder:printcolumn:name="Age",type="date",JSONPath=".metadata.creationTimestamp"

// NetworkConfigRevision is the Schema for the node configuration.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,17 +20,17 @@ spec:
- jsonPath: .status.isInvalid
name: Invalid
type: string
- jsonPath: .status.queued
name: Queued
type: integer
- jsonPath: .status.ongoing
name: Ongoing
type: integer
- jsonPath: .status.ready
name: Ready
type: integer
- jsonPath: .status.queued
name: Queued
type: integer
- jsonPath: .status.available
name: Available
- jsonPath: .status.total
name: Total
type: integer
- jsonPath: .metadata.creationTimestamp
name: Age
Expand Down
2 changes: 1 addition & 1 deletion frr-exporter.Dockerfile
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
ARG FRR_VERSION="10.1.0"
ARG REGISTRY="quay.io"
# Build the manager binary
FROM docker.io/library/golang:1.21-alpine as builder
FROM docker.io/library/golang:1.21-alpine AS builder

WORKDIR /workspace
# Copy the Go Modules manifests
Expand Down
20 changes: 15 additions & 5 deletions pkg/reconciler/config_reconciler.go
Original file line number Diff line number Diff line change
Expand Up @@ -91,7 +91,7 @@ func (cr *ConfigReconciler) ReconcileDebounced(ctx context.Context) error {

// create revision object
if err := r.createRevision(timeoutCtx, revision); err != nil {
return fmt.Errorf("error creating revision %s: %w", revision.Spec.Revision, err)
return fmt.Errorf("error creating revision %s: %w", revision.Spec.Revision[0:10], err)
}

cr.logger.Info("deployed", "revision", revision.Spec.Revision)
Expand All @@ -113,14 +113,24 @@ func cleanRevisionStatus(ctx context.Context, revision *v1alpha1.NetworkConfigRe
}

func shouldSkip(revisions *v1alpha1.NetworkConfigRevisionList, processedRevision *v1alpha1.NetworkConfigRevision) bool {
if len(revisions.Items) > 0 && processedRevision.Spec.Revision == revisions.Items[0].Spec.Revision {
// new revision equals to the last known one - skip
if len(revisions.Items) > 0 && revisions.Items[0].Spec.Revision == processedRevision.Spec.Revision {
// new revision equals to the last known one - skip (no update is required)
return true
}

for i := range revisions.Items {
if (processedRevision.Spec.Revision == revisions.Items[i].Spec.Revision) && revisions.Items[i].Status.IsInvalid {
// new revision is equal to known invalid revision
if !revisions.Items[i].Status.IsInvalid {
if revisions.Items[i].Spec.Revision == processedRevision.Spec.Revision {
// new revision equals to the last known valid one - skip (should be already deployed)
return true
}
break
}
}

for i := range revisions.Items {
if (revisions.Items[i].Spec.Revision == processedRevision.Spec.Revision) && revisions.Items[i].Status.IsInvalid {
// new revision is equal to known invalid revision - skip
return true
}
}
Expand Down
7 changes: 4 additions & 3 deletions pkg/reconciler/nodeconfig_reconciler.go
Original file line number Diff line number Diff line change
Expand Up @@ -145,10 +145,10 @@ func (ncr *NodeConfigReconciler) processConfigs(ctx context.Context, configs []v
return true, ready, ongoing, fmt.Errorf("error invalidating revision %s: %w", revision.Name, err)
}
return true, ready, ongoing, nil
case StatusProvisioning:
case StatusProvisioning, "":
// Update ongoing counter
ongoing++
// If status is 'provisioning' check for how long this status is set already, and if time threshold is exceeded, tag config as invalid.
// If status is 'provisioning' or empty check for how long this status is set already, and if time configTimeout is exceeded, tag config as invalid.
if time.Now().After(configs[i].Status.LastUpdate.Add(configTimeout)) {
configs[i].Status.ConfigStatus = StatusInvalid
configs[i].Status.LastUpdate = metav1.Now()
Expand Down Expand Up @@ -363,7 +363,8 @@ func (ncr *NodeConfigReconciler) deployConfig(ctx context.Context, newConfig, cu
}
}

if err := setStatus(ctx, ncr.client, cfg, ""); err != nil {
if err := setStatus(ctx, ncr.client, cfg, ""); err != nil && !apierrors.IsConflict(err) {
// discard conflict error as it can be encountered if agent will update NodeNetworkConfig status first (race condition)
return fmt.Errorf("error setting config '%s' status: %w", cfg.Name, err)
}

Expand Down

0 comments on commit 672e19a

Please sign in to comment.