Skip to content

Commit 02682af

Browse files
author
shiftstack-merge-bot
committed
2 parents 23512b6 + e1fb93f commit 02682af

23 files changed

+893
-93
lines changed

.github/workflows/release.yaml

Lines changed: 44 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,44 @@
1+
name: release
2+
3+
on:
4+
push:
5+
# Sequence of patterns matched against refs/tags
6+
tags:
7+
- 'v*' # Push events to matching v*, i.e. v1.0, v20.15.10
8+
9+
permissions:
10+
contents: write # Allow to create a release.
11+
12+
jobs:
13+
build:
14+
name: create draft release
15+
runs-on: ubuntu-latest
16+
steps:
17+
- name: Set env
18+
run: echo "RELEASE_TAG=${GITHUB_REF:10}" >> $GITHUB_ENV
19+
- name: checkout code
20+
uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # tag=v4.2.2
21+
with:
22+
fetch-depth: 0
23+
- name: Calculate go version
24+
run: echo "go_version=$(make go-version)" >> $GITHUB_ENV
25+
- name: Set up Go
26+
uses: actions/setup-go@41dfa10bad2bb2ae585af6ee5bb4d7d973ad74ed # tag=v5.1.0
27+
with:
28+
go-version: ${{ env.go_version }}
29+
- name: generate release artifacts
30+
run: |
31+
make release
32+
- name: generate release notes
33+
# Ignore failures for release-notes generation so they could still get
34+
# generated manually before publishing.
35+
run: |
36+
make generate-release-notes || echo "Failed to generate release notes" >> _releasenotes/${{ env.RELEASE_TAG }}.md
37+
env:
38+
GH_TOKEN: ${{ github.token }}
39+
- name: Release
40+
uses: softprops/action-gh-release@01570a1f39cb168c169c802c3bceb9e93fb10974 # tag=v2.1.0
41+
with:
42+
draft: true
43+
files: out/*
44+
body_path: _releasenotes/${{ env.RELEASE_TAG }}.md

.gitignore

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -74,6 +74,9 @@ cscope.*
7474
*.test
7575
/hack/.test-cmd-auth
7676

77+
# Generated release notes
78+
_releasenotes
79+
7780
# JUnit test output from ginkgo e2e tests
7881
/junit*.xml
7982

Makefile

Lines changed: 38 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,9 @@ export GOTOOLCHAIN=go1.22.8
2525
export GO111MODULE=on
2626
unexport GOPATH
2727

28+
# Go
29+
GO_VERSION ?= 1.22.7
30+
2831
# Directories.
2932
ARTIFACTS ?= $(REPO_ROOT)/_artifacts
3033
TOOLS_DIR := hack/tools
@@ -359,8 +362,25 @@ staging-manifests:
359362
##@ Release
360363
## --------------------------------------
361364

365+
ifneq (,$(findstring -,$(RELEASE_TAG)))
366+
PRE_RELEASE=true
367+
endif
368+
PREVIOUS_TAG ?= $(shell git tag -l | grep -E "^v[0-9]+\.[0-9]+\.[0-9]+$$" | sort -V | grep -B1 $(RELEASE_TAG) | head -n 1 2>/dev/null)
369+
## set by Prow, ref name of the base branch, e.g., main
370+
RELEASE_DIR := out
371+
RELEASE_NOTES_DIR := _releasenotes
372+
373+
.PHONY: $(RELEASE_DIR)
362374
$(RELEASE_DIR):
363-
mkdir -p $@
375+
mkdir -p $(RELEASE_DIR)/
376+
377+
.PHONY: $(RELEASE_NOTES_DIR)
378+
$(RELEASE_NOTES_DIR):
379+
mkdir -p $(RELEASE_NOTES_DIR)/
380+
381+
.PHONY: $(BUILD_DIR)
382+
$(BUILD_DIR):
383+
@mkdir -p $(BUILD_DIR)
364384

365385
.PHONY: list-staging-releases
366386
list-staging-releases: ## List staging images for image promotion
@@ -435,9 +455,14 @@ upload-gh-artifacts: $(GH) ## Upload artifacts to Github release
435455
release-alias-tag: # Adds the tag to the last build tag.
436456
gcloud container images add-tag -q $(CONTROLLER_IMG):$(TAG) $(CONTROLLER_IMG):$(RELEASE_ALIAS_TAG)
437457

438-
.PHONY: release-notes
439-
release-notes: $(RELEASE_NOTES) ## Generate release notes
440-
$(RELEASE_NOTES) $(RELEASE_NOTES_ARGS)
458+
.PHONY: generate-release-notes ## Generate release notes
459+
generate-release-notes: $(RELEASE_NOTES_DIR) $(RELEASE_NOTES)
460+
# Reset the file
461+
echo -n > $(RELEASE_NOTES_DIR)/$(RELEASE_TAG).md
462+
if [ -n "${PRE_RELEASE}" ]; then \
463+
echo -e ":rotating_light: This is a RELEASE CANDIDATE. Use it only for testing purposes. If you find any bugs, file an [issue](https://github.com/kubernetes-sigs/cluster-api-provider-openstack/issues/new/choose).\n" >> $(RELEASE_NOTES_DIR)/$(RELEASE_TAG).md; \
464+
fi
465+
"$(RELEASE_NOTES)" --from=$(PREVIOUS_TAG) >> $(RELEASE_NOTES_DIR)/$(RELEASE_TAG).md
441466

442467
.PHONY: templates
443468
templates: ## Generate cluster templates
@@ -557,3 +582,12 @@ compile-e2e: ## Test e2e compilation
557582

558583
.PHONY: FORCE
559584
FORCE:
585+
586+
## --------------------------------------
587+
## Helpers
588+
## --------------------------------------
589+
590+
##@ helpers:
591+
592+
go-version: ## Print the go version we use to compile our binaries and images
593+
@echo $(GO_VERSION)

OWNERS_ALIASES

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,8 @@ aliases:
2020
- vincepri
2121
cluster-api-openstack-maintainers:
2222
- emilienm
23-
- jichenjc
2423
- lentzi90
2524
- mdbooth
2625
cluster-api-openstack-reviewers:
26+
cluster-api-openstack-emeritus-maintainers:
27+
- jichenjc

RELEASE.md

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -70,10 +70,7 @@ The content of the release notes differs depending on the type of release, speci
7070
for review and the promotion of the image.
7171
1. Run `make release` to build artifacts to be attached to the GitHub release.
7272
1. Generate and finalize the release notes and save them for the next step.
73-
- Run `make release-notes RELEASE_NOTES_ARGS="--from <tag>"`.
74-
- Depending on the type of release, substitute `<tag>` with the following:
75-
- Stable releases: tag of the last stable release
76-
- Pre-releases*: tag of the latest pre-release (or last stable release if there isn't one)
73+
- Run `make release-notes`.
7774
- Pay close attention to the `## :question: Sort these by hand` section, as it contains items that need to be manually sorted.
7875
1. Create a draft release in GitHub based on the tag created above
7976
- Name the release `Release [VERSION]` where VERSION is the full version string.

cloudbuild-nightly.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ options:
44
substitution_option: ALLOW_LOOSE
55
machineType: 'N1_HIGHCPU_8'
66
steps:
7-
- name: 'gcr.io/k8s-staging-test-infra/gcb-docker-gcloud:v20220609-2e4c91eb7e'
7+
- name: 'gcr.io/k8s-staging-test-infra/gcb-docker-gcloud:v20241229-5dc092c636'
88
entrypoint: make
99
env:
1010
- DOCKER_CLI_EXPERIMENTAL=enabled

cloudbuild.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ options:
44
substitution_option: ALLOW_LOOSE
55
machineType: 'N1_HIGHCPU_8'
66
steps:
7-
- name: 'gcr.io/k8s-staging-test-infra/gcb-docker-gcloud:v20220609-2e4c91eb7e'
7+
- name: 'gcr.io/k8s-staging-test-infra/gcb-docker-gcloud:v20241229-5dc092c636'
88
entrypoint: make
99
env:
1010
- DOCKER_CLI_EXPERIMENTAL=enabled

controllers/openstackcluster_controller.go

Lines changed: 15 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -152,9 +152,11 @@ func (r *OpenStackClusterReconciler) reconcileDelete(ctx context.Context, scope
152152
// A bastion may have been created if cluster initialisation previously reached populating the network status
153153
// We attempt to delete it even if no status was written, just in case
154154
if openStackCluster.Status.Network != nil {
155-
// Attempt to resolve bastion resources before delete. We don't need to worry about starting if the resources have changed on update.
155+
// Attempt to resolve bastion resources before delete.
156+
// Even if we fail, we need to continue with the deletion or risk getting stuck.
157+
// For example, if the image doesn't exist, we do not have a bastion.
156158
if _, err := resolveBastionResources(scope, clusterResourceName, openStackCluster); err != nil {
157-
return reconcile.Result{}, err
159+
scope.Logger().Info("Failed to resolve bastion, continuing.", "error", err)
158160
}
159161

160162
if err := deleteBastion(scope, cluster, openStackCluster); err != nil {
@@ -614,11 +616,7 @@ func getOrCreateBastionPorts(openStackCluster *infrav1.OpenStackCluster, network
614616
return errors.New("bastion resources are nil")
615617
}
616618

617-
if len(desiredPorts) == len(resources.Ports) {
618-
return nil
619-
}
620-
621-
err := networkingService.CreatePorts(openStackCluster, desiredPorts, resources)
619+
err := networkingService.EnsurePorts(openStackCluster, desiredPorts, resources)
622620
if err != nil {
623621
return fmt.Errorf("failed to create ports for bastion %s: %w", bastionName(openStackCluster.Name), err)
624622
}
@@ -664,14 +662,19 @@ func resolveLoadBalancerNetwork(openStackCluster *infrav1.OpenStackCluster, netw
664662

665663
// Filter out only relevant subnets specified by the spec
666664
lbNetStatus.Subnets = []infrav1.Subnet{}
667-
for _, s := range lbSpec.Subnets {
665+
for i := range lbSpec.Subnets {
666+
s := lbSpec.Subnets[i]
668667
matchFound := false
669668
for _, subnetID := range lbNet.Subnets {
670-
if s.ID != nil && subnetID == *s.ID {
669+
subnet, err := networkingService.GetSubnetByParam(&s)
670+
if s.ID != nil && subnetID == *s.ID && err == nil {
671671
matchFound = true
672672
lbNetStatus.Subnets = append(
673673
lbNetStatus.Subnets, infrav1.Subnet{
674-
ID: *s.ID,
674+
ID: subnet.ID,
675+
Name: subnet.Name,
676+
CIDR: subnet.CIDR,
677+
Tags: subnet.Tags,
675678
})
676679
}
677680
}
@@ -680,6 +683,8 @@ func resolveLoadBalancerNetwork(openStackCluster *infrav1.OpenStackCluster, netw
680683
return fmt.Errorf("no subnet match was found in the specified network (specified subnet: %v, available subnets: %v)", s, lbNet.Subnets)
681684
}
682685
}
686+
687+
openStackCluster.Status.APIServerLoadBalancer.LoadBalancerNetwork = lbNetStatus
683688
}
684689
}
685690

controllers/openstackcluster_controller_test.go

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -277,6 +277,8 @@ var _ = Describe("OpenStackCluster controller", func() {
277277
server.Status = "ACTIVE"
278278

279279
networkClientRecorder := mockScopeFactory.NetworkClient.EXPECT()
280+
// One list for adopting and one for ensuring the ports and tags are correct
281+
networkClientRecorder.ListPort(gomock.Any()).Return([]ports.Port{{ID: "portID1"}}, nil)
280282
networkClientRecorder.ListPort(gomock.Any()).Return([]ports.Port{{ID: "portID1"}}, nil)
281283

282284
computeClientRecorder := mockScopeFactory.ComputeClient.EXPECT()
@@ -362,6 +364,7 @@ var _ = Describe("OpenStackCluster controller", func() {
362364

363365
networkClientRecorder := mockScopeFactory.NetworkClient.EXPECT()
364366
networkClientRecorder.ListPort(gomock.Any()).Return([]ports.Port{{ID: "portID1"}}, nil)
367+
networkClientRecorder.ListPort(gomock.Any()).Return([]ports.Port{{ID: "portID1"}}, nil)
365368

366369
computeClientRecorder := mockScopeFactory.ComputeClient.EXPECT()
367370
computeClientRecorder.GetServer("adopted-fip-bastion-uuid").Return(&server, nil)
@@ -445,6 +448,9 @@ var _ = Describe("OpenStackCluster controller", func() {
445448
computeClientRecorder := mockScopeFactory.ComputeClient.EXPECT()
446449
computeClientRecorder.GetServer("requeue-bastion-uuid").Return(&server, nil)
447450

451+
networkClientRecorder := mockScopeFactory.NetworkClient.EXPECT()
452+
networkClientRecorder.ListPort(gomock.Any()).Return([]ports.Port{{ID: "portID1"}}, nil)
453+
448454
res, err := reconcileBastion(scope, capiCluster, testCluster)
449455
Expect(testCluster.Status.Bastion).To(Equal(&infrav1.BastionStatus{
450456
ID: "requeue-bastion-uuid",

controllers/openstackmachine_controller.go

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -752,11 +752,7 @@ func getOrCreateMachinePorts(openStackMachine *infrav1.OpenStackMachine, network
752752
}
753753
desiredPorts := resolved.Ports
754754

755-
if len(desiredPorts) == len(resources.Ports) {
756-
return nil
757-
}
758-
759-
if err := networkingService.CreatePorts(openStackMachine, desiredPorts, resources); err != nil {
755+
if err := networkingService.EnsurePorts(openStackMachine, desiredPorts, resources); err != nil {
760756
return fmt.Errorf("creating ports: %w", err)
761757
}
762758

0 commit comments

Comments
 (0)