Skip to content

Commit fd2d163

Browse files
DanNiEShclaude
andcommitted
Add AAP provisioning and deprovisioning workflow
- Add provisioning lifecycle: trigger AAP provision jobs when templateID is set, poll for completion, and set ProvisionTemplateComplete condition - Add deprovisioning lifecycle: trigger AAP deprovision jobs on deletion before finalizer removal, with status flush to prevent duplicate jobs on crash - Refactor Reconcile into handleUpdate/reconcileDelete with centralized status updates Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
1 parent d206b73 commit fd2d163

9 files changed

Lines changed: 428 additions & 85 deletions

File tree

Containerfile

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
# Build the manager binary
2-
FROM golang:1.25 AS builder
2+
FROM golang:1.26 AS builder
33
ARG TARGETOS
44
ARG TARGETARCH
55

cmd/main.go

Lines changed: 30 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,7 @@ import (
2222
"fmt"
2323
"os"
2424
"path/filepath"
25+
"strconv"
2526

2627
// Import all Kubernetes client auth plugins (e.g. Azure, GCP, OIDC, etc.)
2728
// to ensure that exec-entrypoint and run can make use of them.
@@ -40,9 +41,11 @@ import (
4041
metricsserver "sigs.k8s.io/controller-runtime/pkg/metrics/server"
4142
"sigs.k8s.io/controller-runtime/pkg/webhook"
4243

43-
v1alpha1 "github.com/osac-project/bare-metal-operator/api/v1alpha1"
44+
v1alpha1 "github.com/osac-project/bare-metal-fulfillment-operator/api/v1alpha1"
4445
"github.com/osac-project/host-management-openstack/internal/controller"
4546
"github.com/osac-project/host-management-openstack/internal/ironic"
47+
"github.com/osac-project/osac-operator/pkg/aap"
48+
"github.com/osac-project/osac-operator/pkg/provisioning"
4649
// +kubebuilder:scaffold:imports
4750
)
4851

@@ -230,11 +233,37 @@ func main() {
230233
}
231234
setupLog.Info("Connect to ironic", "endpoint", ironicClient.GetEndpoint())
232235

236+
// AAP provisioning provider for image provisioning workflows
237+
var provisioningProvider provisioning.ProvisioningProvider
238+
if aapURL := os.Getenv(controller.EnvAAPURL); aapURL != "" {
239+
aapToken := os.Getenv(controller.EnvAAPToken)
240+
insecureSkipVerify, _ := strconv.ParseBool(os.Getenv(controller.EnvAAPInsecureSkipVerify))
241+
templatePrefix := os.Getenv(controller.EnvAAPTemplatePrefix)
242+
if templatePrefix == "" {
243+
templatePrefix = "osac"
244+
}
245+
aapClient := aap.NewClient(aapURL, aapToken, insecureSkipVerify)
246+
var err error
247+
provisioningProvider, err = provisioning.NewProvider(provisioning.ProviderConfig{
248+
ProviderType: provisioning.ProviderTypeAAP,
249+
AAPClient: aapClient,
250+
TemplatePrefix: templatePrefix,
251+
})
252+
if err != nil {
253+
setupLog.Error(err, "failed to create provisioning provider")
254+
os.Exit(1)
255+
}
256+
setupLog.Info("AAP provisioning provider configured", "url", aapURL, "templatePrefix", templatePrefix)
257+
} else {
258+
setupLog.Info("AAP not configured, provisioning workflows disabled", "envVar", controller.EnvAAPURL)
259+
}
260+
233261
// Create HostLease reconciler with defaults
234262
hostLeaseReconciler := controller.NewHostLeaseReconciler(
235263
mgr.GetClient(),
236264
mgr.GetScheme(),
237265
ironicClient,
266+
provisioningProvider,
238267
0, // Use DefaultRecheckInterval
239268
)
240269
if err := hostLeaseReconciler.SetupWithManager(mgr); err != nil {

cmd/main_test.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ import (
2222
. "github.com/onsi/ginkgo/v2" //nolint:revive,staticcheck
2323
. "github.com/onsi/gomega" //nolint:revive,staticcheck
2424

25-
osacv1alpha1 "github.com/osac-project/bare-metal-operator/api/v1alpha1"
25+
osacv1alpha1 "github.com/osac-project/bare-metal-fulfillment-operator/api/v1alpha1"
2626
corev1 "k8s.io/api/core/v1"
2727
"k8s.io/apimachinery/pkg/runtime"
2828
clientgoscheme "k8s.io/client-go/kubernetes/scheme"

config/samples/v1alpha1_hostlease.yaml

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -5,12 +5,12 @@ metadata:
55
namespace: osac-namespace
66
spec:
77
externalHostID: efa3d310-164d-44a4-a399-46cbcdaa587a
8-
externalHostName: MOC-R4PAC08U21-S1
8+
externalHostName: MOC-R4PAC08U33-S1A
99
hostType: fc830
10-
# hostClass: openstack
10+
hostClass: openstack
1111
networkClass: openstack
1212
networkInterfaces:
1313
- macAddress: aa:bb:cc:dd:ee:f1
1414
network: private-vlan-network
1515
# poweredOn: on
16-
templateID: default_template
16+
templateID: bm_host_image_provision

go.mod

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,15 @@
11
module github.com/osac-project/host-management-openstack
22

3-
go 1.25.0
3+
go 1.26.0
44

55
require (
66
github.com/go-logr/logr v1.4.3
77
github.com/gophercloud/gophercloud/v2 v2.12.0
88
github.com/gophercloud/utils/v2 v2.0.0-20260409164906-cd2167a8681a
99
github.com/onsi/ginkgo/v2 v2.28.1
1010
github.com/onsi/gomega v1.39.1
11+
github.com/osac-project/osac-operator v0.1.1-0.20260511193951-8bf9632098a0
12+
github.com/osac-project/osac-operator/api v0.0.2-0.20260511193951-8bf9632098a0
1113
k8s.io/apimachinery v0.35.4
1214
k8s.io/client-go v0.35.4
1315
sigs.k8s.io/controller-runtime v0.23.3
@@ -16,7 +18,6 @@ require (
1618
require (
1719
github.com/Masterminds/semver/v3 v3.4.0 // indirect
1820
github.com/gofrs/uuid/v5 v5.4.0 // indirect
19-
github.com/osac-project/osac-operator v0.0.0-20260413152945-199a0469a4c2 // indirect
2021
github.com/pmezard/go-difflib v1.0.1-0.20181226105442-5d4384ee4fb2 // indirect
2122
go.yaml.in/yaml/v2 v2.4.3 // indirect
2223
go.yaml.in/yaml/v3 v3.0.4 // indirect
@@ -57,7 +58,7 @@ require (
5758
github.com/modern-go/concurrent v0.0.0-20180306012644-bacd9c7ef1dd // indirect
5859
github.com/modern-go/reflect2 v1.0.3-0.20250322232337-35a7c28c31ee // indirect
5960
github.com/munnerz/goautoneg v0.0.0-20191010083416-a7dc8b61c822 // indirect
60-
github.com/osac-project/bare-metal-operator v0.0.0-20260423171233-28ec2bd86640
61+
github.com/osac-project/bare-metal-fulfillment-operator v0.0.0-20260518182443-35f2a9590dcc
6162
github.com/prometheus/client_golang v1.23.2 // indirect
6263
github.com/prometheus/client_model v0.6.2 // indirect
6364
github.com/prometheus/common v0.66.1 // indirect
@@ -80,7 +81,7 @@ require (
8081
golang.org/x/exp v0.0.0-20250210185358-939b2ce775ac // indirect
8182
golang.org/x/net v0.49.0 // indirect
8283
golang.org/x/oauth2 v0.36.0 // indirect
83-
golang.org/x/sync v0.19.0 // indirect
84+
golang.org/x/sync v0.20.0 // indirect
8485
golang.org/x/sys v0.42.0 // indirect
8586
golang.org/x/term v0.39.0 // indirect
8687
golang.org/x/text v0.33.0 // indirect
@@ -96,8 +97,8 @@ require (
9697
gopkg.in/yaml.v3 v3.0.1 // indirect
9798
k8s.io/api v0.35.4
9899
k8s.io/apiextensions-apiserver v0.35.0 // indirect
99-
k8s.io/apiserver v0.35.0 // indirect
100-
k8s.io/component-base v0.35.0 // indirect
100+
k8s.io/apiserver v0.35.4 // indirect
101+
k8s.io/component-base v0.35.4 // indirect
101102
k8s.io/klog/v2 v2.130.1 // indirect
102103
k8s.io/kube-openapi v0.0.0-20250910181357-589584f1c912 // indirect
103104
k8s.io/utils v0.0.0-20251002143259-bc988d571ff4 // indirect

go.sum

Lines changed: 12 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -111,10 +111,12 @@ github.com/onsi/ginkgo/v2 v2.28.1 h1:S4hj+HbZp40fNKuLUQOYLDgZLwNUVn19N3Atb98NCyI
111111
github.com/onsi/ginkgo/v2 v2.28.1/go.mod h1:CLtbVInNckU3/+gC8LzkGUb9oF+e8W8TdUsxPwvdOgE=
112112
github.com/onsi/gomega v1.39.1 h1:1IJLAad4zjPn2PsnhH70V4DKRFlrCzGBNrNaru+Vf28=
113113
github.com/onsi/gomega v1.39.1/go.mod h1:hL6yVALoTOxeWudERyfppUcZXjMwIMLnuSfruD2lcfg=
114-
github.com/osac-project/bare-metal-operator v0.0.0-20260423171233-28ec2bd86640 h1:dYT1/qh3zVJGryZO+ySdLCQNmCkXCzl527Bd0m4bs8g=
115-
github.com/osac-project/bare-metal-operator v0.0.0-20260423171233-28ec2bd86640/go.mod h1:QifCZ5ITT0CLDQ1ZaG0ac9w+9KAmtfnafesvxZ635bM=
116-
github.com/osac-project/osac-operator v0.0.0-20260413152945-199a0469a4c2 h1:DI1B9fMQgjUlkHVL7OuO1fQ24MmYQIrktKslqp0K9nE=
117-
github.com/osac-project/osac-operator v0.0.0-20260413152945-199a0469a4c2/go.mod h1:k/5CPGjhIS9n/BRBQHtxABzeA69yjtBWtLHmnloYeqE=
114+
github.com/osac-project/bare-metal-fulfillment-operator v0.0.0-20260518182443-35f2a9590dcc h1:Ayw/y3WiCxQh8I8nKuyacNxrBeq1GCw60bNLfFD16rQ=
115+
github.com/osac-project/bare-metal-fulfillment-operator v0.0.0-20260518182443-35f2a9590dcc/go.mod h1:N+t/4UPZajrHeDSjKAy+PwyydVaiONx4Uv0DRhk6o0I=
116+
github.com/osac-project/osac-operator v0.1.1-0.20260511193951-8bf9632098a0 h1:w2POmUbIU+ecHGUky0SifYFWV5W05VijjixjnpWN2xw=
117+
github.com/osac-project/osac-operator v0.1.1-0.20260511193951-8bf9632098a0/go.mod h1:c207O7XvQtIY6hFIqUAv3yB2JQt1ZRrsWA+wEla87aQ=
118+
github.com/osac-project/osac-operator/api v0.0.2-0.20260511193951-8bf9632098a0 h1:ddxVNqBMGOk/xx19OgAuLZpKpId7A14pElhQ6eslAl8=
119+
github.com/osac-project/osac-operator/api v0.0.2-0.20260511193951-8bf9632098a0/go.mod h1:JBz/wSWPT4NhksjXZs2QUjulga+KTUdW5UJX0kB22aA=
118120
github.com/pkg/errors v0.9.1 h1:FEBLx1zS214owpjy7qsBeixbURkuhQAwrK5UwLGTwt4=
119121
github.com/pkg/errors v0.9.1/go.mod h1:bwawxfHBFNV+L2hUp1rHADufV3IMtnDRdf1r5NINEl0=
120122
github.com/pmezard/go-difflib v1.0.0/go.mod h1:iKH77koFhYxTK1pcRnkKkqfTogsbg7gZNVY4sRDYZ/4=
@@ -197,8 +199,8 @@ golang.org/x/net v0.49.0 h1:eeHFmOGUTtaaPSGNmjBKpbng9MulQsJURQUAfUwY++o=
197199
golang.org/x/net v0.49.0/go.mod h1:/ysNB2EvaqvesRkuLAyjI1ycPZlQHM3q01F02UY/MV8=
198200
golang.org/x/oauth2 v0.36.0 h1:peZ/1z27fi9hUOFCAZaHyrpWG5lwe0RJEEEeH0ThlIs=
199201
golang.org/x/oauth2 v0.36.0/go.mod h1:YDBUJMTkDnJS+A4BP4eZBjCqtokkg1hODuPjwiGPO7Q=
200-
golang.org/x/sync v0.19.0 h1:vV+1eWNmZ5geRlYjzm2adRgW2/mcpevXNg50YZtPCE4=
201-
golang.org/x/sync v0.19.0/go.mod h1:9KTHXmSnoGruLpwFjVSX0lNNA75CykiMECbovNTZqGI=
202+
golang.org/x/sync v0.20.0 h1:e0PTpb7pjO8GAtTs2dQ6jYa5BWYlMuX047Dco/pItO4=
203+
golang.org/x/sync v0.20.0/go.mod h1:9xrNwdLfx4jkKbNva9FpL6vEN7evnE43NNNJQ2LF3+0=
202204
golang.org/x/sys v0.42.0 h1:omrd2nAlyT5ESRdCLYdm3+fMfNFE/+Rf4bDIQImRJeo=
203205
golang.org/x/sys v0.42.0/go.mod h1:4GL1E5IUh+htKOUEOaiffhrAeqysfVGipDYzABqnCmw=
204206
golang.org/x/term v0.39.0 h1:RclSuaJf32jOqZz74CkPA9qFuVTX7vhLlpfj/IGWlqY=
@@ -237,12 +239,12 @@ k8s.io/apiextensions-apiserver v0.35.0 h1:3xHk2rTOdWXXJM+RDQZJvdx0yEOgC0FgQ1PlJa
237239
k8s.io/apiextensions-apiserver v0.35.0/go.mod h1:E1Ahk9SADaLQ4qtzYFkwUqusXTcaV2uw3l14aqpL2LU=
238240
k8s.io/apimachinery v0.35.4 h1:xtdom9RG7e+yDp71uoXoJDWEE2eOiHgeO4GdBzwWpds=
239241
k8s.io/apimachinery v0.35.4/go.mod h1:NNi1taPOpep0jOj+oRha3mBJPqvi0hGdaV8TCqGQ+cc=
240-
k8s.io/apiserver v0.35.0 h1:CUGo5o+7hW9GcAEF3x3usT3fX4f9r8xmgQeCBDaOgX4=
241-
k8s.io/apiserver v0.35.0/go.mod h1:QUy1U4+PrzbJaM3XGu2tQ7U9A4udRRo5cyxkFX0GEds=
242+
k8s.io/apiserver v0.35.4 h1:vtuFqNFmF9bPRdHDL2lpK6qCTPWDreZJL4LRPwVM6ho=
243+
k8s.io/apiserver v0.35.4/go.mod h1:JnBcb+J8kFXKpZkgcbcUnPBBHi4qgBii1I7dLxFY/oo=
242244
k8s.io/client-go v0.35.4 h1:DN6fyaGuzK64UvnKO5fOA6ymSjvfGAnCAHAR0C66kD8=
243245
k8s.io/client-go v0.35.4/go.mod h1:2Pg9WpsS4NeOpoYTfHHfMxBG8zFMSAUi4O/qoiJC3nY=
244-
k8s.io/component-base v0.35.0 h1:+yBrOhzri2S1BVqyVSvcM3PtPyx5GUxCK2tinZz1G94=
245-
k8s.io/component-base v0.35.0/go.mod h1:85SCX4UCa6SCFt6p3IKAPej7jSnF3L8EbfSyMZayJR0=
246+
k8s.io/component-base v0.35.4 h1:6n1tNJ87johN0Hif0Fs8K2GMthsaUwMqCebUDLYyv7U=
247+
k8s.io/component-base v0.35.4/go.mod h1:qaDJgz5c1KYKla9occFmlJEfPpkuA55s90G509R+PeY=
246248
k8s.io/klog/v2 v2.130.1 h1:n9Xl7H1Xvksem4KFG4PYbdQCQxqc/tTUyrgXaOhHSzk=
247249
k8s.io/klog/v2 v2.130.1/go.mod h1:3Jpz1GvMt720eyJH1ckRHK1EDfpxISzJ7I9OYgaDtPE=
248250
k8s.io/kube-openapi v0.0.0-20250910181357-589584f1c912 h1:Y3gxNAuB0OBLImH611+UDZcmKS3g6CthxToOb37KgwE=

0 commit comments

Comments
 (0)