Skip to content

Commit

Permalink
Merge pull request #305 from shiftstack/rebase-capo-v0.10
Browse files Browse the repository at this point in the history
OSASINFRA-3437: Rebase on CAPO v0.10
  • Loading branch information
openshift-merge-bot[bot] committed Apr 26, 2024
2 parents bbf8955 + 0a9e144 commit c42a465
Show file tree
Hide file tree
Showing 1,910 changed files with 141,461 additions and 67,472 deletions.
12 changes: 12 additions & 0 deletions .gitattributes
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
# Tell GitHub about generated files

# deepcopy and conversion-gen
zz_generated.* linguist-generated=true

# Generated parts of manifests
/config/crd/bases/infrastructure.cluster.x-k8s.io_*.yaml linguist-generated=true
/config/webhook/manifests.yaml linguist-generated=true
/config/rbac/role.yaml linguist-generated=true

# Generated API docs
/docs/book/src/api/*/** linguist-generated=true
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -173,6 +173,7 @@ sshuttle.pid

# Book
docs/book/book/
!docs/book/gen-crd-api-reference-docs/config.json

# venv
.venv
Expand Down
9 changes: 7 additions & 2 deletions .golangci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -101,6 +101,8 @@ linters-settings:
- pkg: sigs.k8s.io/cluster-api-provider-openstack/api/v1alpha6
alias: infrav1alpha6
- pkg: sigs.k8s.io/cluster-api-provider-openstack/api/v1alpha7
alias: infrav1alpha7
- pkg: sigs.k8s.io/cluster-api-provider-openstack/api/v1beta1
alias: infrav1
- pkg: sigs.k8s.io/cluster-api-provider-openstack/pkg/utils/errors
alias: capoerrors
Expand Down Expand Up @@ -166,11 +168,14 @@ issues:
- linters:
- revive
text: "var-naming: don't use underscores in Go names;"
path: .*(api|types)\/.*\/.*conversion.*\.go$
- linters:
- stylecheck
text: "ST1003: should not use underscores in Go names;"
path: .*(api|types)\/.*\/.*conversion.*\.go$
path: (api\/.*|pkg/utils/optional)\/.*conversion.*\.go$
- linters:
- stylecheck
text: "ST1003: should not use underscores in Go names;"
path: pkg/utils/conversioncommon/.*.go

run:
timeout: 10m
Expand Down
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.20.10 as builder
FROM golang:1.22.0 as builder
WORKDIR /workspace

# Run this with docker build --build_arg goproxy=$(go env GOPROXY) to override the goproxy
Expand Down
71 changes: 48 additions & 23 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,7 @@ KUSTOMIZE := $(TOOLS_BIN_DIR)/kustomize
MOCKGEN := $(TOOLS_BIN_DIR)/mockgen
RELEASE_NOTES := $(TOOLS_BIN_DIR)/release-notes
SETUP_ENVTEST := $(TOOLS_BIN_DIR)/setup-envtest
GEN_CRD_API_REFERENCE_DOCS := $(TOOLS_BIN_DIR)/gen-crd-api-reference-docs

# Kubebuilder
export KUBEBUILDER_ENVTEST_KUBERNETES_VERSION ?= 1.28.0
Expand Down Expand Up @@ -132,13 +133,15 @@ ifdef KUBEBUILDER_ASSETS_DIR
setup_envtest_extra_args += --bin-dir $(KUBEBUILDER_ASSETS_DIR)
endif

.PHONY: kubebuilder_assets
kubebuilder_assets: $(SETUP_ENVTEST)
@echo Fetching assets for $(KUBEBUILDER_ENVTEST_KUBERNETES_VERSION)
$(eval KUBEBUILDER_ASSETS ?= $(shell $(SETUP_ENVTEST) use --use-env -p path $(setup_envtest_extra_args) $(KUBEBUILDER_ENVTEST_KUBERNETES_VERSION)))

.PHONY: test
test: $(SETUP_ENVTEST) ## Run tests
set -xeuf -o pipefail; \
if [ -z "$(KUBEBUILDER_ASSETS)" ]; then \
KUBEBUILDER_ASSETS=`$(SETUP_ENVTEST) use --use-env -p path $(setup_envtest_extra_args) $(KUBEBUILDER_ENVTEST_KUBERNETES_VERSION)`; \
fi; \
KUBEBUILDER_ASSETS="$$KUBEBUILDER_ASSETS" go test -v ./... $(TEST_ARGS)
TEST_PATHS ?= ./...
test: kubebuilder_assets
KUBEBUILDER_ASSETS="$(KUBEBUILDER_ASSETS)" go test -v $(TEST_PATHS) $(TEST_ARGS)

E2E_TEMPLATES_DIR=test/e2e/data/infrastructure-openstack
E2E_KUSTOMIZE_DIR=test/e2e/data/kustomize
Expand All @@ -148,16 +151,18 @@ E2E_NO_ARTIFACT_TEMPLATES_DIR=test/e2e/data/infrastructure-openstack-no-artifact
.PHONY: e2e-templates
e2e-templates: ## Generate cluster templates for e2e tests
e2e-templates: $(addprefix $(E2E_NO_ARTIFACT_TEMPLATES_DIR)/, \
cluster-template-v1alpha5.yaml \
cluster-template-v1alpha6.yaml \
cluster-template-v1alpha7.yaml \
cluster-template-md-remediation.yaml \
cluster-template-kcp-remediation.yaml \
cluster-template-multi-az.yaml \
cluster-template-multi-network.yaml \
cluster-template-without-lb.yaml \
cluster-template.yaml \
cluster-template-flatcar.yaml \
cluster-template-k8s-upgrade.yaml)
cluster-template-k8s-upgrade.yaml \
cluster-template-flatcar-sysext.yaml \
cluster-template-no-bastion.yaml)
# Currently no templates that require CI artifacts
# $(addprefix $(E2E_TEMPLATES_DIR)/, add-templates-here.yaml) \
Expand All @@ -167,15 +172,16 @@ $(E2E_NO_ARTIFACT_TEMPLATES_DIR)/cluster-template.yaml: $(E2E_KUSTOMIZE_DIR)/wit
$(E2E_NO_ARTIFACT_TEMPLATES_DIR)/cluster-template-%.yaml: $(E2E_KUSTOMIZE_DIR)/% $(KUSTOMIZE) FORCE
$(KUSTOMIZE) build "$<" > "$@"

e2e-prerequisites: $(GINKGO) e2e-templates e2e-image test-e2e-image-prerequisites ## Build all artifacts required by e2e tests
e2e-prerequisites: e2e-templates e2e-image test-e2e-image-prerequisites ## Build all artifacts required by e2e tests

# Can be run manually, e.g. via:
# export OPENSTACK_CLOUD_YAML_FILE="$(pwd)/clouds.yaml"
# E2E_GINKGO_ARGS="-stream -focus='default'" E2E_ARGS="-use-existing-cluster='true'" make test-e2e
E2E_GINKGO_ARGS ?=
.PHONY: test-e2e ## Run e2e tests using clusterctl
test-e2e: e2e-prerequisites ## Run e2e tests
test-e2e: $(GINKGO) e2e-prerequisites ## Run e2e tests
time $(GINKGO) -fail-fast -trace -timeout=3h -show-node-events -v -tags=e2e -nodes=$(E2E_GINKGO_PARALLEL) \
--output-dir="$(ARTIFACTS)" --junit-report="junit.e2e_suite.1.xml" \
-focus="$(E2E_GINKGO_FOCUS)" $(_SKIP_ARGS) $(E2E_GINKGO_ARGS) ./test/e2e/suites/e2e/... -- \
-config-path="$(E2E_CONF_PATH)" -artifacts-folder="$(ARTIFACTS)" \
-data-folder="$(E2E_DATA_DIR)" $(E2E_ARGS)
Expand All @@ -197,7 +203,7 @@ CONFORMANCE_E2E_ARGS ?= -kubetest.config-file=$(KUBETEST_CONF_PATH)
CONFORMANCE_E2E_ARGS += $(E2E_ARGS)
CONFORMANCE_GINKGO_ARGS ?= -stream
.PHONY: test-conformance
test-conformance: e2e-prerequisites ## Run clusterctl based conformance test on workload cluster (requires Docker).
test-conformance: $(GINKGO) e2e-prerequisites ## Run clusterctl based conformance test on workload cluster (requires Docker).
time $(GINKGO) -trace -show-node-events -v -tags=e2e -focus="conformance" $(CONFORMANCE_GINKGO_ARGS) ./test/e2e/suites/conformance/... -- -config-path="$(E2E_CONF_PATH)" -artifacts-folder="$(ARTIFACTS)" --data-folder="$(E2E_DATA_DIR)" $(CONFORMANCE_E2E_ARGS)

test-conformance-fast: ## Run clusterctl based conformance test on workload cluster (requires Docker) using a subset of the conformance suite in parallel.
Expand Down Expand Up @@ -244,30 +250,39 @@ modules: ## Runs go mod to ensure proper vendoring.
cd $(TOOLS_DIR); go mod tidy

.PHONY: generate
generate: ## Generate code
$(MAKE) generate-go
$(MAKE) generate-manifests
generate: templates generate-controller-gen generate-conversion-gen generate-go generate-manifests generate-api-docs ## Generate all generated code

.PHONY: generate-go
generate-go: $(MOCKGEN)
$(MAKE) -B $(CONTROLLER_GEN) $(CONVERSION_GEN)
go generate ./...

.PHONY: generate-controller-gen
generate-controller-gen: $(CONTROLLER_GEN)
$(CONTROLLER_GEN) \
paths=./api/... \
object:headerFile=./hack/boilerplate/boilerplate.generatego.txt

.PHONY: generate-conversion-gen
capo_module := sigs.k8s.io/cluster-api-provider-openstack
generate-conversion-gen: $(CONVERSION_GEN)
$(CONVERSION_GEN) \
--input-dirs=./api/v1alpha5 \
--input-dirs=./api/v1alpha6 \
--input-dirs=./api/v1alpha7 \
--input-dirs=$(capo_module)/api/v1alpha5 \
--input-dirs=$(capo_module)/api/v1alpha6 \
--input-dirs=$(capo_module)/api/v1alpha7 \
--extra-dirs=$(capo_module)/pkg/utils/optional \
--extra-dirs=$(capo_module)/pkg/utils/conversioncommon \
--output-file-base=zz_generated.conversion \
--trim-path-prefix=$(capo_module)/ \
--go-header-file=./hack/boilerplate/boilerplate.generatego.txt
go generate ./...

.PHONY: generate-manifests
generate-manifests: $(CONTROLLER_GEN) ## Generate manifests e.g. CRD, RBAC etc.
$(CONTROLLER_GEN) \
paths=./api/... \
crd:crdVersions=v1 \
output:crd:dir=$(CRD_ROOT) \
output:crd:dir=$(CRD_ROOT)
$(CONTROLLER_GEN) \
paths=./pkg/webhooks/... \
output:webhook:dir=$(WEBHOOK_ROOT) \
webhook
$(CONTROLLER_GEN) \
Expand All @@ -276,6 +291,15 @@ generate-manifests: $(CONTROLLER_GEN) ## Generate manifests e.g. CRD, RBAC etc.
output:rbac:dir=$(RBAC_ROOT) \
rbac:roleName=manager-role

.PHONY: generate-api-docs
generate-api-docs: generate-api-docs-v1beta1 generate-api-docs-v1alpha7 generate-api-docs-v1alpha6 generate-api-docs-v1alpha1
generate-api-docs-%: $(GEN_CRD_API_REFERENCE_DOCS) FORCE
$(GEN_CRD_API_REFERENCE_DOCS) \
-api-dir=./api/$* \
-config=./docs/book/gen-crd-api-reference-docs/config.json \
-template-dir=./docs/book/gen-crd-api-reference-docs/template \
-out-file=./docs/book/src/api/$*/api.md

