Skip to content

Commit

Permalink
🐛 Fix hook server service account and scheme
Browse files Browse the repository at this point in the history
Update the hook sever service role

Signed-off-by: Aniruddha Basak <[email protected]>
  • Loading branch information
aniruddha2000 authored and janiskemper committed Jun 3, 2024
1 parent cbec114 commit 2d38d31
Show file tree
Hide file tree
Showing 9 changed files with 50 additions and 123 deletions.
2 changes: 2 additions & 0 deletions extension/config/default/sa-roles.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,8 @@ rules:
- clusters
verbs:
- get
- patch
- update
- apiGroups:
- clusterstack.x-k8s.io
resources:
Expand Down
7 changes: 4 additions & 3 deletions extension/go.mod
Original file line number Diff line number Diff line change
@@ -1,12 +1,14 @@
module github.com/SovereignCloudStack/cluster-stack-operator/extension

go 1.19
go 1.21

toolchain go1.21.6

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

require (
github.com/SovereignCloudStack/cluster-stack-operator v0.1.0-alpha.2
github.com/spf13/pflag v1.0.5
github.com/sovereigncloudstack/cluster-stack-operator v0.0.0-00010101000000-000000000000
k8s.io/apimachinery v0.29.0
k8s.io/component-base v0.28.4
k8s.io/klog/v2 v2.110.1
Expand All @@ -15,7 +17,6 @@ require (
)

require (
github.com/SovereignCloudStack/cluster-stack-operator v0.1.0-alpha.2 // indirect
github.com/beorn7/perks v1.0.1 // indirect
github.com/blang/semver/v4 v4.0.0 // indirect
github.com/cespare/xxhash/v2 v2.2.0 // indirect
Expand Down
10 changes: 4 additions & 6 deletions extension/go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,6 @@ github.com/Masterminds/semver/v3 v3.2.0 h1:3MEsd0SM6jqZojhjLWWeBY+Kcjy9i6MQAeY7Y
github.com/Masterminds/semver/v3 v3.2.0/go.mod h1:qvl/7zhW3nngYb5+80sSMF+FG2BjYrf8m9wsX0PNOMQ=
github.com/Masterminds/sprig/v3 v3.2.3 h1:eL2fZNezLomi0uOLqjQoN6BfsDD+fyLtgbJMAj9n6YA=
github.com/Masterminds/sprig/v3 v3.2.3/go.mod h1:rXcFaZ2zZbLRJv/xSysmlgIM1u11eBaRMhvYXJNkGuM=
github.com/SovereignCloudStack/cluster-stack-operator v0.1.0-alpha.2 h1:23sNJB4z0wiguCeG0W+GdusBrRNYGcKsUYLZo01wZNs=
github.com/SovereignCloudStack/cluster-stack-operator v0.1.0-alpha.2/go.mod h1:qXyqN2aZ+JCtVIVMNdr736b+3XNmaOhsXjGZuMUUUp0=
github.com/antlr/antlr4/runtime/Go/antlr/v4 v4.0.0-20230305170008-8188dc5388df h1:7RFfzj4SSt6nnvCPbCqijJi1nWCd+TqAT3bYCStRC18=
github.com/antlr/antlr4/runtime/Go/antlr/v4 v4.0.0-20230305170008-8188dc5388df/go.mod h1:pSwJ0fSY5KhvocuWSx4fz3BA8OrA1bQn+K1Eli3BRwM=
github.com/asaskevich/govalidator v0.0.0-20190424111038-f61b66f89f4a h1:idn718Q4B6AGu/h5Sxe66HYVdqdGu2l9Iebqhi/AEoA=
Expand Down Expand Up @@ -115,8 +113,8 @@ github.com/modern-go/reflect2 v1.0.2 h1:xBagoLtFs94CBntxluKeaWgTMpvLxC4ur3nMaC9G
github.com/modern-go/reflect2 v1.0.2/go.mod h1:yWuevngMOJpCy52FWWMvUC8ws7m/LJsjYzDa0/r8luk=
github.com/munnerz/goautoneg v0.0.0-20191010083416-a7dc8b61c822 h1:C3w9PqII01/Oq1c1nUAm88MOHcQC9l5mIlSMApZMrHA=
github.com/munnerz/goautoneg v0.0.0-20191010083416-a7dc8b61c822/go.mod h1:+n7T8mK8HuQTcFwEeznm/DIxMOiR9yIdICNftLE1DvQ=
github.com/onsi/ginkgo/v2 v2.13.2 h1:Bi2gGVkfn6gQcjNjZJVO8Gf0FHzMPf2phUei9tejVMs=
github.com/onsi/ginkgo/v2 v2.13.2/go.mod h1:XStQ8QcGwLyF4HdfcZB8SFOS/MWCgDuXMSBe6zrvLgM=
github.com/onsi/ginkgo/v2 v2.13.1 h1:LNGfMbR2OVGBfXjvRZIZ2YCTQdGKtPLvuI1rMCCj3OU=
github.com/onsi/ginkgo/v2 v2.13.1/go.mod h1:XStQ8QcGwLyF4HdfcZB8SFOS/MWCgDuXMSBe6zrvLgM=
github.com/onsi/gomega v1.30.0 h1:hvMK7xYz4D3HapigLTeGdId/NcfQx1VHMJc60ew99+8=
github.com/onsi/gomega v1.30.0/go.mod h1:9sxs+SwGrKI0+PWe4Fxa9tFQQBG5xSsSbMXOI8PPpoQ=
github.com/opencontainers/go-digest v1.0.0 h1:apOUWs51W5PlhuyGyz9FCeeBIOUDA/6nW8Oi/yOhh5U=
Expand Down Expand Up @@ -162,8 +160,8 @@ github.com/yuin/goldmark v1.2.1/go.mod h1:3hX8gzYuyVAZsxl0MRgGTJEmQBFcNTphYh9dec
github.com/yuin/goldmark v1.3.5/go.mod h1:mwnBkeHKe2W/ZEtQ+71ViKU8L12m81fl3OWwC1Zlc8k=
go.uber.org/atomic v1.7.0/go.mod h1:fEN4uk6kAWBTFdckzkM89CLk9XfWZrxpCo0nPH17wJc=
go.uber.org/goleak v1.1.11/go.mod h1:cwTWslyiVhfpKIDGSZEM2HlOvcqm+tG4zioyIeLoqMQ=
go.uber.org/goleak v1.3.0 h1:2K3zAYmnTNqV73imy9J1T3WC+gmCePx2hEGkimedGto=
go.uber.org/goleak v1.3.0/go.mod h1:CoHD4mav9JJNrW/WLlf7HGZPjdw8EucARQHekz1X6bE=
go.uber.org/goleak v1.2.1 h1:NBol2c7O1ZokfZ0LEU9K6Whx/KnwvepVetCUhtKja4A=
go.uber.org/goleak v1.2.1/go.mod h1:qlT2yGI9QafXHhZZLxlSuNsMw3FFLxBr+tBRlmO1xH4=
go.uber.org/multierr v1.6.0/go.mod h1:cdWPpRnG4AhwMwsgIHip0KRBQjJy5kYEpYjJxpXp9iU=
go.uber.org/multierr v1.11.0 h1:blXXJkSxSSfBVBlC76pxqeO+LN3aDfLQo+309xJstO0=
go.uber.org/multierr v1.11.0/go.mod h1:20+QtiLqy0Nd6FdQB9TLXag12DsQkrbs3htMFfDN80Y=
Expand Down
6 changes: 5 additions & 1 deletion extension/handlers/hooks.go
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ import (
"fmt"

csov1alpha1 "github.com/SovereignCloudStack/cluster-stack-operator/api/v1alpha1"
"k8s.io/apimachinery/pkg/runtime"
"k8s.io/apimachinery/pkg/types"
runtimehooksv1 "sigs.k8s.io/cluster-api/exp/runtime/hooks/api/v1alpha1"
"sigs.k8s.io/cluster-api/util/conditions"
Expand All @@ -33,7 +34,7 @@ type ExtensionHandler struct {
client client.Client
}

func NewExtensionHandlers(client client.Client) *ExtensionHandler {
func NewExtensionHandlers(client client.Client, scheme *runtime.Scheme) *ExtensionHandler {
return &ExtensionHandler{
client: client,
}
Expand Down Expand Up @@ -92,6 +93,7 @@ func (e *ExtensionHandler) DoAfterControlPlaneInitialized(ctx context.Context, r
key := types.NamespacedName{Name: fmt.Sprintf("cluster-addon-%s", request.Cluster.GetName()), Namespace: request.Cluster.GetNamespace()}
clusterAddon := &csov1alpha1.ClusterAddon{}
if err := e.client.Get(ctx, key, clusterAddon); err != nil {
log.Error(err, "failed to get the cluster addon")
response.SetStatus(runtimehooksv1.ResponseStatusFailure)
response.SetMessage(err.Error())
return
Expand All @@ -110,6 +112,8 @@ func (e *ExtensionHandler) DoAfterControlPlaneInitialized(ctx context.Context, r
}
}()

clusterAddon.Spec.Hook = "AfterControlPlaneInitialized"

response.SetStatus(runtimehooksv1.ResponseStatusSuccess)
return
}
4 changes: 2 additions & 2 deletions extension/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -140,14 +140,14 @@ func main() {
}
restConfig.UserAgent = remote.DefaultClusterAPIUserAgent(controllerName)

client, err := client.New(restConfig, client.Options{})
client, err := client.New(restConfig, client.Options{Scheme: scheme})
if err != nil {
setupLog.Error(err, "error creating client to the cluster")
os.Exit(1)
}

// Create the ExtensionHandlers for the lifecycle hooks
lifecycleExtensionHandlers := handlers.NewExtensionHandlers(client)
lifecycleExtensionHandlers := handlers.NewExtensionHandlers(client, scheme)

if err := webhookServer.AddExtensionHandler(server.ExtensionHandler{
Hook: runtimehooksv1.BeforeClusterUpgrade,
Expand Down

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 0 additions & 2 deletions extension/vendor/modules.txt
Original file line number Diff line number Diff line change
Expand Up @@ -142,8 +142,6 @@ github.com/prometheus/common/model
github.com/prometheus/procfs
github.com/prometheus/procfs/internal/fs
github.com/prometheus/procfs/internal/util
# github.com/sovereigncloudstack/cluster-stack-operator v0.0.0-00010101000000-000000000000
## explicit
# github.com/spf13/cobra v1.8.0
## explicit; go 1.15
github.com/spf13/cobra
Expand Down

0 comments on commit 2d38d31

Please sign in to comment.