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

Convert to controller runtime runnables #4202

Merged
Show file tree
Hide file tree
Changes from 3 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
9 changes: 7 additions & 2 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -205,7 +205,7 @@ lint-flags:

.PHONY: generate
generate: ## Re-generate generated code and documentation
generate: generate-rbac generate-crd-deepcopy generate-crd-yaml generate-gateway-crd-yaml generate-deployment generate-api-docs generate-metrics-docs generate-uml
generate: generate-rbac generate-crd-deepcopy generate-crd-yaml generate-gateway-crd-yaml generate-deployment generate-api-docs generate-metrics-docs generate-uml generate-go

.PHONY: generate-rbac
generate-rbac:
Expand Down Expand Up @@ -240,9 +240,14 @@ generate-api-docs:

.PHONY: generate-metrics-docs
generate-metrics-docs:
@echo Generating metrics documentation ...
@echo "Generating metrics documentation..."
@cd site/content/guides/metrics && rm -f *.md && go run ../../../../hack/generate-metrics-doc.go

.PHONY: generate-go
generate-go:
@echo "Generating mocks..."
@go generate ./...

.PHONY: check-generate
check-generate: generate
@./hack/actions/check-uncommitted-codegen.sh
Expand Down
17 changes: 5 additions & 12 deletions cmd/contour/ingressstatus.go
Original file line number Diff line number Diff line change
Expand Up @@ -48,23 +48,16 @@ import (
type loadBalancerStatusWriter struct {
log logrus.FieldLogger
cache cache.Cache
isLeader chan struct{}
lbStatus chan v1.LoadBalancerStatus
statusUpdater k8s.StatusUpdater
ingressClassName string
}

func (isw *loadBalancerStatusWriter) Start(stop <-chan struct{}) error {
// Await leadership election.
isw.log.Info("awaiting leadership election")
select {
case <-stop:
// We were asked to stop before elected leader.
return nil
case <-isw.isLeader:
isw.log.Info("elected leader")
}
func (isw *loadBalancerStatusWriter) NeedLeaderElection() bool {
return true
}

func (isw *loadBalancerStatusWriter) Start(ctx context.Context) error {
u := &k8s.StatusAddressUpdater{
Logger: func() logrus.FieldLogger {
// Configure the StatusAddressUpdater logger.
Expand Down Expand Up @@ -98,7 +91,7 @@ func (isw *loadBalancerStatusWriter) Start(stop <-chan struct{}) error {

for {
select {
case <-stop:
case <-ctx.Done():
// Once started, there's no way to stop the
// informer from here. Clear the load balancer
// status so that subsequent informer events
Expand Down
6 changes: 6 additions & 0 deletions cmd/contour/ingressstatus_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ import (

"github.com/google/go-cmp/cmp"
"github.com/stretchr/testify/assert"
"github.com/stretchr/testify/require"
v1 "k8s.io/api/core/v1"
)

Expand Down Expand Up @@ -194,3 +195,8 @@ func Test_lbAddress(t *testing.T) {
})
}
}

func TestRequireLeaderElection(t *testing.T) {
l := loadBalancerStatusWriter{}
require.True(t, l.NeedLeaderElection())
}
157 changes: 0 additions & 157 deletions cmd/contour/leadership.go

This file was deleted.

Loading