## --------------------------------------
##@ Docker
## --------------------------------------
Expand Down Expand Up @@ -404,12 +428,13 @@ release-notes: $(RELEASE_NOTES) ## Generate release notes
templates: ## Generate cluster templates
templates: templates/cluster-template.yaml \
templates/cluster-template-without-lb.yaml \
templates/cluster-template-flatcar.yaml
templates/cluster-template-flatcar.yaml \
templates/cluster-template-flatcar-sysext.yaml

templates/cluster-template.yaml: kustomize/v1alpha7/default $(KUSTOMIZE) FORCE
templates/cluster-template.yaml: kustomize/v1beta1/default $(KUSTOMIZE) FORCE
$(KUSTOMIZE) build "$<" > "$@"

templates/cluster-template-%.yaml: kustomize/v1alpha7/% $(KUSTOMIZE) FORCE
templates/cluster-template-%.yaml: kustomize/v1beta1/% $(KUSTOMIZE) FORCE
$(KUSTOMIZE) build "$<" > "$@"

.PHONY: release-templates
Expand Down
2 changes: 2 additions & 0 deletions OWNERS
Original file line number Diff line number Diff line change
Expand Up @@ -19,3 +19,5 @@ emeritus_approvers:
- sbueringer
- hidekazuna
- chrischdi
- tobiasgiese
- seanschneeweiss
3 changes: 1 addition & 2 deletions OWNERS_ALIASES
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,6 @@ aliases:
- jichenjc
- lentzi90
- mdbooth
- seanschneeweiss
- tobiasgiese
cluster-api-openstack-reviewers:
- emilienm
- dulek
39 changes: 29 additions & 10 deletions PROJECT
Original file line number Diff line number Diff line change
@@ -1,40 +1,59 @@
version: "2"
# Code generated by tool. DO NOT EDIT.
# This file is used to track the info used to scaffold your project
# and allow the plugins properly work.
# More info: https://book.kubebuilder.io/reference/project-config.html
domain: cluster.x-k8s.io
repo: sigs.k8s.io/cluster-api-provider-openstack
resources:
- group: infrastructure
version: v1alpha5
kind: OpenStackCluster
- group: infrastructure
version: v1alpha5
kind: OpenStackMachine
- group: infrastructure
kind: OpenStackMachine
version: v1alpha5
- group: infrastructure
kind: OpenStackMachineTemplate
version: v1alpha5
- group: infrastructure
kind: OpenStackClusterTemplate
version: v1alpha5
- group: infrastructure
version: v1alpha6
kind: OpenStackCluster
- group: infrastructure
version: v1alpha6
kind: OpenStackMachine
- group: infrastructure
kind: OpenStackMachine
version: v1alpha6
- group: infrastructure
kind: OpenStackMachineTemplate
version: v1alpha6
- group: infrastructure
kind: OpenStackClusterTemplate
version: v1alpha6
- group: infrastructure
version: v1alpha7
kind: OpenStackCluster
- group: infrastructure
version: v1alpha7
kind: OpenStackMachine
- group: infrastructure
kind: OpenStackMachine
version: v1alpha7
- group: infrastructure
kind: OpenStackMachineTemplate
version: v1alpha7
- group: infrastructure
kind: OpenStackClusterTemplate
version: v1alpha7
- group: infrastructure
version: v1beta1
kind: OpenStackCluster
- group: infrastructure
version: v1beta1
kind: OpenStackMachine
- group: infrastructure
version: v1beta1
kind: OpenStackMachineTemplate
- group: infrastructure
kind: OpenStackClusterTemplate
version: v1beta1
- group: infrastructure
kind: OpenStackFloatingIPPool
version: v1alpha1
version: "2"
17 changes: 10 additions & 7 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,8 @@ This provider's versions are compatible with the following versions of Cluster A
|------------------------------------| -------------- |
| OpenStack Provider v1alpha5 (v0.6) ||
| OpenStack Provider v1alpha6 (v0.7) ||
| OpenStack Provider v1alpha7 ||
| OpenStack Provider v1alpha7 (v0.9) ||
| OpenStack Provider v1beta1 ||


