Skip to content

Commit 4e16800

Browse files
authored
fix: Enforce HookOnlyStrategy for Helm upgrades (#18)
This commit modifies the Helm upgrade logic in the Go shim to explicitly use the `HookOnlyStrategy` when waiting for operations to complete. This ensures that upgrades only wait for pre/post-upgrade hooks to finish, rather than blocking until all resources in the release are fully ready, which helps prevent timeouts on complex stateful workloads. * **Upgrade Strategy**: The `helm_sdkpy_upgrade` function now sets `client.WaitStrategy = kube.HookOnlyStrategy`. * **Formatting**: Applied minor whitespace and formatting fixes throughout `go/shim/main.go` to align variable declarations and comments.
1 parent a3f7dad commit 4e16800

File tree

2 files changed

+18
-15
lines changed

2 files changed

+18
-15
lines changed

go/shim/main.go

Lines changed: 17 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -134,7 +134,7 @@ func helm_sdkpy_config_create(namespace *C.char, kubeconfig *C.char, kubecontext
134134
if err != nil {
135135
return setError(fmt.Errorf("failed to initialize helm config: %w", err))
136136
}
137-
137+
138138
// Configure the Kubernetes client to use Ignore field validation
139139
// This allows charts with managedFields in templates (like rook-ceph v1.18.x)
140140
// to install successfully without strict Kubernetes API validation errors
@@ -202,20 +202,20 @@ func helm_sdkpy_install(handle C.helm_sdkpy_handle, release_name *C.char, chart_
202202
client.ReleaseName = releaseName
203203
client.Namespace = state.envs.Namespace()
204204
client.CreateNamespace = create_namespace != 0
205-
205+
206206
// Use client-side apply instead of server-side to avoid strict field validation
207207
// Server-side apply (default in Helm v4) enforces strict field validation which
208208
// rejects charts with managedFields in templates (like rook-ceph v1.18.x)
209209
client.ServerSideApply = false
210-
210+
211211
// Disable OpenAPI validation as well
212212
client.DisableOpenAPIValidation = true
213-
213+
214214
// Set version if provided
215215
if chartVersion != "" {
216216
client.Version = chartVersion
217217
}
218-
218+
219219
// Configure wait behavior
220220
if wait != 0 {
221221
client.WaitStrategy = kube.StatusWatcherStrategy // Use the status watcher strategy
@@ -284,7 +284,10 @@ func helm_sdkpy_upgrade(handle C.helm_sdkpy_handle, release_name *C.char, chart_
284284
// Create upgrade action
285285
client := action.NewUpgrade(state.cfg)
286286
client.Namespace = state.envs.Namespace()
287-
287+
288+
// Set wait strategy
289+
client.WaitStrategy = kube.HookOnlyStrategy
290+
288291
// Set version if provided
289292
if chartVersion != "" {
290293
client.Version = chartVersion
@@ -342,7 +345,7 @@ func helm_sdkpy_uninstall(handle C.helm_sdkpy_handle, release_name *C.char, wait
342345

343346
// Create uninstall action
344347
client := action.NewUninstall(state.cfg)
345-
348+
346349
// Configure wait behavior
347350
if wait != 0 {
348351
client.WaitStrategy = kube.StatusWatcherStrategy // Use the status watcher strategy
@@ -996,11 +999,11 @@ func helm_sdkpy_registry_login(handle C.helm_sdkpy_handle, hostname *C.char, use
996999

9971000
// Parse options
9981001
var options struct {
999-
CertFile string `json:"cert_file"`
1000-
KeyFile string `json:"key_file"`
1001-
CAFile string `json:"ca_file"`
1002-
Insecure bool `json:"insecure"`
1003-
PlainHTTP bool `json:"plain_http"`
1002+
CertFile string `json:"cert_file"`
1003+
KeyFile string `json:"key_file"`
1004+
CAFile string `json:"ca_file"`
1005+
Insecure bool `json:"insecure"`
1006+
PlainHTTP bool `json:"plain_http"`
10041007
}
10051008

10061009
optionsStr := C.GoString(options_json)
@@ -1015,7 +1018,7 @@ func helm_sdkpy_registry_login(handle C.helm_sdkpy_handle, hostname *C.char, use
10151018

10161019
// Build options slice
10171020
var loginOpts []action.RegistryLoginOpt
1018-
1021+
10191022
if options.CertFile != "" {
10201023
loginOpts = append(loginOpts, action.WithCertFile(options.CertFile))
10211024
}
@@ -1101,7 +1104,7 @@ func helm_sdkpy_push(handle C.helm_sdkpy_handle, chart_ref *C.char, remote *C.ch
11011104
// Create push action
11021105
var pushOpts []action.PushOpt
11031106
pushOpts = append(pushOpts, action.WithPushConfig(state.cfg))
1104-
1107+
11051108
if options.CertFile != "" || options.KeyFile != "" || options.CAFile != "" {
11061109
pushOpts = append(pushOpts, action.WithTLSClientConfig(options.CertFile, options.KeyFile, options.CAFile))
11071110
}

pyproject.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
[project]
22
name = "helm-sdkpy"
3-
version = "0.0.12"
3+
version = "0.0.13"
44
description = "Python bindings for Helm - The Kubernetes Package Manager"
55
readme = "README.md"
66
requires-python = ">=3.12"

0 commit comments

Comments
 (0)