Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
666 commits
Select commit Hold shift + click to select a range
28b90a5
Do not user the PlacementAPI CR name as the DB schema name
mrkisaolamb Jan 11, 2024
fc03473
Use instance.Name in creating resources
mrkisaolamb Jan 11, 2024
269c641
Set DeploymentReady to False when ReadyCount will be 0
mrkisaolamb Jan 2, 2024
410264e
Update openstack-k8s-operators
Jan 15, 2024
4ea5d6c
Watch input secret and update deployment if a relevant password changes
mrkisaolamb Jan 10, 2024
b3cb986
Ensure that DBPasswordSelector is in secret
mrkisaolamb Jan 15, 2024
2729bbc
Update openstack-k8s-operators
Jan 22, 2024
72883dc
[tlse] tls for PlacementAPI pod configuration
Deydra71 Dec 7, 2023
d7eed75
[go.mod]Bump from v0.3.0 to pseudoversion
gibizer Jan 26, 2024
e674727
Drop Debug fields
gibizer Feb 2, 2024
760e21d
Reorganize main reconcile flow
mrkisaolamb Jan 15, 2024
1b4efcc
Remove initcontainer and add more logs
mrkisaolamb Jan 18, 2024
2a54360
Sync refactor with tls enable patches
mrkisaolamb Jan 26, 2024
7090b23
Fix scripts volum issue
mrkisaolamb Feb 2, 2024
4285571
Change secret mounting path to allign with nova-operator
mrkisaolamb Feb 6, 2024
482655c
Bump to latest mariadb-operator/api
gibizer Feb 7, 2024
1eb49fd
[FIPS] build operator in fips mode
SeanMooney Feb 8, 2024
cf2d215
Update openstack-k8s-operators
Feb 9, 2024
533e51d
Add missing logic for DefaultConfigOverwrite
gibizer Feb 8, 2024
54f054f
Update openstack-k8s-operators
Feb 10, 2024
8d366f0
Update controller-runtime version
Feb 6, 2024
4ccdfdb
[webhook] Update webhook functions for CR update
Feb 6, 2024
6273a56
[manager] Update manager initialisation for CR update
Feb 6, 2024
813158e
[watches] Fix watches declarations for CR update
Feb 6, 2024
641c8c1
Update to Go 1.21
Feb 6, 2024
3afea14
Merge pull request #144 from bshephar/controller-runtime
gibizer Feb 14, 2024
96257f8
Revert "Controller runtime update"
gibizer Feb 14, 2024
a9ce3ab
Merge pull request #150 from openstack-k8s-operators/revert-144-contr…
gibizer Feb 14, 2024
8b95708
Update controller-runtime version
gibizer Feb 14, 2024
68fb87b
[webhook] Update webhook functions for CR update
Feb 6, 2024
4197610
[manager] Update manager initialisation for CR update
Feb 6, 2024
b980347
[watches] Fix watches declarations for CR update
Feb 6, 2024
b1920db
Update to Go 1.20
gibizer Feb 14, 2024
3392960
Bump envtest to 1.28 to match k8s.io
gibizer Feb 14, 2024
461276b
Merge pull request #151 from gibizer/controller-runtime-0.16
gibizer Feb 14, 2024
3250f7b
Bump to compatible deps
gibizer Feb 14, 2024
de02f25
Merge pull request #153 from gibizer/controller-runtime-0.16
abays Feb 14, 2024
86f8ffc
Fix mixing go.sum lines
gibizer Feb 14, 2024
12812f6
Merge pull request #154 from gibizer/fix-gosum
abays Feb 14, 2024
cb21d57
Unique LeaderElectionID
stuggi Feb 15, 2024
608567b
Merge pull request #155 from stuggi/election_id
gibizer Feb 15, 2024
533a9f5
Bump golangci-lint
gibizer Feb 16, 2024
614c095
Bump golangci-lint
gibizer Feb 16, 2024
3d349f2
[renovate]Remove golang constraint
gibizer Feb 16, 2024
278c02b
Regenerate go.mod indirect dependencies
gibizer Feb 19, 2024
c3d2988
[tlse] TLS database connection
stuggi Feb 15, 2024
d2a5a5a
Update openstack-k8s-operators
Feb 29, 2024
9270551
migrate from databaseUsername to databaseAccount
zzzeek Feb 23, 2024
39eddb6
Update openstack-k8s-operators
Mar 5, 2024
ab60211
Update module github.com/onsi/ginkgo/v2 to v2.16.0
Mar 7, 2024
970ded0
use Eventually in RunURLAssertSuite test
zzzeek Mar 5, 2024
006a06a
Add PlacementAPISpecCore struct
dprince Mar 1, 2024
0bd583d
Add PlacementAPISpecCore version of validate functions
dprince Mar 7, 2024
9eaa106
Update k8s.io/utils digest to 4693a02
Mar 10, 2024
71131dc
Correct ValidateUpdate for PlacementSpecCore
dprince Mar 11, 2024
1dd69c7
Update openstack-k8s-operators
Mar 13, 2024
3558f06
Pin setup-envtest at working commit to unblock CI
gibizer Mar 22, 2024
fae0c72
Update module github.com/onsi/gomega to v1.32.0
Mar 27, 2024
9a39594
update mariadb to include finalizer secret logic
zzzeek Apr 2, 2024
1dea027
Re-init conditions each reconcile
mrkisaolamb Mar 21, 2024
c710647
Add Status.ObservedGeneration to Nova CR
mrkisaolamb Apr 2, 2024
69252e9
Update openstack-k8s-operators
Apr 4, 2024
887edc5
Ensure golangci-lint runs on all files
gibizer Apr 15, 2024
6a2b76b
Update openstack-k8s-operators
Apr 20, 2024
b5a3f16
[test] validate that TLSInputReadyCondition is ready when cert secret…
stuggi Apr 22, 2024
fcac8d9
Move ObservedGeneration earlier in reconciliation
mrkisaolamb Apr 5, 2024
6d57561
Update openstack-k8s-operators
Apr 24, 2024
cb62011
Bump Placement probe timeouts
SeanMooney Apr 24, 2024
677bc82
Update openstack-k8s-operators
Apr 27, 2024
ccaae3e
Update openstack-k8s-operators
Apr 29, 2024
67bdcd6
Update openstack-k8s-operators
Apr 30, 2024
52a2d82
[pre-commit][kuttl]Check for multiple TestAsserts
gibizer May 13, 2024
673463b
Set fips-compliant CRD feature flag
May 20, 2024
950b728
Check for valid service override endpoint type on create and update
stuggi May 7, 2024
6cee824
Update openstack-k8s-operators
May 27, 2024
a5b0bf4
Wait for DB writes to propagate (causality checks)
gibizer May 29, 2024
d89f81f
Update openstack-k8s-operators to 02d9d18
Jun 3, 2024
0863f22
Correct placement flow to expose service only when deployment is ready
mrkisaolamb May 15, 2024
0aa3698
Update openstack-k8s-operators
Jun 12, 2024
8316c9b
Run make bundle and commit the diff
gibizer May 28, 2024
e414db9
[pre-commit]Run make bundle
gibizer May 28, 2024
5d0e0df
Revert "Wait for DB writes to propagate (causality checks)"
gibizer Jun 14, 2024
519b430
Update openstack-k8s-operators
Jun 15, 2024
ec06106
Update openstack-k8s-operators
Jun 17, 2024
c17fa31
update finalzier to CRD doc
stuggi Jun 17, 2024
1a55890
Update openstack-k8s-operators
Jun 21, 2024
e3f3ea3
Update functional test to simulate LB IP
stuggi Jun 21, 2024
75f6c36
Update openstack-k8s-operators
Jun 22, 2024
d9b7dbf
Update github.com/openstack-k8s-operators/mariadb-operator/api digest…
Jun 22, 2024
2d5918c
Update github.com/openstack-k8s-operators/keystone-operator/api diges…
Jun 23, 2024
0b9bd13
Ensure bundles include all the Required Infrastructure Annotations
mrkisaolamb Jun 25, 2024
94a9077
Update openstack-k8s-operators
Jun 29, 2024
ac0b0c3
Update github.com/openstack-k8s-operators/keystone-operator/api diges…
Jul 3, 2024
7a8d9b5
Adding patch rbac perm for serviceaccounts
gibizer Jul 4, 2024
857fef8
Remove the glance icon field entirely from the CSV
mrkisaolamb Jul 8, 2024
67b6081
Update openstack-k8s-operators
Jul 9, 2024
caef695
Update openstack-k8s-operators
Jul 27, 2024
6ad0a8b
Align restore LastTransitionTime with nova-operator
mrkisaolamb Jul 26, 2024
c5bc274
Update openstack-k8s-operators
Jul 30, 2024
8a8cdd1
Update kuttl test due to lib-common antiaffinity weight change
stuggi Jul 30, 2024
26c067f
Update module github.com/onsi/gomega to v1.34.1
Aug 3, 2024
fc2cf11
Return nil error in case NAD not found to use RequeueAfter
stuggi Aug 6, 2024
d3a775b
Update openstack-k8s-operators
Aug 6, 2024
18dd22d
Update module github.com/onsi/ginkgo/v2 to v2.20.1
Sep 2, 2024
7904631
Update k8s.io to v0.28.13
Sep 2, 2024
af09895
Update tls cert secret validation due VerifyCertSecrets() change
stuggi Sep 5, 2024
dcfb8a7
Update openstack-k8s-operators
Sep 7, 2024
1776a61
Bump golang to 1.21
mrkisaolamb Sep 16, 2024
1247611
set GOTOOLCHAIN min version when init go.work
mrkisaolamb Sep 18, 2024
b59ad6c
Update openstack-k8s-operators
Sep 26, 2024
88e1a00
Update module github.com/gophercloud/gophercloud to v1.14.1
Sep 26, 2024
da97bfb
Update module github.com/k8snetworkplumbingwg/network-attachment-defi…
Sep 26, 2024
c694384
Update openstack-k8s-operators
Sep 27, 2024
0dbd528
Update github.com/openstack-k8s-operators/mariadb-operator/api digest…
Sep 28, 2024
9a07132
Update module github.com/k8snetworkplumbingwg/network-attachment-defi…
Oct 5, 2024
203ecfd
Make sure to log error in findObjectsForSrc()
stuggi Oct 10, 2024
0fcca7e
Update openstack-k8s-operators
Oct 12, 2024
a6fc2d9
Update openstack-k8s-operators
Oct 12, 2024
864edb1
Update github.com/openstack-k8s-operators/keystone-operator/api diges…
Oct 12, 2024
718abf1
Update openstack-k8s-operators
Oct 15, 2024
5285411
Update openstack-k8s-operators
Oct 19, 2024
270dd04
Update module github.com/k8snetworkplumbingwg/network-attachment-defi…
Oct 19, 2024
802442e
Switch to use new CreateServiceReadyCondition
stuggi Oct 24, 2024
d4cca7c
Update openstack-k8s-operators
Oct 30, 2024
e6705df
Improve automated support for local webhooks
abays Oct 30, 2024
1bd39d7
Update openstack-k8s-operators
Nov 2, 2024
9566e1f
Use new nad.EnsureNetworksAnnotation() func to get NAD annotations
stuggi Nov 11, 2024
6494d7b
Set nodeSelector on jobs and allow empty nodeSelector
olliewalsh Nov 13, 2024
9945903
Add nodeSelector functional tests
olliewalsh Nov 13, 2024
e4c1ba6
Pass-through empty nodeSelector to podSpecs
olliewalsh Nov 18, 2024
77c84ef
[make][pre-commit]Check CRD schema to avoid update issues
mrkisaolamb Nov 26, 2024
42cff8b
Update openstack-k8s-operators
Nov 30, 2024
a531fbe
Use conditional assignment for BRANCH
stuggi Dec 3, 2024
5d9278f
Bump CONTROLLER_TOOLS_VERSION to 0.14.0
stuggi Dec 6, 2024
92a44b2
crd-schema-check: allow new CRDs
stuggi Dec 12, 2024
df31b23
Update openstack-k8s-operators
Dec 16, 2024
5c39b09
Added a parameter 'apiTimeout' to allow customization
mrkisaolamb Nov 25, 2024
c7459e2
Update k8s.io to v0.29.13
Jan 18, 2025
ea89ace
Fix bad tls-certs data in octavia_tls kuttl test
mrkisaolamb Feb 13, 2025
0845804
Correct defaulting of timeout
mrkisaolamb Feb 10, 2025
8a31256
Consume Topology CR by reference
fmount Feb 11, 2025
ab799d1
Use quay hosted kube-rbac-proxy image
stuggi Feb 17, 2025
36c58e7
Align LastAppliedTopology to TopologyRef interface
fmount Feb 19, 2025
15c8983
.github/workflows/release-branch-sync.yaml
dprince Feb 25, 2025
52d6965
Update openstack-k8s-operators
Feb 26, 2025
eb9a7af
Improve error handling
mrkisaolamb Feb 26, 2025
0d4e5e1
Switch Topology defaultLabelSelector to lib-common GetLabelSelector
fmount Feb 27, 2025
85c9a82
Update openstack-k8s-operators
Mar 1, 2025
3e53088
Update github.com/openstack-k8s-operators/keystone-operator/api diges…
Mar 2, 2025
6b6afa5
[functional] verify LastAppliedTopology != nil before checking name
stuggi Mar 7, 2025
4e23c5a
Update openstack-k8s-operators
Mar 9, 2025
61d054d
Improve webhook validation for topology references
fmount Mar 20, 2025
aff948c
Update openstack-k8s-operators
Mar 22, 2025
942d238
add zuul noop jobs
SeanMooney Mar 27, 2025
4611fab
Add ratailor and auniyal61 to OWNERS
mrkisaolamb Dec 4, 2024
4a8d5a2
remove placeholder design section from the readme
SeanMooney Mar 27, 2025
7fa1954
Improve topology testing coverage
fmount Mar 29, 2025
7916183
Update openstack-k8s-operators
Mar 29, 2025
785e9ab
Update module github.com/k8snetworkplumbingwg/network-attachment-defi…
Mar 29, 2025
2af0cee
Update openstack-k8s-operators
Apr 5, 2025
403c7ae
Update github.com/openstack-k8s-operators/keystone-operator/api diges…
Apr 6, 2025
eca0e95
Add make force-bump target
dprince Apr 10, 2025
92269f1
[run-with-webhook] Handle operator deploy by Openstack initialization
karelyatin Mar 26, 2025
45fde62
Use deployment.IsReady() to validate status
stuggi Apr 3, 2025
81a4a51
Optmize handling topology logic
fmount Apr 2, 2025
db23ac9
Fix go.mod checksum mismatch
fmount Apr 20, 2025
80229e1
Update openstack-k8s-operators
Apr 20, 2025
8e61c77
Add force-bump-pull-request workflows
dprince Apr 28, 2025
df0bb1b
Update openstack-k8s-operators
Apr 26, 2025
d9bf51e
Leader election lease tunables
hjensas May 6, 2025
0881305
Update openstack-k8s-operators (main)
May 10, 2025
1edb5f5
Do not update the status when reconciler exits due to panic
ratailor May 14, 2025
0e81845
Update openstack-k8s-operators (main)
May 24, 2025
2ecd086
Watch KeystoneAPI status updates to reconcile
stuggi Jun 4, 2025
9c9bcc1
Add pprof-bind-address option to main.go
dprince Jun 18, 2025
c2b28e8
Update openstack-k8s-operators (main)
Jul 5, 2025
ffcacac
Update module github.com/k8snetworkplumbingwg/network-attachment-defi…
Jun 28, 2025
f219879
Update openstack-k8s-operators (main)
Jul 12, 2025
d60bb28
Use structured logging
ratailor Jul 17, 2025
d9002b5
bump rabbitmq-cluster-operator
stuggi Jul 28, 2025
f8444a4
Update openstack-k8s-operators (main)
Aug 2, 2025
3ada315
Update openstack-k8s-operators (main)
Aug 9, 2025
bd92fcd
Update openstack-k8s-operators (main)
Aug 16, 2025
d63b4e7
Remove Lewis from ci-approvers
ninja-quokka Aug 19, 2025
cb89a0c
Update openstack-k8s-operators (main)
Aug 23, 2025
40d41e7
[OSPRH-19382] Remove deprecated Kustomize fields in config dir
abays Aug 25, 2025
85ee919
Make local webhook port configurable
karelyatin Sep 5, 2025
ef2824c
bump to golang 1.24
stuggi Apr 16, 2025
9db39d1
Bump dependencies for OpenShift 4.18 compatibility
stuggi Aug 22, 2025
ab65224
bump openstack-k8s-operator dependencies
stuggi Sep 17, 2025
01613c4
Modernize Go code with latest style conventions
fmount Sep 26, 2025
12e6461
[OSPRH-20438] Improve consistency of condition severity usage
abays Oct 1, 2025
eda4e9d
Bump rabbitmq-cluster-operator dependency
stuggi Oct 1, 2025
26fec21
Update module github.com/onsi/gomega to v1.38.2
Oct 2, 2025
915d552
Update openstack-k8s-operators (main)
Oct 4, 2025
a0180c9
Update module github.com/onsi/ginkgo/v2 to v2.26.0
Oct 6, 2025
46ae39c
Use setup-envtest@release-0.22
abays Oct 15, 2025
a45fab9
Update openstack-k8s-operators (main)
Oct 25, 2025
2aba856
Update openstack-k8s-operators (main)
Nov 1, 2025
59f5c91
Update module github.com/onsi/ginkgo/v2 to v2.27.2
Nov 1, 2025
7583889
Pin base image to 9.6 tag
stuggi Nov 12, 2025
a272264
Upgrade to Operator SDK 1.41.1
stuggi Nov 17, 2025
f158367
Add pprof-bind-address flag support
stuggi Nov 25, 2025
42e6ab0
Re-add --webhook-bind-address flag
stuggi Nov 25, 2025
6ba4b35
Update openstack-k8s-operators (main)
Dec 6, 2025
1dd2c48
Update k8s.io 0.31.x replaces to v0.31.14
Dec 6, 2025
b8357bc
Update openstack-k8s-operators (main)
Dec 20, 2025
4f87861
Update module github.com/onsi/gomega to v1.38.3
Dec 20, 2025
10057ce
Update module github.com/onsi/ginkgo/v2 to v2.27.3
Dec 21, 2025
b894b91
Update openstack-k8s-operators (main)
Dec 27, 2025
5e65ce7
Update openstack-k8s-operators (main)
Jan 3, 2026
a3a9bc0
Bump golangci-lint to 2.7.2
dprince Dec 19, 2025
e2be9cb
Update module github.com/onsi/ginkgo/v2 to v2.27.4
Jan 10, 2026
5267bfb
Update openstack-k8s-operators (main)
Jan 10, 2026
0dcd5c9
Update module github.com/onsi/gomega to v1.39.0
Jan 11, 2026
0d8a2cc
Remove Ollie from owners
abays Jan 23, 2026
693e978
Update openstack-k8s-operators (main)
Jan 24, 2026
0015cb1
Add region_name support to Placement API config
vakwetu Jan 19, 2026
7b903f2
Application Credential support
xek Jan 29, 2026
c46bb49
Remove ci-approvers from OWNERS and OWNERS_ALIAS
amartyasinha Feb 3, 2026
4bfa441
Update openstack-k8s-operators (main)
Feb 7, 2026
9ae2865
Update module github.com/onsi/ginkgo/v2 to v2.28.1
Feb 7, 2026
387f1bb
Update module github.com/onsi/gomega to v1.39.1
Feb 9, 2026
4828c28
Allow triggering the build workflow manually of needed
stuggi Feb 10, 2026
c1c2d8b
Sync envtest optimization across all operators
stuggi Feb 12, 2026
9919225
Update openstack-k8s-operators (main)
Feb 14, 2026
8c493b9
Update openstack-k8s-operators (main)
Feb 28, 2026
523ffaf
Update openstack-k8s-operators (main)
Mar 7, 2026
4ba8bc4
Update openstack-k8s-operators (main)
Mar 14, 2026
aaffa49
Update openstack-k8s-operators (main)
Mar 21, 2026
8439d89
Update openstack-k8s-operators (main)
Apr 4, 2026
72ed2ae
Merge placement-operator/main into nova-operator
auniyal61 Apr 8, 2026
58fb9ff
Move placement API to multi-group structure
auniyal61 Apr 8, 2026
4f79ae0
Move placement controller
auniyal61 Apr 8, 2026
ef67a22
Move placement business logic to internal/placement
auniyal61 Apr 8, 2026
1d5860f
Move placement webhook
auniyal61 Mar 27, 2026
f2c8a56
Move templates
auniyal61 Mar 27, 2026
84f30ee
Move placement tests
auniyal61 Apr 8, 2026
6c1ade7
Add placement kuttl test suite configuration
auniyal61 Apr 8, 2026
93f675d
Rename placement files to remove redundant prefix
auniyal61 Apr 8, 2026
7ae32dd
Update placement import paths and test package names
auniyal61 Mar 27, 2026
1314544
Move placement sample files from placement-operator
auniyal61 Apr 8, 2026
c038940
Update Makefile to generate placement manifests
auniyal61 Apr 8, 2026
2590742
Register PlacementAPI controller and webhook into nova-operator
auniyal61 Apr 1, 2026
d0ffacf
Fix codespell typos in placement code
auniyal61 Apr 6, 2026
b5c406e
placement webhook manifests in config/webhook
auniyal61 Apr 7, 2026
8a30771
Updates placement template paths for multi-group structure
auniyal61 Apr 7, 2026
87622e2
Cleanup placement-import and add generated manifests
auniyal61 Apr 8, 2026
f2945a4
Keep only the base sample in kustomization
auniyal61 Apr 8, 2026
620ad26
Update symlinks
auniyal61 Apr 9, 2026
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 6 additions & 3 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -114,12 +114,13 @@ docker-buildx: ## Build and push docker image for the manager for cross-platform