This provider's versions are able to install and manage the following versions of Kubernetes:
Expand All @@ -52,15 +53,17 @@ This provider's versions are able to install and manage the following versions o
|------------------------------------| ----- | ----- | ----- | ----- |
| OpenStack Provider v1alpha5 (v0.6) || + | + | + |
| OpenStack Provider v1alpha6 (v0.7) |||| + |
| OpenStack Provider v1alpha7 | + ||||
| OpenStack Provider v1alpha7 (v0.9) | + ||||
| OpenStack Provider v1beta1 | + ||||

This provider's versions are able to install Kubernetes to the following versions of OpenStack:

| | Queens | Rocky | Stein | Train | Ussuri | Victoria | Wallaby | Xena | Yoga |
|------------------------------------| ------ | ----- | ----- | ----- | ------ | -------- | ------- | ---- | ---- |
| OpenStack Provider v1alpha5 (v0.6) | + | + | + | + | + |||||
| OpenStack Provider v1alpha6 (v0.7) | + | + | + | + | + |||||
| OpenStack Provider v1alpha7 | | + | + | + | + |||||
| | Queens | Rocky | Stein | Train | Ussuri | Victoria | Wallaby | Xena | Yoga | Bobcat |
|------------------------------------| ------ | ----- | ----- | ----- | ------ | -------- | ------- | ---- | ---- | ------ |
| OpenStack Provider v1alpha5 (v0.6) | + | + | + | + | + ||||||
| OpenStack Provider v1alpha6 (v0.7) | + | + | + | + | + ||||||
| OpenStack Provider v1alpha7 (v0.9) | | + | + | + | + ||||||
| OpenStack Provider v1beta1 | | + | + | + | + ||||||

