Skip to content

Commit 88e3f16

Browse files
Merge pull request #2814 from Nordix/peppi-lotta/add-more-pr-checks-for-fkas
🌱 Add build test in PR checks for FKAS
2 parents b30878e + f331dba commit 88e3f16

File tree

7 files changed

+250
-251
lines changed

7 files changed

+250
-251
lines changed

Makefile

Lines changed: 15 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -42,6 +42,7 @@ TEST_DIR := test
4242
BIN_DIR := bin
4343
TOOLS_BIN_DIR := $(abspath $(TOOLS_DIR)/$(BIN_DIR))
4444
FAKE_APISERVER_DIR := hack/fake-apiserver
45+
MAKE_ROOT_DIR := $(CURDIR)
4546

4647
# Set --output-base for conversion-gen if we are not within GOPATH
4748
ifneq ($(abspath $(ROOT_DIR)),$(shell $(GO) env GOPATH)/src/github.com/metal3-io/cluster-api-provider-metal3)
@@ -357,6 +358,10 @@ build-api: ## Builds api directory.
357358
build-e2e: ## Builds test directory.
358359
cd $(TEST_DIR) && $(GO) build ./...
359360

361+
.PHONY: build-fkas
362+
build-fkas: ## Builds fkas directory.
363+
cd $(FAKE_APISERVER_DIR) && $(GO) build ./...
364+
360365
## --------------------------------------
361366
## Tooling Binaries
362367
## --------------------------------------
@@ -552,13 +557,20 @@ docker-build: ## Build the docker image for controller-manager
552557
docker-push: ## Push the docker image
553558
docker push $(CONTROLLER_IMG)-$(ARCH):$(TAG)
554559

555-
.PHONY: build-fkas
560+
.PHONY: docker-build-fkas
556561
# Allow overriding this by setting CONTAINER_RUNTIME var
557562
CONTAINER_RUNTIME := $(if $(CONTAINER_RUNTIME),$(CONTAINER_RUNTIME),docker)
558563
export CONTAINER_RUNTIME
559564

560-
build-fkas:
561-
cd $(FAKE_APISERVER_DIR) && $(CONTAINER_RUNTIME) build --build-arg ARCH=$(ARCH) -t "quay.io/metal3-io/metal3-fkas:latest" .
565+
docker-build-fkas:
566+
cp -r $(FAKE_APISERVER_DIR) /tmp && \
567+
mkdir -p /tmp/fake-apiserver/capm3 && \
568+
cp -r ./api /tmp/fake-apiserver/capm3 && \
569+
cd /tmp/fake-apiserver && \
570+
$(GO) mod edit -replace=github.com/metal3-io/cluster-api-provider-metal3=./capm3 && \
571+
$(GO) mod tidy && \
572+
$(CONTAINER_RUNTIME) build --build-arg ARCH=$(ARCH) -t "quay.io/metal3-io/metal3-fkas:latest" . || true
573+
rm -rf /tmp/fake-apiserver
562574

563575
## --------------------------------------
564576
## Docker — All ARCH

hack/build.sh

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,13 +6,20 @@ set -eux
66
IS_CONTAINER="${IS_CONTAINER:-false}"
77
CONTAINER_RUNTIME="${CONTAINER_RUNTIME:-podman}"
88
WORKDIR="${WORKDIR:-/workdir}"
9+
BUILD_FKAS="${BUILD_FKAS:-false}"
10+
911

1012
if [ "${IS_CONTAINER}" != "false" ]; then
1113
export XDG_CACHE_HOME=/tmp/.cache
1214
mkdir /tmp/build
1315
cp -r . /tmp/build
1416
cd /tmp/build
15-
make build
17+
18+
if [ "${BUILD_FKAS}" != "false" ]; then
19+
make build-fkas
20+
else
21+
make build
22+
fi
1623
else
1724
"${CONTAINER_RUNTIME}" run --rm \
1825
--env IS_CONTAINER=TRUE \

hack/fake-apiserver/Dockerfile

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@
1313
# limitations under the License.
1414

1515
# Support FROM override
16-
ARG BUILD_IMAGE=docker.io/golang:1.24.6@sha256:2c89c41fb9efc3807029b59af69645867cfe978d2b877d475be0d72f6c6ce6f6
16+
ARG BUILD_IMAGE=docker.io/golang:1.24.7@sha256:5e9d14d681c3224276f0c8e318525ef6fc96b47fbcbb89f8bec0e402e18ea8bf
1717
ARG BASE_IMAGE=gcr.io/distroless/static:nonroot@sha256:9ecc53c269509f63c69a266168e4a687c7eb8c0cfd753bd8bfcaa4f58a90876f
1818