.PHONY: manifests
manifests: gowork controller-gen ## Generate WebhookConfiguration, ClusterRole and CustomResourceDefinition objects.
$(CONTROLLER_GEN) rbac:roleName=manager-role crd webhook paths="./..." output:crd:artifacts:config=config/crd/bases && \
$(CONTROLLER_GEN) crd webhook paths="./api/nova/..." paths="./api/placement/..." paths="./internal/webhook/nova/..." paths="./internal/webhook/placement/..." output:crd:artifacts:config=config/crd/bases output:webhook:artifacts:config=config/webhook && \
$(CONTROLLER_GEN) rbac:roleName=manager-role paths="./..." output:dir=config/rbac && \
rm -f api/bases/* && cp -a config/crd/bases api/

.PHONY: generate
generate: controller-gen ## Generate code containing DeepCopy, DeepCopyInto, and DeepCopyObject method implementations.
$(CONTROLLER_GEN) object:headerFile="hack/boilerplate.go.txt" paths="./..."
$(CONTROLLER_GEN) object:headerFile="hack/boilerplate.go.txt" paths="./api/nova/..." paths="./api/placement/..."

.PHONY: fmt
fmt: ## Run go fmt against code.
Expand Down Expand Up @@ -147,10 +148,12 @@ PROCS?=$(shell expr $(shell nproc --ignore 2) / 2)
PROC_CMD = --procs ${PROCS}

.PHONY: test
# TODO: Currently runs all tests (Nova + Placement). In future, optimize CI to run only tests
# for the operator code that changed (e.g., skip Placement tests if only Nova code changed).
test: manifests generate fmt vet envtest ginkgo ## Run tests.
KUBEBUILDER_ASSETS="$(shell $(ENVTEST) -v debug --bin-dir $(LOCALBIN) use $(ENVTEST_K8S_VERSION) -p path)" \
OPERATOR_TEMPLATES="$(PWD)/templates" \
$(GINKGO) --trace --cover --coverpkg=../../internal/...,../../api/nova/v1beta1 --coverprofile cover.out --covermode=atomic --randomize-all ${PROC_CMD} $(GINKGO_ARGS) ./test/...
$(GINKGO) --trace --cover --coverpkg=../../internal/...,../../api/nova/v1beta1,../../api/placement/v1beta1 --coverprofile cover.out --covermode=atomic --randomize-all ${PROC_CMD} $(GINKGO_ARGS) ./test/...

##@ Build

Expand Down
502 changes: 502 additions & 0 deletions api/bases/placement.openstack.org_placementapis.yaml

Large diffs are not rendered by default.

259 changes: 259 additions & 0 deletions api/placement/v1beta1/api_types.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,259 @@
/*
Copyright 2022.

Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at

http://www.apache.org/licenses/LICENSE-2.0

Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
*/