Test status:

Expand Down
8 changes: 4 additions & 4 deletions RELEASE.md
Original file line number Diff line number Diff line change
Expand Up @@ -60,11 +60,11 @@ The content of the release notes differs depending on the type of release, speci

This will cause the image to be automatically built by CI and pushed to the staging repository. As this only builds
the image, it only takes a few minutes.
1. Follow the [image promotion process](https://github.com/kubernetes/k8s.io/tree/main/k8s.gcr.io#image-promoter) to promote the image from the staging repo to `registry.k8s.io/capi-openstack`.
1. Follow the [image promotion process](https://github.com/kubernetes/k8s.io/blob/main/registry.k8s.io/README.md#image-promoter) to promote the image from the staging repo to `registry.k8s.io/capi-openstack`.
The staging repository can be inspected at https://console.cloud.google.com/gcr/images/k8s-staging-capi-openstack/GLOBAL. Be
sure to choose the top level `capi-openstack-controller`, which will provide the multi-arch manifest, rather than one for a specific architecture.
The image build logs are available at [Cloud Build](https://console.cloud.google.com/cloud-build/builds?project=k8s-staging-capi-openstack).
Add the new sha=>tag mapping to the [images.yaml](https://github.com/kubernetes/k8s.io/edit/main/k8s.gcr.io/images/k8s-staging-capi-openstack/images.yaml) (use the sha of the image with the corresponding tag). The PR to update the [images.yaml](https://github.com/kubernetes/k8s.io/edit/main/k8s.gcr.io/images/k8s-staging-capi-openstack/images.yaml) must be approved in the [OWNERS](https://github.com/kubernetes/k8s.io/blob/main/k8s.gcr.io/images/k8s-staging-capi-openstack/OWNERS) file and merged.
Add the new sha=>tag mapping to the [images.yaml](https://github.com/kubernetes/k8s.io/blob/main/registry.k8s.io/images/k8s-staging-capi-openstack/images.yaml) (use the sha of the image with the corresponding tag). The PR to update the [images.yaml](https://github.com/kubernetes/k8s.io/blob/main/registry.k8s.io/images/k8s-staging-capi-openstack/images.yaml) must be approved in the [OWNERS](https://github.com/kubernetes/k8s.io/blob/main/registry.k8s.io/images/k8s-staging-capi-openstack/OWNERS) file and merged.

It is good practise to get somebody else to review this PR. It is safe to perform the following steps while waiting
for review and the promotion of the image.
Expand Down Expand Up @@ -92,12 +92,12 @@ The content of the release notes differs depending on the type of release, speci

Releasing requires a particular set of permissions.

* Approver role for the image promoter process ([kubernetes/k8s.io/blob/main/k8s.gcr.io/images/k8s-staging-capi-openstack/OWNERS](https://github.com/kubernetes/k8s.io/blob/main/k8s.gcr.io/images/k8s-staging-capi-openstack/OWNERS))
* Approver role for the image promoter process ([kubernetes/k8s.io/blob/main/registry.k8s.io/images/k8s-staging-capi-openstack/OWNERS](https://github.com/kubernetes/k8s.io/blob/main/registry.k8s.io/images/k8s-staging-capi-openstack/OWNERS))
* Tag push and release creation rights to the GitHub repository (team `cluster-api-provider-openstack-maintainers` in [kubernetes/org/config/kubernetes-sigs/sig-cluster-lifecycle/teams.yaml](https://github.com/kubernetes/org/blob/main/config/kubernetes-sigs/sig-cluster-lifecycle/teams.yaml))

## Staging

There is a post-submit Prow job running after each commit on `main` which pushes a new image to the staging repo (`gcr.io/k8s-staging-capi-openstack/capi-openstack-controller:latest`). Following configuration is involved:
* staging gcr bucket: [kubernetes/k8s.io/blob/main/k8s.gcr.io/manifests/k8s-staging-capi-openstack/promoter-manifest.yaml](https://github.com/kubernetes/k8s.io/blob/main/k8s.gcr.io/manifests/k8s-staging-capi-openstack/promoter-manifest.yaml)
* staging gcr bucket: [kubernetes/k8s.io/blob/main/registry.k8s.io/manifests/k8s-staging-capi-openstack/promoter-manifest.yaml](https://github.com/kubernetes/k8s.io/blob/main/registry.k8s.io/manifests/k8s-staging-capi-openstack/promoter-manifest.yaml)
* post-submit `post-capi-openstack-push-images` Prow job: [kubernetes/test-infra/blob/master/config/jobs/image-pushing/k8s-staging-cluster-api.yaml](https://github.com/kubernetes/test-infra/blob/master/config/jobs/image-pushing/k8s-staging-cluster-api.yaml)) (corresponding dashboard is located at [https://testgrid.k8s.io/sig-cluster-lifecycle-image-pushes#post-capi-openstack-push-images](https://testgrid.k8s.io/sig-cluster-lifecycle-image-pushes#post-capi-openstack-push-images))
* Google Cloud Build configuration which is used by the Prow job: [kubernetes-sigs/cluster-api-provider-openstack/cloudbuild.yaml](https://github.com/kubernetes-sigs/cluster-api-provider-openstack/blob/main/cloudbuild.yaml)
Original file line number Diff line number Diff line change
Expand Up @@ -14,19 +14,15 @@ See the License for the specific language governing permissions and
limitations under the License.
*/

package v1alpha7
package v1alpha1

import (
"sigs.k8s.io/controller-runtime/pkg/builder"
logf "sigs.k8s.io/controller-runtime/pkg/log"
"sigs.k8s.io/controller-runtime/pkg/manager"
)
const (
// OpenstackFloatingIPPoolReadyCondition reports on the current status of the floating ip pool. Ready indicates that the pool is ready to be used.
OpenstackFloatingIPPoolReadyCondition = "OpenstackFloatingIPPoolReadyCondition"

// log is for logging in this package.
var _ = logf.Log.WithName("openstackclusterlist-resource")
// MaxIPsReachedReason is set when the maximum number of floating IPs has been reached.
MaxIPsReachedReason = "MaxIPsReached"

func (r *OpenStackClusterList) SetupWebhookWithManager(mgr manager.Manager) error {
return builder.WebhookManagedBy(mgr).
For(r).
Complete()
}
// UnableToFindFloatingIPNetworkReason is used when the floating ip network is not found.
UnableToFindNetwork = "UnableToFindNetwork"
)

0 comments on commit c42a465

Please sign in to comment.