Skip to content

Commit b4c226a

Browse files
authored
feat: Add --min-sigterm-delay property to the workload configuration (#639)
The auth proxy added the flag --min-sigterm-delay in GoogleCloudPlatform/cloud-sql-proxy#2266. This adds a matching configuration property to the operator's CRD. Fixes #627
1 parent 19d8043 commit b4c226a

File tree

4 files changed

+14
-0
lines changed

4 files changed

+14
-0
lines changed

docs/api.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -55,6 +55,7 @@ _Appears in:_
5555
| `authentication` _[AuthenticationSpec](#authenticationspec)_ | Authentication specifies the config for how the proxy authenticates itself<br />to the Google Cloud API. | | |
5656
| `maxConnections` _integer_ | MaxConnections limits the number of connections. Default value is no limit.<br />This sets the proxy container's CLI argument `--max-connections` | | Minimum: 0 <br />Optional: {} <br /> |
5757
| `maxSigtermDelay` _integer_ | MaxSigtermDelay is the maximum number of seconds to wait for connections to<br />close after receiving a TERM signal. This sets the proxy container's<br />CLI argument `--max-sigterm-delay` and<br />configures `terminationGracePeriodSeconds` on the workload's PodSpec. | | Minimum: 0 <br />Optional: {} <br /> |
58+
| `minSigtermDelay` _integer_ | MinSigtermDelay is the minimum number of seconds to wait for connections to<br />close after receiving a TERM signal. This sets the proxy container's<br />CLI argument `--min-sigterm-delay` | | Minimum: 0 <br />Optional: {} <br /> |
5859
| `sqlAdminAPIEndpoint` _string_ | SQLAdminAPIEndpoint is a debugging parameter that when specified will<br />change the Google Cloud api endpoint used by the proxy. | | Optional: {} <br /> |
5960
| `image` _string_ | Image is the URL to the proxy image. Optional, by default the operator<br />will use the latest Cloud SQL Auth Proxy version as of the release of the<br />operator.<br /><br />The operator ensures that all workloads configured with the default proxy<br />image are upgraded automatically to use to the latest released proxy image.<br /><br />When the customer upgrades the operator, the operator upgrades all<br />workloads using the default proxy image to the latest proxy image. The<br />change to the proxy container image is applied in accordance with<br />the RolloutStrategy. | | Optional: {} <br /> |
6061
| `rolloutStrategy` _string_ | RolloutStrategy indicates the strategy to use when rolling out changes to<br />the workloads affected by the results. When this is set to<br />`Workload`, changes to this resource will be automatically applied<br />to a running Deployment, StatefulSet, DaemonSet, or ReplicaSet in<br />accordance with the Strategy set on that workload. When this is set to<br />`None`, the operator will take no action to roll out changes to affected<br />workloads. `Workload` will be used by default if no value is set.<br />See: https://kubernetes.io/docs/concepts/workloads/controllers/deployment/#strategy | Workload | Enum: [Workload None] <br />Optional: {} <br /> |

internal/api/v1/authproxyworkload_types.go

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -181,6 +181,13 @@ type AuthProxyContainerSpec struct {
181181
//+kubebuilder:validation:Minimum=0
182182
MaxSigtermDelay *int64 `json:"maxSigtermDelay,omitempty"`
183183

184+
// MinSigtermDelay is the minimum number of seconds to wait for connections to
185+
// close after receiving a TERM signal. This sets the proxy container's
186+
// CLI argument `--min-sigterm-delay`
187+
//+kubebuilder:validation:Optional
188+
//+kubebuilder:validation:Minimum=0
189+
MinSigtermDelay *int64 `json:"minSigtermDelay,omitempty"`
190+
184191
// SQLAdminAPIEndpoint is a debugging parameter that when specified will
185192
// change the Google Cloud api endpoint used by the proxy.
186193
//+kubebuilder:validation:Optional

internal/workload/podspec_updates.go

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -759,6 +759,10 @@ func (s *updateState) applyContainerSpec(p *cloudsqlapi.AuthProxyWorkload, c *co
759759
*p.Spec.AuthProxyContainer.MaxSigtermDelay != 0 {
760760
s.addProxyContainerEnvVar(p, "CSQL_PROXY_MAX_SIGTERM_DELAY", fmt.Sprintf("%ds", *p.Spec.AuthProxyContainer.MaxSigtermDelay))
761761
}
762+
if p.Spec.AuthProxyContainer.MinSigtermDelay != nil &&
763+
*p.Spec.AuthProxyContainer.MinSigtermDelay != 0 {
764+
s.addProxyContainerEnvVar(p, "CSQL_PROXY_MIN_SIGTERM_DELAY", fmt.Sprintf("%ds", *p.Spec.AuthProxyContainer.MinSigtermDelay))
765+
}
762766

763767
return
764768
}

internal/workload/podspec_updates_test.go

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -669,6 +669,7 @@ func TestProxyCLIArgs(t *testing.T) {
669669
},
670670
MaxConnections: ptr(int64(10)),
671671
MaxSigtermDelay: ptr(int64(20)),
672+
MinSigtermDelay: ptr(int64(15)),
672673
Quiet: true,
673674
RefreshStrategy: "lazy",
674675
},
@@ -697,6 +698,7 @@ func TestProxyCLIArgs(t *testing.T) {
697698
"CSQL_PROXY_QUOTA_PROJECT": "qp",
698699
"CSQL_PROXY_MAX_CONNECTIONS": "10",
699700
"CSQL_PROXY_MAX_SIGTERM_DELAY": "20s",
701+
"CSQL_PROXY_MIN_SIGTERM_DELAY": "15s",
700702
"CSQL_PROXY_IMPERSONATE_SERVICE_ACCOUNT": "[email protected],[email protected]",
701703
"CSQL_PROXY_QUIET": "true",
702704
"CSQL_PROXY_STRUCTURED_LOGS": "true",

0 commit comments

Comments
 (0)