package v1beta1

import (
topologyv1 "github.com/openstack-k8s-operators/infra-operator/apis/topology/v1beta1"
condition "github.com/openstack-k8s-operators/lib-common/modules/common/condition"
"github.com/openstack-k8s-operators/lib-common/modules/common/service"
"github.com/openstack-k8s-operators/lib-common/modules/common/tls"
"github.com/openstack-k8s-operators/lib-common/modules/common/util"
corev1 "k8s.io/api/core/v1"
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
"k8s.io/apimachinery/pkg/util/validation/field"
)

const (
// DbSyncHash hash
DbSyncHash = "dbsync"

// DeploymentHash hash used to detect changes
DeploymentHash = "deployment"

// Container image fall-back defaults

// PlacementAPIContainerImage is the fall-back container image for PlacementAPI
PlacementAPIContainerImage = "quay.io/podified-antelope-centos9/openstack-placement-api:current-podified"
)

// PlacementAPISpec defines the desired state of PlacementAPI
type PlacementAPISpec struct {
PlacementAPISpecCore `json:",inline"`

// +kubebuilder:validation:Required
// PlacementAPI Container Image URL (will be set to environmental default if empty)
ContainerImage string `json:"containerImage"`
}

// PlacementAPISpecCore -
type PlacementAPISpecCore struct {
// +kubebuilder:validation:Optional
// +kubebuilder:default=60
// +kubebuilder:validation:Minimum=10
// APITimeout for HAProxy, Apache
APITimeout int `json:"apiTimeout"`

// +kubebuilder:validation:Optional
// +kubebuilder:default=placement
// ServiceUser - optional username used for this service to register in keystone
ServiceUser string `json:"serviceUser"`

// +kubebuilder:validation:Required
// MariaDB instance name
// Right now required by the maridb-operator to get the credentials from the instance to create the DB
// Might not be required in future
DatabaseInstance string `json:"databaseInstance"`

// +kubebuilder:validation:Optional
// +kubebuilder:default=placement
// DatabaseAccount - name of MariaDBAccount which will be used to connect.
DatabaseAccount string `json:"databaseAccount"`

// +kubebuilder:validation:Optional
// +kubebuilder:default=1
// +kubebuilder:validation:Maximum=32
// +kubebuilder:validation:Minimum=0
// Replicas of placement API to run
Replicas *int32 `json:"replicas"`

// +kubebuilder:validation:Required
// Secret containing OpenStack password information for placement PlacementPassword
Secret string `json:"secret"`

// +kubebuilder:validation:Optional
// +kubebuilder:default={service: PlacementPassword}
// PasswordSelectors - Selectors to identify the DB and ServiceUser password from the Secret
PasswordSelectors PasswordSelector `json:"passwordSelectors"`

// +kubebuilder:validation:Optional
// NodeSelector to target subset of worker nodes running this service
NodeSelector *map[string]string `json:"nodeSelector,omitempty"`

// +kubebuilder:validation:Optional
// +kubebuilder:default=false
// PreserveJobs - do not delete jobs after they finished e.g. to check logs
PreserveJobs bool `json:"preserveJobs"`

// +kubebuilder:validation:Optional
// CustomServiceConfig - customize the service config using this parameter to change service defaults,
// or overwrite rendered information using raw OpenStack config format. The content gets added to
// to /etc/<service>/<service>.conf.d directory as custom.conf file.
CustomServiceConfig string `json:"customServiceConfig"`

// +kubebuilder:validation:Optional
// DefaultConfigOverwrite - interface to overwrite default config files like policy.yaml.
DefaultConfigOverwrite map[string]string `json:"defaultConfigOverwrite,omitempty"`

// +kubebuilder:validation:Optional
// Resources - Compute Resources required by this service (Limits/Requests).
// https://kubernetes.io/docs/concepts/configuration/manage-resources-containers/
Resources corev1.ResourceRequirements `json:"resources,omitempty"`

// +kubebuilder:validation:Optional
// NetworkAttachments is a list of NetworkAttachment resource names to expose the services to the given network
NetworkAttachments []string `json:"networkAttachments,omitempty"`

// +kubebuilder:validation:Optional
// Override, provides the ability to override the generated manifest of several child resources.
Override APIOverrideSpec `json:"override,omitempty"`

// +kubebuilder:validation:Optional
// +operator-sdk:csv:customresourcedefinitions:type=spec
// TLS - Parameters related to the TLS
TLS tls.API `json:"tls,omitempty"`

// +kubebuilder:validation:Optional
// +operator-sdk:csv:customresourcedefinitions:type=spec
// Auth - Parameters related to authentication
Auth AuthSpec `json:"auth,omitempty"`

// +kubebuilder:validation:Optional
// TopologyRef to apply the Topology defined by the associated CR referenced
// by name
TopologyRef *topologyv1.TopoRef `json:"topologyRef,omitempty"`
}

