Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix reconciliation on Endpoints's subset changes #1674

Merged
merged 1 commit into from
Jul 31, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -452,7 +452,7 @@ terratest: # Run terratest suite
echo -e "$(RED)Make sure you run the tests against at least two running clusters$(NC)" ;\
exit 1;\
fi
cd terratest/test/ && go mod download && CLUSTERS_NUMBER=$(RUNNING_CLUSTERS) go test -v -timeout 20m -parallel=12 --tags=$(TEST_TAGS)
cd terratest/test/ && go mod download && CLUSTERS_NUMBER=$(RUNNING_CLUSTERS) go test -v -timeout 25m -parallel=12 --tags=$(TEST_TAGS)

.PHONY: website
website:
Expand Down
1 change: 0 additions & 1 deletion controllers/gslb_controller_reconciliation.go
Original file line number Diff line number Diff line change
Expand Up @@ -169,7 +169,6 @@ func (r *GslbReconciler) Reconcile(ctx context.Context, req ctrl.Request) (ctrl.
return result.RequeueError(fmt.Errorf("getting GSLB servers (%s)", err))
}
gslb.Status.Servers = servers
fmt.Printf("got servers: %v\n", servers)
Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Debug statement that was forgotten from a previous commit


loadBalancerExposedIPs, err := refResolver.GetGslbExposedIPs(r.Client, r.Config.EdgeDNSServers)
if err != nil {
Expand Down
12 changes: 12 additions & 0 deletions controllers/gslb_controller_setup.go
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,7 @@ import (
"k8s.io/apimachinery/pkg/types"
ctrl "sigs.k8s.io/controller-runtime"
"sigs.k8s.io/controller-runtime/pkg/client"
"sigs.k8s.io/controller-runtime/pkg/client/apiutil"
"sigs.k8s.io/controller-runtime/pkg/controller/controllerutil"
"sigs.k8s.io/controller-runtime/pkg/event"
"sigs.k8s.io/controller-runtime/pkg/handler"
Expand Down Expand Up @@ -98,10 +99,21 @@ func (r *GslbReconciler) SetupWithManager(mgr ctrl.Manager) error {
if e.ObjectOld.GetGeneration() != e.ObjectNew.GetGeneration() {
return true
}

// endpoints don't have state, therefore they don't have a generation
// but when their subsets change they must be be reconciled
gvk, err := apiutil.GVKForObject(e.ObjectOld, r.Scheme)
if err != nil {
log.Warn().Msg("could not fetch GroupVersionKind for object")
} else if gvk.Kind == "Endpoints" {
return true
}

// Ignore reconciliation in case nothing has changed in k8gb annotations
oldAnnotations := e.ObjectOld.GetAnnotations()
newAnnotations := e.ObjectNew.GetAnnotations()
reconcile := !utils.EqualPredefinedAnnotations(oldAnnotations, newAnnotations, k8gbAnnotations...)

return reconcile
},
}).
Expand Down
1 change: 1 addition & 0 deletions controllers/logging/logr.go
Original file line number Diff line number Diff line change
Expand Up @@ -61,6 +61,7 @@ func (a *logrSinkAdapter) Info(_ int, msg string, keysAndValues ...interface{})
a.WithValues(keysAndValues)
if a.name != "" {
a.z.Info().Msgf("%s: %s %s", a.name, msg, a.valuesAsJSON())
return
Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The lack of this return was leading to duplicated log lines

}
a.z.Info().Msgf("%s %s", msg, a.valuesAsJSON())
}
Expand Down
2 changes: 1 addition & 1 deletion deploy/edge/deployment.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ spec:
name: zone-volume
containers:
- name: bind
image: internetsystemsconsortium/bind9:9.16
image: internetsystemsconsortium/bind9:9.18
ports:
- containerPort: 1053
protocol: TCP
Expand Down
60 changes: 0 additions & 60 deletions go.sum

Large diffs are not rendered by default.

2 changes: 0 additions & 2 deletions terratest/test/k8gb_weight_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -27,8 +27,6 @@ import (
)

func TestWeightsExistsInLocalDNSEndpoint(t *testing.T) {
t.Parallel()
Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

There were some random failures in this test, I had to remove parallelism to have it stable. One cluster was taking too long discovering the DNS entries of the other cluster, but I am not sure why.
Before:

   --- FAIL: TestWeightsExistsInLocalDNSEndpoint (337.85s)
      --- FAIL: TestWeightsExistsInLocalDNSEndpoint/with_gslb_only (245.38s)
      --- PASS: TestWeightsExistsInLocalDNSEndpoint/with_ref (92.48s)

After:

   --- PASS: TestWeightsExistsInLocalDNSEndpoint (195.55s)
      --- PASS: TestWeightsExistsInLocalDNSEndpoint/with_gslb_only (128.23s)
      --- PASS: TestWeightsExistsInLocalDNSEndpoint/with_ref (67.32s)


tests := []struct {
gslbPath string
ingressPath string
Expand Down
Loading