From f4c1b4defa4f12c3233fe834198308eb35ede778 Mon Sep 17 00:00:00 2001 From: Joao Morais Date: Wed, 1 May 2024 12:05:42 -0300 Subject: [PATCH] local building improvements Building local image in the same arch of the host. This avoids the need of running under an emulator on m1/arm envs. Minor updates on comments and public methods as well. --- Makefile | 2 +- README.md | 3 +-- pkg/controller/services/svcleader.go | 8 ++++---- pkg/controller/services/svcstatusing.go | 3 --- 4 files changed, 6 insertions(+), 10 deletions(-) diff --git a/Makefile b/Makefile index e817b4d1..c3957fa8 100644 --- a/Makefile +++ b/Makefile @@ -2,7 +2,7 @@ default: build GOOS=linux -GOARCH?=amd64 +GOARCH?=$(shell go env GOARCH) GIT_REPO=$(shell git config --get remote.origin.url) GIT_COMMIT=git-$(shell git rev-parse --short HEAD) VERSION_PKG=github.com/jcmoraisjr/haproxy-ingress/pkg/version diff --git a/README.md b/README.md index b2e971dd..5c2553ea 100644 --- a/README.md +++ b/README.md @@ -56,13 +56,12 @@ Dependencies to run locally: * Golang * HAProxy compiled with `USE_OPENSSL=1` and `USE_LUA=1` -* [golangci-lint](https://golangci-lint.run/) is used when running `make lint` or `make test` targets * Lua with `lua-json` (`luarocks install lua-json`) if using Auth External or OAuth * Kubernetes network should be reachable from the local machine for a proper e2e test **Building container image:** -Fast build - cross compile for linux/amd64 (locally) and generate `localhost/haproxy-ingress:latest`: +Fast build - cross compile for linux (locally) and generate `localhost/haproxy-ingress:latest`: ``` make image diff --git a/pkg/controller/services/svcleader.go b/pkg/controller/services/svcleader.go index c3260e8e..c2a1de2c 100644 --- a/pkg/controller/services/svcleader.go +++ b/pkg/controller/services/svcleader.go @@ -71,8 +71,8 @@ func initSvcLeader(ctx context.Context, cfg *config.Config) (*svcLeader, error) RenewDeadline: defaultRenewDeadline, RetryPeriod: defaultRetryPeriod, Callbacks: leaderelection.LeaderCallbacks{ - OnStartedLeading: s.OnStartedLeading, - OnStoppedLeading: s.OnStoppedLeading, + OnStartedLeading: s.onStartedLeading, + OnStoppedLeading: s.onStoppedLeading, }, }) if err != nil { @@ -101,7 +101,7 @@ func (s *svcLeader) Start(ctx context.Context) error { return nil } -func (s *svcLeader) OnStartedLeading(ctx context.Context) { +func (s *svcLeader) onStartedLeading(ctx context.Context) { s.log.Info("leader acquired") ctxwg, cancel := context.WithCancel(ctx) @@ -120,7 +120,7 @@ func (s *svcLeader) OnStartedLeading(ctx context.Context) { } } -func (s *svcLeader) OnStoppedLeading() { +func (s *svcLeader) onStoppedLeading() { for _, f := range s.subscribers { go f(s.ctx, false) } diff --git a/pkg/controller/services/svcstatusing.go b/pkg/controller/services/svcstatusing.go index e3417d4d..968bb1cf 100644 --- a/pkg/controller/services/svcstatusing.go +++ b/pkg/controller/services/svcstatusing.go @@ -38,9 +38,6 @@ import ( ) func initSvcStatusIng(ctx context.Context, config *config.Config, client client.Client, cache *c, status svcStatusUpdateFnc) *svcStatusIng { - // TODO this service mimics the old controller behavior but it might worth - // to make a refactor, e.g. watching ingress pod updates or lb service, - // depending on how the hostname/ip are read return &svcStatusIng{ log: logr.FromContextOrDiscard(ctx).WithName("status").WithName("ingress"), cfg: config,