// APIOverrideSpec to override the generated manifest of several child resources.
type APIOverrideSpec struct {
// Override configuration for the Service created to serve traffic to the cluster.
// The key must be the endpoint type (public, internal)
Service map[service.Endpoint]service.RoutedOverrideSpec `json:"service,omitempty"`
}

// AuthSpec defines authentication parameters
type AuthSpec struct {
// +kubebuilder:validation:Optional
// +operator-sdk:csv:customresourcedefinitions:type=spec
// ApplicationCredentialSecret - Secret containing Application Credential ID and Secret
ApplicationCredentialSecret string `json:"applicationCredentialSecret,omitempty"`
}

// PasswordSelector to identify the DB and AdminUser password from the Secret
type PasswordSelector struct {
// +kubebuilder:validation:Optional
// +kubebuilder:default="PlacementPassword"
// Service - Selector to get the service user password from the Secret
Service string `json:"service"`
}

// PlacementAPIStatus defines the observed state of PlacementAPI
type PlacementAPIStatus struct {
// ReadyCount of placement API instances
ReadyCount int32 `json:"readyCount,omitempty"`

// Map of hashes to track e.g. job status
Hash map[string]string `json:"hash,omitempty"`

// Conditions
Conditions condition.Conditions `json:"conditions,omitempty" optional:"true"`

// Placement Database Hostname
DatabaseHostname string `json:"databaseHostname,omitempty"`

// NetworkAttachments status of the deployment pods
NetworkAttachments map[string][]string `json:"networkAttachments,omitempty"`

//ObservedGeneration - the most recent generation observed for this service. If the observed generation is less than the spec generation, then the controller has not processed the latest changes.
ObservedGeneration int64 `json:"observedGeneration,omitempty"`

// LastAppliedTopology - the last applied Topology
LastAppliedTopology *topologyv1.TopoRef `json:"lastAppliedTopology,omitempty"`
}

