Skip to content

Commit b50680f

Browse files
Aniruddha Basakjaniskemper
authored andcommitted
🐛 Fix hook server service account and scheme
Update the hook sever service role Signed-off-by: Aniruddha Basak <[email protected]>
1 parent 6f43c23 commit b50680f

File tree

9 files changed

+50
-123
lines changed

9 files changed

+50
-123
lines changed

extension/config/default/sa-roles.yaml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,8 @@ rules:
1414
- clusters
1515
verbs:
1616
- get
17+
- patch
18+
- update
1719
- apiGroups:
1820
- clusterstack.x-k8s.io
1921
resources:

extension/go.mod

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,14 @@
11
module github.com/SovereignCloudStack/cluster-stack-operator/extension
22

3-
go 1.19
3+
go 1.21
4+
5+
toolchain go1.21.6
46

57
replace github.com/SovereignCloudStack/cluster-stack-operator => ../
68

79
require (
10+
github.com/SovereignCloudStack/cluster-stack-operator v0.1.0-alpha.2
811
github.com/spf13/pflag v1.0.5
9-
github.com/sovereigncloudstack/cluster-stack-operator v0.0.0-00010101000000-000000000000
1012
k8s.io/apimachinery v0.29.0
1113
k8s.io/component-base v0.28.4
1214
k8s.io/klog/v2 v2.110.1
@@ -15,7 +17,6 @@ require (
1517
)
1618

1719
require (
18-
github.com/SovereignCloudStack/cluster-stack-operator v0.1.0-alpha.2 // indirect
1920
github.com/beorn7/perks v1.0.1 // indirect
2021
github.com/blang/semver/v4 v4.0.0 // indirect
2122
github.com/cespare/xxhash/v2 v2.2.0 // indirect

extension/go.sum

Lines changed: 4 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -6,8 +6,6 @@ github.com/Masterminds/semver/v3 v3.2.0 h1:3MEsd0SM6jqZojhjLWWeBY+Kcjy9i6MQAeY7Y
66
github.com/Masterminds/semver/v3 v3.2.0/go.mod h1:qvl/7zhW3nngYb5+80sSMF+FG2BjYrf8m9wsX0PNOMQ=
77
github.com/Masterminds/sprig/v3 v3.2.3 h1:eL2fZNezLomi0uOLqjQoN6BfsDD+fyLtgbJMAj9n6YA=
88
github.com/Masterminds/sprig/v3 v3.2.3/go.mod h1:rXcFaZ2zZbLRJv/xSysmlgIM1u11eBaRMhvYXJNkGuM=
9-
github.com/SovereignCloudStack/cluster-stack-operator v0.1.0-alpha.2 h1:23sNJB4z0wiguCeG0W+GdusBrRNYGcKsUYLZo01wZNs=
10-
github.com/SovereignCloudStack/cluster-stack-operator v0.1.0-alpha.2/go.mod h1:qXyqN2aZ+JCtVIVMNdr736b+3XNmaOhsXjGZuMUUUp0=
119
github.com/antlr/antlr4/runtime/Go/antlr/v4 v4.0.0-20230305170008-8188dc5388df h1:7RFfzj4SSt6nnvCPbCqijJi1nWCd+TqAT3bYCStRC18=
1210
github.com/antlr/antlr4/runtime/Go/antlr/v4 v4.0.0-20230305170008-8188dc5388df/go.mod h1:pSwJ0fSY5KhvocuWSx4fz3BA8OrA1bQn+K1Eli3BRwM=
1311
github.com/asaskevich/govalidator v0.0.0-20190424111038-f61b66f89f4a h1:idn718Q4B6AGu/h5Sxe66HYVdqdGu2l9Iebqhi/AEoA=
@@ -115,8 +113,8 @@ github.com/modern-go/reflect2 v1.0.2 h1:xBagoLtFs94CBntxluKeaWgTMpvLxC4ur3nMaC9G
115113
github.com/modern-go/reflect2 v1.0.2/go.mod h1:yWuevngMOJpCy52FWWMvUC8ws7m/LJsjYzDa0/r8luk=
116114
github.com/munnerz/goautoneg v0.0.0-20191010083416-a7dc8b61c822 h1:C3w9PqII01/Oq1c1nUAm88MOHcQC9l5mIlSMApZMrHA=
117115
github.com/munnerz/goautoneg v0.0.0-20191010083416-a7dc8b61c822/go.mod h1:+n7T8mK8HuQTcFwEeznm/DIxMOiR9yIdICNftLE1DvQ=
118-
github.com/onsi/ginkgo/v2 v2.13.2 h1:Bi2gGVkfn6gQcjNjZJVO8Gf0FHzMPf2phUei9tejVMs=
119-
github.com/onsi/ginkgo/v2 v2.13.2/go.mod h1:XStQ8QcGwLyF4HdfcZB8SFOS/MWCgDuXMSBe6zrvLgM=
116+
github.com/onsi/ginkgo/v2 v2.13.1 h1:LNGfMbR2OVGBfXjvRZIZ2YCTQdGKtPLvuI1rMCCj3OU=
117+
github.com/onsi/ginkgo/v2 v2.13.1/go.mod h1:XStQ8QcGwLyF4HdfcZB8SFOS/MWCgDuXMSBe6zrvLgM=
120118
github.com/onsi/gomega v1.30.0 h1:hvMK7xYz4D3HapigLTeGdId/NcfQx1VHMJc60ew99+8=
121119
github.com/onsi/gomega v1.30.0/go.mod h1:9sxs+SwGrKI0+PWe4Fxa9tFQQBG5xSsSbMXOI8PPpoQ=
122120
github.com/opencontainers/go-digest v1.0.0 h1:apOUWs51W5PlhuyGyz9FCeeBIOUDA/6nW8Oi/yOhh5U=
@@ -162,8 +160,8 @@ github.com/yuin/goldmark v1.2.1/go.mod h1:3hX8gzYuyVAZsxl0MRgGTJEmQBFcNTphYh9dec
162160
github.com/yuin/goldmark v1.3.5/go.mod h1:mwnBkeHKe2W/ZEtQ+71ViKU8L12m81fl3OWwC1Zlc8k=
163161
go.uber.org/atomic v1.7.0/go.mod h1:fEN4uk6kAWBTFdckzkM89CLk9XfWZrxpCo0nPH17wJc=
164162
go.uber.org/goleak v1.1.11/go.mod h1:cwTWslyiVhfpKIDGSZEM2HlOvcqm+tG4zioyIeLoqMQ=
165-
go.uber.org/goleak v1.3.0 h1:2K3zAYmnTNqV73imy9J1T3WC+gmCePx2hEGkimedGto=
166-
go.uber.org/goleak v1.3.0/go.mod h1:CoHD4mav9JJNrW/WLlf7HGZPjdw8EucARQHekz1X6bE=
163+
go.uber.org/goleak v1.2.1 h1:NBol2c7O1ZokfZ0LEU9K6Whx/KnwvepVetCUhtKja4A=
164+
go.uber.org/goleak v1.2.1/go.mod h1:qlT2yGI9QafXHhZZLxlSuNsMw3FFLxBr+tBRlmO1xH4=
167165
go.uber.org/multierr v1.6.0/go.mod h1:cdWPpRnG4AhwMwsgIHip0KRBQjJy5kYEpYjJxpXp9iU=
168166
go.uber.org/multierr v1.11.0 h1:blXXJkSxSSfBVBlC76pxqeO+LN3aDfLQo+309xJstO0=
169167
go.uber.org/multierr v1.11.0/go.mod h1:20+QtiLqy0Nd6FdQB9TLXag12DsQkrbs3htMFfDN80Y=

extension/handlers/hooks.go

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,7 @@ import (
2121
"fmt"
2222

2323
csov1alpha1 "github.com/SovereignCloudStack/cluster-stack-operator/api/v1alpha1"
24+
"k8s.io/apimachinery/pkg/runtime"
2425
"k8s.io/apimachinery/pkg/types"
2526
runtimehooksv1 "sigs.k8s.io/cluster-api/exp/runtime/hooks/api/v1alpha1"
2627
"sigs.k8s.io/cluster-api/util/conditions"
@@ -33,7 +34,7 @@ type ExtensionHandler struct {
3334
client client.Client
3435
}
3536

36-
func NewExtensionHandlers(client client.Client) *ExtensionHandler {
37+
func NewExtensionHandlers(client client.Client, scheme *runtime.Scheme) *ExtensionHandler {
3738
return &ExtensionHandler{
3839
client: client,
3940
}
@@ -92,6 +93,7 @@ func (e *ExtensionHandler) DoAfterControlPlaneInitialized(ctx context.Context, r
9293
key := types.NamespacedName{Name: fmt.Sprintf("cluster-addon-%s", request.Cluster.GetName()), Namespace: request.Cluster.GetNamespace()}
9394
clusterAddon := &csov1alpha1.ClusterAddon{}
9495
if err := e.client.Get(ctx, key, clusterAddon); err != nil {
96+
log.Error(err, "failed to get the cluster addon")
9597
response.SetStatus(runtimehooksv1.ResponseStatusFailure)
9698
response.SetMessage(err.Error())
9799
return
@@ -110,6 +112,8 @@ func (e *ExtensionHandler) DoAfterControlPlaneInitialized(ctx context.Context, r
110112
}
111113
}()
112114

115+
clusterAddon.Spec.Hook = "AfterControlPlaneInitialized"
116+
113117
response.SetStatus(runtimehooksv1.ResponseStatusSuccess)
114118
return
115119
}

extension/main.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -140,14 +140,14 @@ func main() {
140140
}
141141
restConfig.UserAgent = remote.DefaultClusterAPIUserAgent(controllerName)
142142

143-
client, err := client.New(restConfig, client.Options{})
143+
client, err := client.New(restConfig, client.Options{Scheme: scheme})
144144
if err != nil {
145145
setupLog.Error(err, "error creating client to the cluster")
146146
os.Exit(1)
147147
}
148148

149149
// Create the ExtensionHandlers for the lifecycle hooks
150-
lifecycleExtensionHandlers := handlers.NewExtensionHandlers(client)
150+
lifecycleExtensionHandlers := handlers.NewExtensionHandlers(client, scheme)
151151

152152
if err := webhookServer.AddExtensionHandler(server.ExtensionHandler{
153153
Hook: runtimehooksv1.BeforeClusterUpgrade,

extension/vendor/github.com/SovereignCloudStack/cluster-stack-operator/api/v1alpha1/clusterstack_types.go

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

extension/vendor/github.com/SovereignCloudStack/cluster-stack-operator/pkg/version/channel.go

Lines changed: 9 additions & 3 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

extension/vendor/github.com/SovereignCloudStack/cluster-stack-operator/pkg/version/version.go

Lines changed: 23 additions & 105 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

extension/vendor/modules.txt

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -142,8 +142,6 @@ github.com/prometheus/common/model
142142
github.com/prometheus/procfs
143143
github.com/prometheus/procfs/internal/fs
144144
github.com/prometheus/procfs/internal/util
145-
# github.com/sovereigncloudstack/cluster-stack-operator v0.0.0-00010101000000-000000000000
146-
## explicit
147145
# github.com/spf13/cobra v1.8.0
148146
## explicit; go 1.15
149147
github.com/spf13/cobra

0 commit comments

Comments
 (0)