1919
# Build the fkas binary on golang image
@@ -27,12 +27,13 @@ ENV GOPROXY=$goproxy
2727
# Copy the Go Modules manifests
2828
COPY go.mod go.sum ./
2929

30+
COPY capm3 ./capm3
3031
# Cache deps before building and copying source so that we don't need to re-download as much
3132
# and so that source changes don't invalidate our downloaded layer
3233
RUN go mod download
3334

3435
# Build Fkas
35-
FROM base AS build-fkas
36+
FROM base AS docker-build-fkas
3637

3738
# Copy the sources
3839
COPY cmd/metal3-fkas/*.go ./
@@ -44,7 +45,7 @@ RUN CGO_ENABLED=0 GOOS=linux GOARCH=${ARCH} \
4445
-o fkas .
4546

4647
# Build fkas-reconciler
47-
FROM base AS build-fkas-reconciler
48+
FROM base AS docker-build-fkas-reconciler
4849

4950
# Copy the sources
5051
COPY cmd/metal3-fkas-reconciler/*.go ./
@@ -59,7 +60,7 @@ RUN CGO_ENABLED=0 GOOS=linux GOARCH=${ARCH} \
5960
FROM $BASE_IMAGE
6061
WORKDIR /
6162
# Use uid of nonroot user (65532) because kubernetes expects numeric user when applying pod security policies
62-
COPY --from=build-fkas /workspace/fkas .
63-
COPY --from=build-fkas-reconciler /workspace/reconciler .
63+
COPY --from=docker-build-fkas /workspace/fkas .
64+
COPY --from=docker-build-fkas-reconciler /workspace/reconciler .
6465
USER 65532
6566
ENTRYPOINT ["/fkas"]

hack/fake-apiserver/cmd/metal3-fkas-reconciler/main.go

Lines changed: 8 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -11,11 +11,10 @@ import (
1111

1212
bmov1alpha1 "github.com/metal3-io/baremetal-operator/apis/metal3.io/v1alpha1"
1313
infrav1 "github.com/metal3-io/cluster-api-provider-metal3/api/v1beta1"
14-
"github.com/metal3-io/cluster-api-provider-metal3/baremetal"
1514
"go.uber.org/zap/zapcore"
1615
"k8s.io/apimachinery/pkg/runtime"
1716
rest "k8s.io/client-go/rest"
18-
clusterv1 "sigs.k8s.io/cluster-api/api/v1beta1"
17+
clusterv1beta1 "sigs.k8s.io/cluster-api/api/core/v1beta1"
1918
ctrl "sigs.k8s.io/controller-runtime"
2019
"sigs.k8s.io/controller-runtime/pkg/client"
2120
"sigs.k8s.io/controller-runtime/pkg/log"
@@ -24,6 +23,10 @@ import (
2423
"sigs.k8s.io/controller-runtime/pkg/reconcile"
2524
)
2625

26+
const (
27+
VerbosityLevelDebug = 4
28+
)
29+
2730
func main() {
2831
// Set up logger
2932
debug := os.Getenv("DEBUG")
@@ -53,7 +56,7 @@ func main() {
5356
setupLog.Error(err, "Error adding Metal3Machine to scheme")
5457
}
5558

56-
if err = clusterv1.AddToScheme(scheme); err != nil {
59+
if err = clusterv1beta1.AddToScheme(scheme); err != nil {
5760
setupLog.Error(err, "Error adding Machine to scheme")
5861
}
5962

@@ -76,7 +79,7 @@ func main() {
7679

7780
// Check if the state has changed to "provisioned"
7881
if bmh.Status.Provisioning.State != "provisioned" {
79-
setupLog.V(baremetal.VerbosityLevelDebug).Info(fmt.Sprintf("BMH %s/%s state is not in 'provisioning' or 'provisioned' state.", req.Namespace, req.Name))
82+
setupLog.V(VerbosityLevelDebug).Info(fmt.Sprintf("BMH %s/%s state is not in 'provisioning' or 'provisioned' state.", req.Namespace, req.Name))
8083
return reconcile.Result{}, nil
8184
}
8285
uuid := bmh.ObjectMeta.UID
@@ -100,7 +103,7 @@ func main() {
100103

101104
machineName := m3m.ObjectMeta.OwnerReferences[0].Name
102105
namespace := m3m.Namespace
103-
machine := &clusterv1.Machine{}
106+
machine := &clusterv1beta1.Machine{}
104107
machineKey := client.ObjectKey{
105108
Namespace: namespace,
106109
Name: machineName,

hack/fake-apiserver/cmd/metal3-fkas/main.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -89,7 +89,7 @@ func register(w http.ResponseWriter, r *http.Request) {
8989
}
9090

9191
resp.Host = listener.Host()
92-
resp.Port = listener.Port()
92+
resp.Port = int(listener.Port())
9393

9494
workloadListenerActivations[listenerName] = false
9595

hack/fake-apiserver/go.mod

Lines changed: 62 additions & 60 deletions
Original file line numberDiff line numberDiff line change
@@ -1,30 +1,36 @@
11
module github.com/metal3-io/cluster-api-provider-metal3/hack/fake-apiserver
22

3-
go 1.23.7
3+
go 1.24.0
44

55
require (
6-
github.com/metal3-io/baremetal-operator/apis v0.10.3
7-
github.com/metal3-io/cluster-api-provider-metal3/api v1.10.2
6+
github.com/metal3-io/baremetal-operator/apis v0.11.0
7+
github.com/metal3-io/cluster-api-provider-metal3/api v1.11.0
88
go.uber.org/zap v1.27.0
9-
k8s.io/api v0.32.9
10-
k8s.io/apimachinery v0.32.9
11-
k8s.io/client-go v0.32.9
12-
sigs.k8s.io/cluster-api v1.10.6
13-
sigs.k8s.io/cluster-api/test v1.10.4
14-
sigs.k8s.io/controller-runtime v0.20.4
9+
k8s.io/api v0.34.1
10+
k8s.io/apimachinery v0.34.1
11+
k8s.io/client-go v0.34.1
12+
sigs.k8s.io/cluster-api v1.11.1
13+
sigs.k8s.io/cluster-api/test v1.11.1
14+
sigs.k8s.io/controller-runtime v0.22.1
1515
)
1616

17+
replace github.com/metal3-io/cluster-api-provider-metal3 => ../..
18+
1719
require (
18-
github.com/gobuffalo/flect v1.0.3 // indirect
19-
github.com/onsi/gomega v1.37.0 // indirect
20-
k8s.io/cluster-bootstrap v0.32.3 // indirect
20+
github.com/kylelemons/godebug v1.1.0 // indirect
21+
github.com/onsi/gomega v1.38.2 // indirect
22+
github.com/pmezard/go-difflib v1.0.1-0.20181226105442-5d4384ee4fb2 // indirect
23+
go.opentelemetry.io/auto/sdk v1.1.0 // indirect
24+
go.yaml.in/yaml/v2 v2.4.2 // indirect
25+
go.yaml.in/yaml/v3 v3.0.4 // indirect
26+
sigs.k8s.io/randfill v1.0.0 // indirect
27+
sigs.k8s.io/structured-merge-diff/v6 v6.3.0 // indirect
2128
)
2229

2330
require (
24-
cel.dev/expr v0.18.0 // indirect
31+
cel.dev/expr v0.24.0 // indirect
2532
github.com/NYTimes/gziphandler v1.1.1 // indirect
2633
github.com/antlr4-go/antlr/v4 v4.13.0 // indirect
27-
github.com/asaskevich/govalidator v0.0.0-20190424111038-f61b66f89f4a // indirect
2834
github.com/beorn7/perks v1.0.1 // indirect
2935
github.com/blang/semver/v4 v4.0.0 // indirect
3036
github.com/cenkalti/backoff/v4 v4.3.0 // indirect
@@ -35,8 +41,8 @@ require (
3541
github.com/emicklei/go-restful/v3 v3.12.2 // indirect
3642
github.com/evanphx/json-patch/v5 v5.9.11 // indirect
3743
github.com/felixge/httpsnoop v1.0.4 // indirect
38-
github.com/fsnotify/fsnotify v1.8.0 // indirect
39-
github.com/fxamacker/cbor/v2 v2.7.0 // indirect
44+
github.com/fsnotify/fsnotify v1.9.0 // indirect
45+
github.com/fxamacker/cbor/v2 v2.9.0 // indirect
4046
github.com/go-logr/logr v1.4.3 // indirect
4147
github.com/go-logr/stdr v1.2.2 // indirect
4248
github.com/go-logr/zapr v1.3.0 // indirect
@@ -46,73 +52,69 @@ require (
4652
github.com/gogo/protobuf v1.3.2 // indirect
4753
github.com/golang/protobuf v1.5.4 // indirect
4854
github.com/google/btree v1.1.3 // indirect
49-
github.com/google/cel-go v0.22.0 // indirect
50-
github.com/google/gnostic-models v0.6.8 // indirect
55+
github.com/google/cel-go v0.26.0 // indirect
56+
github.com/google/gnostic-models v0.7.0 // indirect
5157
github.com/google/go-cmp v0.7.0 // indirect
52-
github.com/google/gofuzz v1.2.0 // indirect
5358
github.com/google/uuid v1.6.0 // indirect
54-
github.com/gorilla/websocket v1.5.3 // indirect
59+
github.com/gorilla/websocket v1.5.4-0.20250319132907-e064f32e3674 // indirect
5560
github.com/grpc-ecosystem/go-grpc-prometheus v1.2.0 // indirect
56-
github.com/grpc-ecosystem/grpc-gateway/v2 v2.20.0 // indirect
61+
github.com/grpc-ecosystem/grpc-gateway/v2 v2.26.3 // indirect
5762
github.com/inconshreveable/mousetrap v1.1.0 // indirect
5863
github.com/josharian/intern v1.0.0 // indirect
5964
github.com/json-iterator/go v1.1.12 // indirect
6065
github.com/mailru/easyjson v0.7.7 // indirect
61-
github.com/metal3-io/baremetal-operator/pkg/hardwareutils v0.10.3 // indirect
62-
github.com/metal3-io/cluster-api-provider-metal3 v1.10.2
63-
github.com/metal3-io/ip-address-manager/api v1.10.2 // indirect
66+
github.com/metal3-io/ip-address-manager/api v1.11.0 // indirect
6467
github.com/moby/spdystream v0.5.0 // indirect
6568
github.com/modern-go/concurrent v0.0.0-20180306012644-bacd9c7ef1dd // indirect
66-
github.com/modern-go/reflect2 v1.0.2 // indirect
69+
github.com/modern-go/reflect2 v1.0.3-0.20250322232337-35a7c28c31ee // indirect
6770
github.com/munnerz/goautoneg v0.0.0-20191010083416-a7dc8b61c822 // indirect
6871
github.com/mxk/go-flowrate v0.0.0-20140419014527-cca7078d478f // indirect
6972
github.com/pkg/errors v0.9.1 // indirect
70-
github.com/prometheus/client_golang v1.19.1 // indirect
73+
github.com/prometheus/client_golang v1.22.0 // indirect
7174
github.com/prometheus/client_model v0.6.1 // indirect
72-
github.com/prometheus/common v0.55.0 // indirect
75+
github.com/prometheus/common v0.62.0 // indirect
7376
github.com/prometheus/procfs v0.15.1 // indirect
7477
github.com/spf13/cobra v1.9.1 // indirect
7578
github.com/spf13/pflag v1.0.10 // indirect
7679
github.com/stoewer/go-strcase v1.3.0 // indirect
7780
github.com/x448/float16 v0.8.4 // indirect
78-
go.etcd.io/etcd/api/v3 v3.5.20 // indirect
79-
go.etcd.io/etcd/client/pkg/v3 v3.5.20 // indirect
80-
go.etcd.io/etcd/client/v3 v3.5.20 // indirect
81-
go.opentelemetry.io/contrib/instrumentation/google.golang.org/grpc/otelgrpc v0.54.0 // indirect
82-
go.opentelemetry.io/contrib/instrumentation/net/http/otelhttp v0.54.0 // indirect
83-
go.opentelemetry.io/otel v1.29.0 // indirect
84-
go.opentelemetry.io/otel/exporters/otlp/otlptrace v1.28.0 // indirect
85-
go.opentelemetry.io/otel/exporters/otlp/otlptrace/otlptracegrpc v1.27.0 // indirect
86-
go.opentelemetry.io/otel/metric v1.29.0 // indirect
87-
go.opentelemetry.io/otel/sdk v1.29.0 // indirect
88-
go.opentelemetry.io/otel/trace v1.29.0 // indirect
89-
go.opentelemetry.io/proto/otlp v1.3.1 // indirect
81+
go.etcd.io/etcd/api/v3 v3.6.4 // indirect
82+
go.etcd.io/etcd/client/pkg/v3 v3.6.4 // indirect
83+
go.etcd.io/etcd/client/v3 v3.6.4 // indirect
84+
go.opentelemetry.io/contrib/instrumentation/google.golang.org/grpc/otelgrpc v0.60.0 // indirect
85+
go.opentelemetry.io/contrib/instrumentation/net/http/otelhttp v0.58.0 // indirect
86+
go.opentelemetry.io/otel v1.35.0 // indirect
87+
go.opentelemetry.io/otel/exporters/otlp/otlptrace v1.34.0 // indirect
88+
go.opentelemetry.io/otel/exporters/otlp/otlptrace/otlptracegrpc v1.34.0 // indirect
89+
go.opentelemetry.io/otel/metric v1.35.0 // indirect
90+
go.opentelemetry.io/otel/sdk v1.34.0 // indirect
91+
go.opentelemetry.io/otel/trace v1.35.0 // indirect
92+
go.opentelemetry.io/proto/otlp v1.5.0 // indirect
9093
go.uber.org/multierr v1.11.0 // indirect
91-
golang.org/x/crypto v0.38.0 // indirect
94+
golang.org/x/crypto v0.41.0 // indirect
9295
golang.org/x/exp v0.0.0-20240719175910-8a7402abbf56 // indirect
93-
golang.org/x/net v0.40.0 // indirect
94-
golang.org/x/oauth2 v0.28.0 // indirect
95-
golang.org/x/sync v0.14.0 // indirect
96-
golang.org/x/sys v0.33.0 // indirect
97-
golang.org/x/term v0.32.0 // indirect
98-
golang.org/x/text v0.25.0 // indirect
99-
golang.org/x/time v0.8.0 // indirect
96+
golang.org/x/net v0.43.0 // indirect
97+
golang.org/x/oauth2 v0.30.0 // indirect
98+
golang.org/x/sync v0.16.0 // indirect
99+
golang.org/x/sys v0.35.0 // indirect
100+
golang.org/x/term v0.34.0 // indirect
101+
golang.org/x/text v0.28.0 // indirect
102+
golang.org/x/time v0.9.0 // indirect
100103
gomodules.xyz/jsonpatch/v2 v2.5.0 // indirect
101-
google.golang.org/genproto/googleapis/api v0.0.0-20241209162323-e6fa225c2576 // indirect
102-
google.golang.org/genproto/googleapis/rpc v0.0.0-20241223144023-3abc09e42ca8 // indirect
103-
google.golang.org/grpc v1.67.3 // indirect
104-
google.golang.org/protobuf v1.36.5 // indirect
104+
google.golang.org/genproto/googleapis/api v0.0.0-20250303144028-a0af3efb3deb // indirect
105+
google.golang.org/genproto/googleapis/rpc v0.0.0-20250303144028-a0af3efb3deb // indirect
106+
google.golang.org/grpc v1.72.1 // indirect
107+
google.golang.org/protobuf v1.36.7 // indirect
105108
gopkg.in/evanphx/json-patch.v4 v4.12.0 // indirect
106109
gopkg.in/inf.v0 v0.9.1 // indirect
107110
gopkg.in/yaml.v3 v3.0.1 // indirect
108-
k8s.io/apiextensions-apiserver v0.32.9 // indirect
109-
k8s.io/apiserver v0.32.9 // indirect
110-
k8s.io/component-base v0.32.9 // indirect
111+
k8s.io/apiextensions-apiserver v0.34.1 // indirect
112+
k8s.io/apiserver v0.34.1 // indirect
113+
k8s.io/component-base v0.34.1 // indirect
111114
k8s.io/klog/v2 v2.130.1 // indirect
112-
k8s.io/kube-openapi v0.0.0-20241105132330-32ad38e42d3f // indirect
113-
k8s.io/utils v0.0.0-20241104100929-3ea5e8cea738 // indirect
114-
sigs.k8s.io/apiserver-network-proxy/konnectivity-client v0.31.0 // indirect
115-
sigs.k8s.io/json v0.0.0-20241010143419-9aa6b5e7a4b3 // indirect
116-
sigs.k8s.io/structured-merge-diff/v4 v4.4.2 // indirect
117-
sigs.k8s.io/yaml v1.4.0 // indirect
115+
k8s.io/kube-openapi v0.0.0-20250710124328-f3f2b991d03b // indirect
116+
k8s.io/utils v0.0.0-20250820121507-0af2bda4dd1d // indirect
117+
sigs.k8s.io/apiserver-network-proxy/konnectivity-client v0.31.2 // indirect
118+
sigs.k8s.io/json v0.0.0-20241014173422-cfa47c3a1cc8 // indirect
119+
sigs.k8s.io/yaml v1.6.0 // indirect
118120
)

0 commit comments

Comments
 (0)