// PlacementAPI is the Schema for the placementapis API
// +kubebuilder:object:root=true
// +kubebuilder:subresource:status
// +kubebuilder:printcolumn:name="NetworkAttachments",type="string",JSONPath=".spec.networkAttachments",description="NetworkAttachments"
// +kubebuilder:printcolumn:name="Status",type="string",JSONPath=".status.conditions[0].status",description="Status"
// +kubebuilder:printcolumn:name="Message",type="string",JSONPath=".status.conditions[0].message",description="Message"
type PlacementAPI struct {
metav1.TypeMeta `json:",inline"`
metav1.ObjectMeta `json:"metadata,omitempty"`

Spec PlacementAPISpec `json:"spec,omitempty"`
Status PlacementAPIStatus `json:"status,omitempty"`
}

// PlacementAPIList contains a list of PlacementAPI
// +kubebuilder:object:root=true
type PlacementAPIList struct {
metav1.TypeMeta `json:",inline"`
metav1.ListMeta `json:"metadata,omitempty"`
Items []PlacementAPI `json:"items"`
}

func init() {
SchemeBuilder.Register(&PlacementAPI{}, &PlacementAPIList{})
}

// IsReady - returns true if PlacementAPI is reconciled successfully
func (instance PlacementAPI) IsReady() bool {
return instance.Status.Conditions.IsTrue(condition.ReadyCondition)
}

