Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 4 additions & 2 deletions WORKSPACE
Original file line number Diff line number Diff line change
Expand Up @@ -57,12 +57,14 @@ load("@bazel_gazelle//:deps.bzl", "gazelle_dependencies")

go_rules_dependencies()

# gazelle:repository_macro hack/build/repos.bzl%_go_dependencies
go_dependencies()

go_register_toolchains(version = "1.17")

gazelle_dependencies()

# gazelle:repository_macro hack/build/repos.bzl%_go_dependencies
go_dependencies()


################################
# begin rules_oci dependencies #
Expand Down
5 changes: 5 additions & 0 deletions apis/v1alpha1/cluster_types.go
Original file line number Diff line number Diff line change
Expand Up @@ -145,6 +145,11 @@ type CrdbClusterSpec struct {
// Default: false
// +optional
AutomountServiceAccountToken bool `json:"automountServiceAccountToken,omitempty"`
// (Optional) The grace period in seconds prior to the container being forcibly terminated
// when marked for deletion or restarted.
// Default : 300
// +optional
TerminationGracePeriodSecs int64 `json:"terminationGracePeriodSecs,omitempty"`
}

// +k8s:openapi-gen=true
Expand Down
6 changes: 6 additions & 0 deletions config/crd/bases/crdb.cockroachlabs.com_crdbclusters.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -1393,6 +1393,12 @@ spec:
description: '(Optional) The SQL Port number Default: 26257'
format: int32
type: integer
terminationGracePeriodSecs:
description: '(Optional) The grace period in seconds prior to the
container being forcibly terminated when marked for deletion or
restarted. Default : 300'
format: int64
type: integer
tlsEnabled:
description: (Optional) TLSEnabled determines if TLS is enabled for
your CockroachDB Cluster
Expand Down
1 change: 1 addition & 0 deletions e2e/upgrades/upgrades_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -221,6 +221,7 @@ func TestUpgradesMinorVersionThenRollback(t *testing.T) {

builder := testutil.NewBuilder("crdb").
WithAutomountServiceAccountToken(true).
WithTerminationGracePeriodSeconds(5).
WithNodeCount(3).
WithTLS().
WithImage(e2e.MinorVersion1).
Expand Down
2 changes: 1 addition & 1 deletion hack/dev.sh
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ APP_VERSION="${APP_VERSION:-v$(cat version.txt)}"
CLUSTER_NAME="dev"
NODE_IMAGE="rancher/k3s:v1.23.3-k3s1"
REGISTRY_NAME="registry.localhost"
REGISTRY_PORT=5000
REGISTRY_PORT=5002
DEV_REGISTRY="${REGISTRY_NAME}:${REGISTRY_PORT}"

main() {
Expand Down
6 changes: 6 additions & 0 deletions install/crds.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -1391,6 +1391,12 @@ spec:
description: '(Optional) The SQL Port number Default: 26257'
format: int32
type: integer
terminationGracePeriodSecs:
description: '(Optional) The grace period in seconds prior to the
container being forcibly terminated when marked for deletion or
restarted. Default : 300'
format: int64
type: integer
tlsEnabled:
description: (Optional) TLSEnabled determines if TLS is enabled for
your CockroachDB Cluster
Expand Down
7 changes: 7 additions & 0 deletions pkg/resource/cluster.go
Original file line number Diff line number Diff line change
Expand Up @@ -330,6 +330,13 @@ func (cluster Cluster) SecureMode() string {
return "--insecure"
}

func (cluster Cluster) GetTerminationGracePeriod() int64 {
if cluster.Spec().TerminationGracePeriodSecs == 0 {
return terminationGracePeriodSecs
}
return cluster.Spec().TerminationGracePeriodSecs
}

func (cluster Cluster) LoggingConfiguration(fetcher Fetcher) (string, error) {
if cluster.Spec().LogConfigMap != "" {
cm := &corev1.ConfigMap{
Expand Down
2 changes: 1 addition & 1 deletion pkg/resource/statefulset.go
Original file line number Diff line number Diff line change
Expand Up @@ -209,7 +209,7 @@ func (b StatefulSetBuilder) makePodTemplate() corev1.PodTemplateSpec {
RunAsUser: ptr.Int64(1000581000),
FSGroup: ptr.Int64(1000581000),
},
TerminationGracePeriodSeconds: ptr.Int64(terminationGracePeriodSecs),
TerminationGracePeriodSeconds: ptr.Int64(b.GetTerminationGracePeriod()),
Containers: b.MakeContainers(),
AutomountServiceAccountToken: ptr.Bool(b.Spec().AutomountServiceAccountToken),
ServiceAccountName: b.ServiceAccountName(),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@ spec:
car: koenigsegg
spec:
automountServiceAccountToken: true
terminationGracePeriodSecs: 300
containers:
- command:
- /bin/bash
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ metadata:
namespace: test-ns
spec:
automountServiceAccountToken: true
terminationGracePeriodSecs: 300
dataStore:
pvc:
spec:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@ spec:
app.kubernetes.io/name: cockroachdb
spec:
automountServiceAccountToken: false
terminationGracePeriodSecs: 300
containers:
- command:
- /bin/bash
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ metadata:
name: test-cluster
namespace: test-ns
spec:
terminationGracePeriodSecs: 300
dataStore:
pvc:
spec:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@ spec:
car: koenigsegg
spec:
automountServiceAccountToken: false
terminationGracePeriodSecs: 300
containers:
- command:
- /bin/bash
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ metadata:
name: test-cluster
namespace: test-ns
spec:
terminationGracePeriodSecs: 300
dataStore:
pvc:
spec:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,7 @@ spec:
topologyKey: kubernetes.io/hostname
weight: 100
automountServiceAccountToken: false
terminationGracePeriodSecs: 300
containers:
- command:
- /bin/bash
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -58,4 +58,5 @@ spec:
effect: "NoSchedule"
additionalAnnotations:
key: "test-value"
terminationGracePeriodSecs: 300
status: {}
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,7 @@ spec:
topologyKey: kubernetes.io/hostname
weight: 100
automountServiceAccountToken: false
terminationGracePeriodSecs: 300
containers:
- command:
- /bin/bash
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -58,4 +58,5 @@ spec:
effect: "NoSchedule"
additionalAnnotations:
key: "test-value"
terminationGracePeriodSecs: 300
status: {}
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@ spec:
app.kubernetes.io/name: cockroachdb
spec:
automountServiceAccountToken: false
terminationGracePeriodSecs: 300
containers:
- command:
- /bin/bash
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -41,4 +41,5 @@ spec:
topology:
zones:
- locality: ""
terminationGracePeriodSecs: 300
status: {}
5 changes: 5 additions & 0 deletions pkg/testutil/builder.go
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,11 @@ func (b ClusterBuilder) WithAutomountServiceAccountToken(mount bool) ClusterBuil
return b
}

func (b ClusterBuilder) WithTerminationGracePeriodSeconds(s int64) ClusterBuilder {
b.cluster.Spec.TerminationGracePeriodSecs = s
return b
}

func (b ClusterBuilder) WithUID(uid string) ClusterBuilder {
b.cluster.ObjectMeta.UID = amtypes.UID(uid)
return b
Expand Down