Skip to content

Commit

Permalink
Merge pull request #25 from kloeckner-i/METAL-1890/fix
Browse files Browse the repository at this point in the history
METAL-1890/fix
  • Loading branch information
hyunysmile authored Jun 9, 2020
2 parents 8031dec + ea72039 commit f5a04a8
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 2 deletions.
2 changes: 1 addition & 1 deletion pkg/apis/kci/v1alpha1/dbinstance_types.go
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@ type PerconaCluster struct {
type BackendServer struct {
Host string `json:"host"`
Port uint16 `json:"port"`
MaxConnection uint8 `json:"maxConn"`
MaxConnection uint16 `json:"maxConn"`
ReadOnly bool `json:"readonly,omitempty"`
}

Expand Down
7 changes: 6 additions & 1 deletion pkg/utils/proxy/cloudproxy.go
Original file line number Diff line number Diff line change
Expand Up @@ -89,6 +89,8 @@ func (cp *CloudProxy) deploymentSpec() (v1apps.DeploymentSpec, error) {
},
}

terminationGracePeriodSeconds := int64(120) // force kill pod after this time

return v1apps.DeploymentSpec{
Replicas: &replicas,
Selector: &metav1.LabelSelector{
Expand All @@ -106,6 +108,7 @@ func (cp *CloudProxy) deploymentSpec() (v1apps.DeploymentSpec, error) {
Affinity: &v1.Affinity{
PodAntiAffinity: podAntiAffinity(cp.Labels),
},
TerminationGracePeriodSeconds: &terminationGracePeriodSeconds,
},
},
}, nil
Expand All @@ -115,12 +118,14 @@ func (cp *CloudProxy) container() (v1.Container, error) {
RunAsUser := int64(2)
AllowPrivilegeEscalation := false
instanceArg := fmt.Sprintf("-instances=%s=tcp:0.0.0.0:%s", cp.InstanceConnectionName, strconv.FormatInt(int64(cp.Port), 10))
timeoutSecond := 60 // wait given seconds after SIGTERM
timeoutArg := fmt.Sprintf("-term_timeout=%ss", strconv.FormatInt(int64(timeoutSecond), 10))

return v1.Container{
Name: "cloudsql-proxy",
Image: conf.Instances.Google.ProxyConfig.Image,
Command: []string{"/cloud_sql_proxy"},
Args: []string{instanceArg, "-credential_file=/srv/gcloud/credentials.json"},
Args: []string{instanceArg, "-credential_file=/srv/gcloud/credentials.json", timeoutArg},
SecurityContext: &v1.SecurityContext{
RunAsUser: &RunAsUser,
AllowPrivilegeEscalation: &AllowPrivilegeEscalation,
Expand Down

0 comments on commit f5a04a8

Please sign in to comment.