// RbacConditionsSet - set the conditions for the rbac object
func (instance PlacementAPI) RbacConditionsSet(c *condition.Condition) {
instance.Status.Conditions.Set(c)
}

// RbacNamespace - return the namespace
func (instance PlacementAPI) RbacNamespace() string {
return instance.Namespace
}

// RbacResourceName - return the name to be used for rbac objects (serviceaccount, role, rolebinding)
func (instance PlacementAPI) RbacResourceName() string {
return "placement-" + instance.Name
}

// SetupDefaults - initializes any CRD field defaults based on environment variables (the defaulting mechanism itself is implemented via webhooks)
func SetupDefaults() {
// Acquire environmental defaults and initialize Placement defaults with them
placementDefaults := PlacementAPIDefaults{
ContainerImageURL: util.GetEnvVar("RELATED_IMAGE_PLACEMENT_API_IMAGE_URL_DEFAULT", PlacementAPIContainerImage),
APITimeout: 60,
}

SetupPlacementAPIDefaults(placementDefaults)
}

// GetSecret returns the value of the Nova.Spec.Secret
func (instance PlacementAPI) GetSecret() string {
return instance.Spec.Secret
}

// ValidateTopology -
func (instance *PlacementAPISpecCore) ValidateTopology(
basePath *field.Path,
namespace string,
) field.ErrorList {
var allErrs field.ErrorList
allErrs = append(allErrs, topologyv1.ValidateTopologyRef(
instance.TopologyRef,
*basePath.Child("topologyRef"), namespace)...)
return allErrs
}
Loading
Loading