Skip to content

Commit

Permalink
Upgrade CAPI to v1.4.0 and CAPE to v1.2.0 (#24)
Browse files Browse the repository at this point in the history
  • Loading branch information
haijianyang authored Apr 3, 2023
1 parent df2b7ed commit 86b5e9e
Show file tree
Hide file tree
Showing 9 changed files with 121 additions and 117 deletions.
2 changes: 1 addition & 1 deletion .go-version
Original file line number Diff line number Diff line change
@@ -1 +1 @@
1.19.5
1.19.6
2 changes: 1 addition & 1 deletion Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@
# limitations under the License.

# Build the manager binary
FROM golang:1.19.5 as builder
FROM golang:1.19.6 as builder
WORKDIR /workspace

# Run this with docker build --build_arg $(go env GOPROXY) to override the goproxy
Expand Down
6 changes: 3 additions & 3 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -95,19 +95,19 @@ kustomize: ## Download kustomize locally if necessary.

CONTROLLER_GEN = $(shell pwd)/bin/controller-gen
controller-gen: ## Download controller-gen locally if necessary.
$(call go-get-tool,$(CONTROLLER_GEN),sigs.k8s.io/controller-tools/cmd/controller-gen@v0.10.0)
$(call go-get-tool,$(CONTROLLER_GEN),sigs.k8s.io/controller-tools/cmd/controller-gen@v0.11.3)

GINKGO := $(shell pwd)/bin/ginkgo
ginkgo: ## Download ginkgo locally if necessary.
$(call go-get-tool,$(GINKGO),github.com/onsi/ginkgo/v2/ginkgo@v2.6.1)
$(call go-get-tool,$(GINKGO),github.com/onsi/ginkgo/v2/ginkgo@v2.9.2)

KIND := $(shell pwd)/bin/kind
kind: ## Download kind locally if necessary.
$(call go-get-tool,$(KIND),sigs.k8s.io/[email protected])

GOLANGCI_LINT := $(shell pwd)/bin/golangci-lint
golangci-lint: ## Download golangci-lint locally if necessary.
$(call go-get-tool,$(GOLANGCI_LINT),github.com/golangci/golangci-lint/cmd/golangci-lint@v1.50.1)
$(call go-get-tool,$(GOLANGCI_LINT),github.com/golangci/golangci-lint/cmd/golangci-lint@v1.52.1)

## --------------------------------------
## Linting and fixing linter errors
Expand Down
30 changes: 15 additions & 15 deletions controllers/elfmachine_controller_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -79,19 +79,19 @@ var _ = Describe("ElfMachineReconciler", func() {
reconciler := &ElfMachineReconciler{ControllerContext: ctrlContext}
result, err := reconciler.Reconcile(ctx, ctrl.Request{NamespacedName: capiutil.ObjectKey(elfMachine)})
Expect(result).To(BeZero())
Expect(err).To(BeNil())
Expect(err).ToNot(HaveOccurred())
Expect(logBuffer.String()).To(ContainSubstring("ElfMachine not found, won't reconcile"))
})

It("should not reconcile when ElfMachine in an error state", func() {
elfMachine.Status.FailureMessage = pointer.StringPtr("some error")
elfMachine.Status.FailureMessage = pointer.String("some error")
ctrlContext := newCtrlContexts(elfCluster, cluster, elfMachine, machine, elfMachineTemplate)
fake.InitOwnerReferences(ctrlContext, elfCluster, cluster, elfMachine, machine)

reconciler := &ElfMachineReconciler{ControllerContext: ctrlContext}
result, err := reconciler.Reconcile(ctx, ctrl.Request{NamespacedName: capiutil.ObjectKey(elfMachine)})
Expect(result).To(BeZero())
Expect(err).To(BeNil())
Expect(err).ToNot(HaveOccurred())
Expect(logBuffer.String()).To(ContainSubstring("Error state detected, skipping reconciliation"))
})

Expand All @@ -101,7 +101,7 @@ var _ = Describe("ElfMachineReconciler", func() {
reconciler := &ElfMachineReconciler{ControllerContext: ctrlContext}
result, err := reconciler.Reconcile(ctx, ctrl.Request{NamespacedName: capiutil.ObjectKey(elfMachine)})
Expect(result).To(BeZero())
Expect(err).To(BeNil())
Expect(err).ToNot(HaveOccurred())
Expect(logBuffer.String()).To(ContainSubstring("Waiting for Machine Controller to set OwnerRef on ElfMachine"))
})

Expand All @@ -113,7 +113,7 @@ var _ = Describe("ElfMachineReconciler", func() {
reconciler := &ElfMachineReconciler{ControllerContext: ctrlContext}
result, err := reconciler.Reconcile(ctx, ctrl.Request{NamespacedName: capiutil.ObjectKey(elfMachine)})
Expect(result).To(BeZero())
Expect(err).To(BeNil())
Expect(err).ToNot(HaveOccurred())
Expect(logBuffer.String()).To(ContainSubstring("ElfMachine linked to a cluster that is paused"))
})

Expand All @@ -125,7 +125,7 @@ var _ = Describe("ElfMachineReconciler", func() {
reconciler := &ElfMachineReconciler{ControllerContext: ctrlContext}
result, err := reconciler.Reconcile(ctx, ctrl.Request{NamespacedName: capiutil.ObjectKey(elfMachine)})
Expect(result).To(BeZero())
Expect(err).To(BeNil())
Expect(err).ToNot(HaveOccurred())
Expect(logBuffer.String()).To(ContainSubstring("No network device found"))
Expect(ctrlContext.Client.Get(ctrlContext, capiutil.ObjectKey(elfMachine), elfMachine)).To(Succeed())
Expect(ctrlutil.ContainsFinalizer(elfMachine, MachineStaticIPFinalizer)).To(BeFalse())
Expand All @@ -143,7 +143,7 @@ var _ = Describe("ElfMachineReconciler", func() {
reconciler := &ElfMachineReconciler{ControllerContext: ctrlContext}
result, err := reconciler.Reconcile(ctx, ctrl.Request{NamespacedName: capiutil.ObjectKey(elfMachine)})
Expect(result).To(BeZero())
Expect(err).To(BeNil())
Expect(err).ToNot(HaveOccurred())
Expect(logBuffer.String()).To(ContainSubstring("No need to allocate static IP"))
Expect(ctrlContext.Client.Get(ctrlContext, capiutil.ObjectKey(elfMachine), elfMachine)).To(Succeed())
Expect(ctrlutil.ContainsFinalizer(elfMachine, MachineStaticIPFinalizer)).To(BeFalse())
Expand All @@ -170,7 +170,7 @@ var _ = Describe("ElfMachineReconciler", func() {
reconciler := &ElfMachineReconciler{ControllerContext: ctrlContext}
result, err := reconciler.Reconcile(ctx, ctrl.Request{NamespacedName: capiutil.ObjectKey(elfMachine)})
Expect(result).To(BeZero())
Expect(err).To(BeNil())
Expect(err).ToNot(HaveOccurred())
Expect(logBuffer.String()).To(ContainSubstring("Waiting for IPPool to be available"))
Expect(ctrlContext.Client.Get(ctrlContext, capiutil.ObjectKey(elfMachine), elfMachine)).To(Succeed())
Expect(ctrlutil.ContainsFinalizer(elfMachine, MachineStaticIPFinalizer)).To(BeTrue())
Expand All @@ -185,7 +185,7 @@ var _ = Describe("ElfMachineReconciler", func() {
reconciler := &ElfMachineReconciler{ControllerContext: ctrlContext}
result, err := reconciler.Reconcile(ctx, ctrl.Request{NamespacedName: capiutil.ObjectKey(elfMachine)})
Expect(result.RequeueAfter).To(Equal(config.DefaultRequeue))
Expect(err).To(BeNil())
Expect(err).ToNot(HaveOccurred())
Expect(logBuffer.String()).To(ContainSubstring(fmt.Sprintf("Waiting for IP address for %s to be available", ipamutil.GetFormattedClaimName(elfMachine.Namespace, elfMachine.Name, 0))))
var ipClaim ipamv1.IPClaim
Expect(ctrlContext.Client.Get(ctrlContext, apitypes.NamespacedName{
Expand All @@ -210,7 +210,7 @@ var _ = Describe("ElfMachineReconciler", func() {
reconciler := &ElfMachineReconciler{ControllerContext: ctrlContext}
result, err := reconciler.Reconcile(ctx, ctrl.Request{NamespacedName: capiutil.ObjectKey(elfMachine)})
Expect(result.RequeueAfter).To(Equal(config.DefaultRequeue))
Expect(err).To(BeNil())
Expect(err).ToNot(HaveOccurred())
Expect(logBuffer.String()).To(ContainSubstring(fmt.Sprintf("IPClaim %s already exists, skipping creation", ipamutil.GetFormattedClaimName(elfMachine.Namespace, elfMachine.Name, 0))))
Expect(logBuffer.String()).To(ContainSubstring(fmt.Sprintf("Waiting for IP address for %s to be available", ipamutil.GetFormattedClaimName(elfMachine.Namespace, elfMachine.Name, 0))))
Expect(ctrlContext.Client.Get(ctrlContext, capiutil.ObjectKey(elfMachine), elfMachine)).To(Succeed())
Expand All @@ -231,7 +231,7 @@ var _ = Describe("ElfMachineReconciler", func() {
reconciler := &ElfMachineReconciler{ControllerContext: ctrlContext}
result, err := reconciler.Reconcile(ctx, ctrl.Request{NamespacedName: capiutil.ObjectKey(elfMachine)})
Expect(result).To(BeZero())
Expect(err).To(BeNil())
Expect(err).ToNot(HaveOccurred())
Expect(ctrlContext.Client.Get(ctrlContext, capiutil.ObjectKey(elfMachine), elfMachine)).To(Succeed())
Expect(elfMachine.Spec.Network.Devices[0].IPAddrs).To(Equal([]string{string(metal3IPAddress.Spec.Address)}))
// DNS server is unique and DNS server priority of ElfMachine is higher than IPPool.
Expand All @@ -254,7 +254,7 @@ var _ = Describe("ElfMachineReconciler", func() {
reconciler := &ElfMachineReconciler{ControllerContext: ctrlContext}
result, err := reconciler.Reconcile(ctx, ctrl.Request{NamespacedName: capiutil.ObjectKey(elfMachine)})
Expect(result).To(BeZero())
Expect(err).To(BeNil())
Expect(err).ToNot(HaveOccurred())
Expect(ctrlContext.Client.Get(ctrlContext, capiutil.ObjectKey(elfMachine), elfMachine)).To(Succeed())
Expect(ctrlutil.ContainsFinalizer(elfMachine, MachineStaticIPFinalizer)).To(BeFalse())
})
Expand All @@ -267,7 +267,7 @@ var _ = Describe("ElfMachineReconciler", func() {
reconciler := &ElfMachineReconciler{ControllerContext: ctrlContext}
result, err := reconciler.Reconcile(ctx, ctrl.Request{NamespacedName: capiutil.ObjectKey(elfMachine)})
Expect(result).To(BeZero())
Expect(err).To(BeNil())
Expect(err).ToNot(HaveOccurred())
Expect(apierrors.IsNotFound(ctrlContext.Client.Get(ctrlContext, capiutil.ObjectKey(elfMachine), elfMachine))).To(BeTrue())
})

Expand All @@ -278,7 +278,7 @@ var _ = Describe("ElfMachineReconciler", func() {
reconciler := &ElfMachineReconciler{ControllerContext: ctrlContext}
result, err := reconciler.Reconcile(ctx, ctrl.Request{NamespacedName: capiutil.ObjectKey(elfMachine)})
Expect(result).To(BeZero())
Expect(err).To(BeNil())
Expect(err).ToNot(HaveOccurred())
Expect(logBuffer.String()).To(ContainSubstring("Waiting for MachineFinalizer to be removed"))
Expect(ctrlContext.Client.Get(ctrlContext, capiutil.ObjectKey(elfMachine), elfMachine)).To(Succeed())
Expect(ctrlutil.ContainsFinalizer(elfMachine, MachineStaticIPFinalizer)).To(BeTrue())
Expand All @@ -297,7 +297,7 @@ var _ = Describe("ElfMachineReconciler", func() {
reconciler := &ElfMachineReconciler{ControllerContext: ctrlContext}
result, err := reconciler.Reconcile(ctx, ctrl.Request{NamespacedName: capiutil.ObjectKey(elfMachine)})
Expect(result).To(BeZero())
Expect(err).To(BeNil())
Expect(err).ToNot(HaveOccurred())
Expect(apierrors.IsNotFound(ctrlContext.Client.Get(ctrlContext, capiutil.ObjectKey(elfMachine), elfMachine))).To(BeTrue())
Expect(apierrors.IsNotFound(ctrlContext.Client.Get(ctrlContext, capiutil.ObjectKey(metal3IPClaim), metal3IPClaim))).To(BeTrue())
})
Expand Down
60 changes: 31 additions & 29 deletions go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -3,32 +3,32 @@ module github.com/smartxworks/cluster-api-provider-elf-static-ip
go 1.19

require (
github.com/metal3-io/ip-address-manager v1.2.1
github.com/metal3-io/ip-address-manager/api v0.0.0
k8s.io/api v0.25.0
k8s.io/apimachinery v0.25.0
k8s.io/client-go v0.25.0
sigs.k8s.io/controller-runtime v0.13.1
k8s.io/api v0.26.1
k8s.io/apimachinery v0.26.1
k8s.io/client-go v0.26.1
sigs.k8s.io/controller-runtime v0.14.6
)

require (
github.com/go-logr/logr v1.2.3
github.com/onsi/ginkgo/v2 v2.6.1
github.com/onsi/gomega v1.24.2
github.com/onsi/ginkgo/v2 v2.9.2
github.com/onsi/gomega v1.27.4
github.com/pkg/errors v0.9.1
github.com/smartxworks/cluster-api-provider-elf v1.1.2
golang.org/x/mod v0.7.0
k8s.io/apiextensions-apiserver v0.25.0
k8s.io/apiserver v0.25.0
github.com/smartxworks/cluster-api-provider-elf v1.2.0
golang.org/x/mod v0.9.0
k8s.io/apiextensions-apiserver v0.26.1
k8s.io/apiserver v0.26.1
k8s.io/klog/v2 v2.80.1
k8s.io/utils v0.0.0-20220823124924-e9cbc92d1a73
sigs.k8s.io/cluster-api v1.3.4
k8s.io/utils v0.0.0-20221128185143-99ec85e7a448
sigs.k8s.io/cluster-api v1.4.0
)

require (
github.com/asaskevich/govalidator v0.0.0-20210307081110-f21760c49a8d // indirect
github.com/beorn7/perks v1.0.1 // indirect
github.com/blang/semver v3.5.1+incompatible // indirect
github.com/blang/semver/v4 v4.0.0 // indirect
github.com/cespare/xxhash/v2 v2.1.2 // indirect
github.com/coredns/caddy v1.1.0 // indirect
github.com/coredns/corefile-migration v1.0.20 // indirect
Expand All @@ -49,54 +49,56 @@ require (
github.com/go-openapi/strfmt v0.21.3 // indirect
github.com/go-openapi/swag v0.22.3 // indirect
github.com/go-openapi/validate v0.22.0 // indirect
github.com/gobuffalo/flect v0.3.0 // indirect
github.com/go-task/slim-sprig v0.0.0-20230315185526-52ccab3ef572 // indirect
github.com/gobuffalo/flect v1.0.2 // indirect
github.com/gogo/protobuf v1.3.2 // indirect
github.com/golang/groupcache v0.0.0-20210331224755-41bb18bfe9da // indirect
github.com/golang/protobuf v1.5.2 // indirect
github.com/golang/protobuf v1.5.3 // indirect
github.com/google/gnostic v0.6.9 // indirect
github.com/google/go-cmp v0.5.9 // indirect
github.com/google/gofuzz v1.2.0 // indirect
github.com/google/pprof v0.0.0-20210407192527-94a9f03dee38 // indirect
github.com/google/uuid v1.3.0 // indirect
github.com/imdario/mergo v0.3.13 // indirect
github.com/josharian/intern v1.0.0 // indirect
github.com/json-iterator/go v1.1.12 // indirect
github.com/mailru/easyjson v0.7.7 // indirect
github.com/matttproud/golang_protobuf_extensions v1.0.2-0.20181231171920-c182affec369 // indirect
github.com/matttproud/golang_protobuf_extensions v1.0.2 // indirect
github.com/mitchellh/mapstructure v1.5.0 // indirect
github.com/modern-go/concurrent v0.0.0-20180306012644-bacd9c7ef1dd // indirect
github.com/modern-go/reflect2 v1.0.2 // indirect
github.com/munnerz/goautoneg v0.0.0-20191010083416-a7dc8b61c822 // indirect
github.com/oklog/ulid v1.3.1 // indirect
github.com/opencontainers/go-digest v1.0.0 // indirect
github.com/opentracing/opentracing-go v1.2.0 // indirect
github.com/prometheus/client_golang v1.13.0 // indirect
github.com/prometheus/client_model v0.2.0 // indirect
github.com/prometheus/client_golang v1.14.0 // indirect
github.com/prometheus/client_model v0.3.0 // indirect
github.com/prometheus/common v0.37.0 // indirect
github.com/prometheus/procfs v0.8.0 // indirect
github.com/smartxworks/cloudtower-go-sdk/v2 v2.5.0 // indirect
github.com/spf13/pflag v1.0.5 // indirect
go.mongodb.org/mongo-driver v1.11.1 // indirect
go.opentelemetry.io/otel v1.11.2 // indirect
go.opentelemetry.io/otel/trace v1.11.2 // indirect
golang.org/x/net v0.7.0 // indirect
golang.org/x/oauth2 v0.0.0-20220909003341-f21342109be1 // indirect
golang.org/x/sys v0.5.0 // indirect
golang.org/x/term v0.5.0 // indirect
golang.org/x/text v0.7.0 // indirect
golang.org/x/time v0.0.0-20220722155302-e5dcc9cfc0b9 // indirect
golang.org/x/net v0.8.0 // indirect
golang.org/x/oauth2 v0.6.0 // indirect
golang.org/x/sys v0.6.0 // indirect
golang.org/x/term v0.6.0 // indirect
golang.org/x/text v0.8.0 // indirect
golang.org/x/time v0.3.0 // indirect
golang.org/x/tools v0.7.0 // indirect
gomodules.xyz/jsonpatch/v2 v2.2.0 // indirect
google.golang.org/appengine v1.6.7 // indirect
google.golang.org/genproto v0.0.0-20220804142021-4e6b2dfa6612 // indirect
google.golang.org/protobuf v1.28.1 // indirect
gopkg.in/inf.v0 v0.9.1 // indirect
gopkg.in/yaml.v2 v2.4.0 // indirect
gopkg.in/yaml.v3 v3.0.1 // indirect
k8s.io/cluster-bootstrap v0.25.0 // indirect
k8s.io/component-base v0.25.0 // indirect
k8s.io/kube-openapi v0.0.0-20220803164354-a70c9af30aea // indirect
k8s.io/cluster-bootstrap v0.26.1 // indirect
k8s.io/component-base v0.26.1 // indirect
k8s.io/kube-openapi v0.0.0-20221012153701-172d655c2280 // indirect
sigs.k8s.io/json v0.0.0-20220713155537-f223a00ba0e2 // indirect
sigs.k8s.io/structured-merge-diff/v4 v4.2.3 // indirect
sigs.k8s.io/yaml v1.3.0 // indirect
)

replace github.com/metal3-io/ip-address-manager/api => github.com/metal3-io/ip-address-manager/api v0.0.0-20221109074200-4f826644ac3f
replace github.com/metal3-io/ip-address-manager/api => github.com/metal3-io/ip-address-manager/api v0.0.0-20221208094636-8892d31b812f
Loading

0 comments on commit 86b5e9e

Please sign in to comment.