diff --git a/docs/api-references/docs.md b/docs/api-references/docs.md
index 859f90417cc..9ade2871b7e 100644
--- a/docs/api-references/docs.md
+++ b/docs/api-references/docs.md
@@ -14251,7 +14251,7 @@ Only valid in Prometheus versions 2.15.0 and newer.
remoteTimeout
-github.com/prometheus/common/model.Duration
+string
|
diff --git a/manifests/crd.yaml b/manifests/crd.yaml
index 64f5f85d879..dbead2f6775 100644
--- a/manifests/crd.yaml
+++ b/manifests/crd.yaml
@@ -51296,8 +51296,8 @@ spec:
type: integer
type: object
remoteTimeout:
- format: int64
- type: integer
+ pattern: ^\d+[smhd]$
+ type: string
tlsConfig:
properties:
ca:
diff --git a/manifests/crd/v1/pingcap.com_tidbmonitors.yaml b/manifests/crd/v1/pingcap.com_tidbmonitors.yaml
index 14dfb2d2984..c72da8fb733 100644
--- a/manifests/crd/v1/pingcap.com_tidbmonitors.yaml
+++ b/manifests/crd/v1/pingcap.com_tidbmonitors.yaml
@@ -1891,8 +1891,8 @@ spec:
type: integer
type: object
remoteTimeout:
- format: int64
- type: integer
+ pattern: ^\d+[smhd]$
+ type: string
tlsConfig:
properties:
ca:
diff --git a/pkg/apis/pingcap/v1alpha1/openapi_generated.go b/pkg/apis/pingcap/v1alpha1/openapi_generated.go
index f94ca25df16..9b7d3e28c47 100644
--- a/pkg/apis/pingcap/v1alpha1/openapi_generated.go
+++ b/pkg/apis/pingcap/v1alpha1/openapi_generated.go
@@ -7977,8 +7977,8 @@ func schema_pkg_apis_pingcap_v1alpha1_RemoteWriteSpec(ref common.ReferenceCallba
},
"remoteTimeout": {
SchemaProps: spec.SchemaProps{
- Type: []string{"integer"},
- Format: "int64",
+ Type: []string{"string"},
+ Format: "",
},
},
"writeRelabelConfigs": {
diff --git a/pkg/apis/pingcap/v1alpha1/tidbmonitor_types.go b/pkg/apis/pingcap/v1alpha1/tidbmonitor_types.go
index 665d1833aba..95b4c719167 100644
--- a/pkg/apis/pingcap/v1alpha1/tidbmonitor_types.go
+++ b/pkg/apis/pingcap/v1alpha1/tidbmonitor_types.go
@@ -445,8 +445,9 @@ type RemoteWriteSpec struct {
// Only valid in Prometheus versions 2.15.0 and newer.
// +optional
Name string `json:"name,omitempty"`
+ // +kubebuilder:validation:Pattern=`^\d+[smhd]$`
// +optional
- RemoteTimeout *model.Duration `json:"remoteTimeout,omitempty"`
+ RemoteTimeout string `json:"remoteTimeout,omitempty"`
// The list of remote write relabel configurations.
// +optional
WriteRelabelConfigs []RelabelConfig `json:"writeRelabelConfigs,omitempty"`
diff --git a/pkg/apis/pingcap/v1alpha1/zz_generated.deepcopy.go b/pkg/apis/pingcap/v1alpha1/zz_generated.deepcopy.go
index 877baa02247..7cd8c5d5ef7 100644
--- a/pkg/apis/pingcap/v1alpha1/zz_generated.deepcopy.go
+++ b/pkg/apis/pingcap/v1alpha1/zz_generated.deepcopy.go
@@ -4825,11 +4825,6 @@ func (in *ReloaderSpec) DeepCopy() *ReloaderSpec {
// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil.
func (in *RemoteWriteSpec) DeepCopyInto(out *RemoteWriteSpec) {
*out = *in
- if in.RemoteTimeout != nil {
- in, out := &in.RemoteTimeout, &out.RemoteTimeout
- *out = new(model.Duration)
- **out = **in
- }
if in.WriteRelabelConfigs != nil {
in, out := &in.WriteRelabelConfigs, &out.WriteRelabelConfigs
*out = make([]RelabelConfig, len(*in))
diff --git a/pkg/monitor/monitor/monitor_manager_test.go b/pkg/monitor/monitor/monitor_manager_test.go
index e98038acd78..cf7256e6eb2 100644
--- a/pkg/monitor/monitor/monitor_manager_test.go
+++ b/pkg/monitor/monitor/monitor_manager_test.go
@@ -141,13 +141,13 @@ func TestTidbMonitorSyncCreate(t *testing.T) {
g.Expect(err).NotTo(HaveOccurred())
url := "http://127.0.0.1/a/b/c"
- remoteTimeout := model.Duration(30 * time.Second)
+ remoteTimeout := "30s"
testTime := 10 * time.Second
monitor.Spec.Prometheus.RemoteWrite = []*v1alpha1.RemoteWriteSpec{
{
URL: url,
Name: "test",
- RemoteTimeout: &remoteTimeout,
+ RemoteTimeout: remoteTimeout,
WriteRelabelConfigs: []v1alpha1.RelabelConfig{
{
SourceLabels: []model.LabelName{"test1", "test2"},
diff --git a/pkg/monitor/monitor/util.go b/pkg/monitor/monitor/util.go
index f06558d5e0f..47a376f1862 100644
--- a/pkg/monitor/monitor/util.go
+++ b/pkg/monitor/monitor/util.go
@@ -19,7 +19,6 @@ import (
"sort"
"strconv"
"strings"
- "time"
semver "github.com/Masterminds/semver"
"github.com/pingcap/tidb-operator/pkg/apis/label"
@@ -1487,9 +1486,8 @@ func generateRemoteWrite(monitor *v1alpha1.TidbMonitor, store *Store) (yaml.MapI
}
for i, spec := range monitor.Spec.Prometheus.RemoteWrite {
//defaults
- if spec.RemoteTimeout == nil {
- duration := model.Duration(30 * time.Second)
- spec.RemoteTimeout = &duration
+ if spec.RemoteTimeout == "" {
+ spec.RemoteTimeout = "30s"
}
cfg := yaml.MapSlice{
diff --git a/pkg/monitor/monitor/util_test.go b/pkg/monitor/monitor/util_test.go
index f4c63c25d51..8ffc96e9a5e 100644
--- a/pkg/monitor/monitor/util_test.go
+++ b/pkg/monitor/monitor/util_test.go
@@ -56,7 +56,7 @@ func TestGenerateRemoteWrite(t *testing.T) {
max_backoff: 10s
`
url := "http://127.0.0.1/a/b/c"
- remoteTimeout := model.Duration(30 * time.Second)
+ remoteTimeout := "30s"
testTime := 10 * time.Second
monitor := v1alpha1.TidbMonitor{
Spec: v1alpha1.TidbMonitorSpec{
@@ -65,7 +65,7 @@ func TestGenerateRemoteWrite(t *testing.T) {
{
URL: url,
Name: "test",
- RemoteTimeout: &remoteTimeout,
+ RemoteTimeout: remoteTimeout,
WriteRelabelConfigs: []v1alpha1.RelabelConfig{
{
SourceLabels: []model.LabelName{"test1", "test2"},
@@ -161,7 +161,7 @@ func TestGenerateRemoteWriteWithHighVersion(t *testing.T) {
send_interval: 10s
`
url := "http://127.0.0.1/a/b/c"
- remoteTimeout := model.Duration(30 * time.Second)
+ remoteTimeout := "30s"
testTime := 10 * time.Second
monitor := v1alpha1.TidbMonitor{
Spec: v1alpha1.TidbMonitorSpec{
@@ -170,7 +170,7 @@ func TestGenerateRemoteWriteWithHighVersion(t *testing.T) {
{
URL: url,
Name: "test",
- RemoteTimeout: &remoteTimeout,
+ RemoteTimeout: remoteTimeout,
WriteRelabelConfigs: []v1alpha1.RelabelConfig{
{
SourceLabels: []model.LabelName{"test1", "test2"},
|