Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

pdms: support pv for log #5535

Merged
merged 1 commit into from
Feb 4, 2024
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
46 changes: 44 additions & 2 deletions docs/api-references/docs.md
Original file line number Diff line number Diff line change
Expand Up @@ -10827,7 +10827,7 @@ ServiceSpec
</td>
<td>
<em>(Optional)</em>
<p>Service defines a Kubernetes service of PD cluster.
<p>Service defines a Kubernetes service of PD Micro Service cluster.
Optional: Defaults to <code>.spec.services</code> in favor of backward compatibility</p>
</td>
</tr>
Expand Down Expand Up @@ -10855,7 +10855,7 @@ PDConfigWraper
</td>
<td>
<em>(Optional)</em>
<p>Config is the Configuration of pd-servers</p>
<p>Config is the Configuration of pd Micro Service servers</p>
</td>
</tr>
<tr>
Expand Down Expand Up @@ -10897,6 +10897,33 @@ string
</tr>
<tr>
<td>
<code>storageClassName</code></br>
<em>
string
</em>
</td>
<td>
<em>(Optional)</em>
<p>The storageClassName of the persistent volume for PD Micro Service log storage.
Defaults to Kubernetes default storage class.</p>
</td>
</tr>
<tr>
<td>
<code>storageVolumes</code></br>
<em>
<a href="#storagevolume">
[]StorageVolume
</a>
</em>
</td>
<td>
<em>(Optional)</em>
<p>StorageVolumes configure additional storage for PD Micro Service pods.</p>
</td>
</tr>
<tr>
<td>
<code>startTimeout</code></br>
<em>
int
Expand Down Expand Up @@ -10971,6 +10998,19 @@ Kubernetes apps/v1.StatefulSetStatus
</tr>
<tr>
<td>
<code>volumes</code></br>
<em>
<a href="#storagevolumestatus">
map[github.com/pingcap/tidb-operator/pkg/apis/pingcap/v1alpha1.StorageVolumeName]*github.com/pingcap/tidb-operator/pkg/apis/pingcap/v1alpha1.StorageVolumeStatus
</a>
</em>
</td>
<td>
<p>Volumes contains the status of all volumes.</p>
</td>
</tr>
<tr>
<td>
<code>members</code></br>
<em>
[]string
Expand Down Expand Up @@ -15604,6 +15644,7 @@ LocalStorageProvider
<p>
(<em>Appears on:</em>
<a href="#ngmonitoringspec">NGMonitoringSpec</a>,
<a href="#pdmsspec">PDMSSpec</a>,
<a href="#pdspec">PDSpec</a>,
<a href="#ticdcspec">TiCDCSpec</a>,
<a href="#tidbspec">TiDBSpec</a>,
Expand Down Expand Up @@ -15680,6 +15721,7 @@ string
<p>
(<em>Appears on:</em>
<a href="#masterstatus">MasterStatus</a>,
<a href="#pdmsstatus">PDMSStatus</a>,
<a href="#pdstatus">PDStatus</a>,
<a href="#pumpstatus">PumpStatus</a>,
<a href="#ticdcstatus">TiCDCStatus</a>,
Expand Down
2 changes: 0 additions & 2 deletions examples/basic/pd-micro-service-cluster.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -32,12 +32,10 @@ spec:
baseImage: pingcap/pd
version: nightly
replicas: 2
config: {}
- name: "scheduling"
baseImage: pingcap/pd
version: nightly
replicas: 1
config: {}
tikv:
baseImage: pingcap/tikv
version: v7.4.0
Expand Down
57 changes: 57 additions & 0 deletions manifests/crd.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -27379,6 +27379,24 @@ spec:
type: string
statefulSetUpdateStrategy:
type: string
storageClassName:
type: string
storageVolumes:
items:
properties:
mountPath:
type: string
name:
type: string
storageClassName:
type: string
storageSize:
type: string
required:
- name
- storageSize
type: object
type: array
suspendAction:
properties:
suspendStatefulSet:
Expand Down Expand Up @@ -44079,6 +44097,45 @@ spec:
type: object
synced:
type: boolean
volumes:
additionalProperties:
properties:
boundCount:
type: integer
currentCapacity:
anyOf:
- type: integer
- type: string
pattern: ^(\+|-)?(([0-9]+(\.[0-9]*)?)|(\.[0-9]+))(([KMGTPE]i)|[numkMGTPE]|([eE](\+|-)?(([0-9]+(\.[0-9]*)?)|(\.[0-9]+))))?$
x-kubernetes-int-or-string: true
currentCount:
type: integer
currentStorageClass:
type: string
modifiedCapacity:
anyOf:
- type: integer
- type: string
pattern: ^(\+|-)?(([0-9]+(\.[0-9]*)?)|(\.[0-9]+))(([KMGTPE]i)|[numkMGTPE]|([eE](\+|-)?(([0-9]+(\.[0-9]*)?)|(\.[0-9]+))))?$
x-kubernetes-int-or-string: true
modifiedCount:
type: integer
modifiedStorageClass:
type: string
name:
type: string
resizedCapacity:
anyOf:
- type: integer
- type: string
pattern: ^(\+|-)?(([0-9]+(\.[0-9]*)?)|(\.[0-9]+))(([KMGTPE]i)|[numkMGTPE]|([eE](\+|-)?(([0-9]+(\.[0-9]*)?)|(\.[0-9]+))))?$
x-kubernetes-int-or-string: true
resizedCount:
type: integer
required:
- name
type: object
type: object
type: object
type: object
pump:
Expand Down
57 changes: 57 additions & 0 deletions manifests/crd/v1/pingcap.com_tidbclusters.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -8380,6 +8380,24 @@ spec:
type: string
statefulSetUpdateStrategy:
type: string
storageClassName:
type: string
storageVolumes:
items:
properties:
mountPath:
type: string
name:
type: string
storageClassName:
type: string
storageSize:
type: string
required:
- name
- storageSize
type: object
type: array
suspendAction:
properties:
suspendStatefulSet:
Expand Down Expand Up @@ -25080,6 +25098,45 @@ spec:
type: object
synced:
type: boolean
volumes:
additionalProperties:
properties:
boundCount:
type: integer
currentCapacity:
anyOf:
- type: integer
- type: string
pattern: ^(\+|-)?(([0-9]+(\.[0-9]*)?)|(\.[0-9]+))(([KMGTPE]i)|[numkMGTPE]|([eE](\+|-)?(([0-9]+(\.[0-9]*)?)|(\.[0-9]+))))?$
x-kubernetes-int-or-string: true
currentCount:
type: integer
currentStorageClass:
type: string
modifiedCapacity:
anyOf:
- type: integer
- type: string
pattern: ^(\+|-)?(([0-9]+(\.[0-9]*)?)|(\.[0-9]+))(([KMGTPE]i)|[numkMGTPE]|([eE](\+|-)?(([0-9]+(\.[0-9]*)?)|(\.[0-9]+))))?$
x-kubernetes-int-or-string: true
modifiedCount:
type: integer
modifiedStorageClass:
type: string
name:
type: string
resizedCapacity:
anyOf:
- type: integer
- type: string
pattern: ^(\+|-)?(([0-9]+(\.[0-9]*)?)|(\.[0-9]+))(([KMGTPE]i)|[numkMGTPE]|([eE](\+|-)?(([0-9]+(\.[0-9]*)?)|(\.[0-9]+))))?$
x-kubernetes-int-or-string: true
resizedCount:
type: integer
required:
- name
type: object
type: object
type: object
type: object
pump:
Expand Down
6 changes: 3 additions & 3 deletions pkg/apis/pingcap/v1alpha1/component_status.go
Original file line number Diff line number Diff line change
Expand Up @@ -195,7 +195,8 @@ func (s *PDMSStatus) GetSynced() bool {
func (s *PDMSStatus) GetPhase() MemberPhase {
return s.Phase
}
func (s *PDMSStatus) GetVolumes() map[StorageVolumeName]*StorageVolumeStatus { return nil }
func (s *PDMSStatus) GetVolumes() map[StorageVolumeName]*StorageVolumeStatus { return s.Volumes }
func (s *PDMSStatus) SetVolumes(vols map[StorageVolumeName]*StorageVolumeStatus) { s.Volumes = vols }
func (s *PDMSStatus) GetConditions() []metav1.Condition {
return s.Conditions
}
Expand Down Expand Up @@ -228,8 +229,7 @@ func (s *PDMSStatus) SetPhase(phase MemberPhase) {
func (s *PDMSStatus) SetStatefulSet(sts *appsv1.StatefulSetStatus) {
s.StatefulSet = sts
}
func (s *PDMSStatus) SetVolumes(vols map[StorageVolumeName]*StorageVolumeStatus) {}
func (s *PDMSStatus) SetVolReplaceInProgress(status bool) {}
func (s *PDMSStatus) SetVolReplaceInProgress(status bool) {}

func (s *TiKVStatus) MemberType() MemberType {
return TiKVMemberType
Expand Down
27 changes: 24 additions & 3 deletions pkg/apis/pingcap/v1alpha1/openapi_generated.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

15 changes: 13 additions & 2 deletions pkg/apis/pingcap/v1alpha1/types.go
Original file line number Diff line number Diff line change
Expand Up @@ -587,7 +587,7 @@ type PDMSSpec struct {
// +optional
BaseImage *string `json:"baseImage"`

// Service defines a Kubernetes service of PD cluster.
// Service defines a Kubernetes service of PD Micro Service cluster.
// Optional: Defaults to `.spec.services` in favor of backward compatibility
// +optional
Service *ServiceSpec `json:"service,omitempty"`
Expand All @@ -598,7 +598,7 @@ type PDMSSpec struct {
// +optional
MaxFailoverCount *int32 `json:"maxFailoverCount,omitempty"`

// Config is the Configuration of pd-servers
// Config is the Configuration of pd Micro Service servers
// +optional
// +kubebuilder:validation:Schemaless
// +kubebuilder:validation:XPreserveUnknownFields
Expand All @@ -618,6 +618,15 @@ type PDMSSpec struct {
// +kubebuilder:validation:Enum:="";"v1"
StartUpScriptVersion string `json:"startUpScriptVersion,omitempty"`

// The storageClassName of the persistent volume for PD Micro Service log storage.
// Defaults to Kubernetes default storage class.
// +optional
StorageClassName *string `json:"storageClassName,omitempty"`

// StorageVolumes configure additional storage for PD Micro Service pods.
// +optional
StorageVolumes []StorageVolume `json:"storageVolumes,omitempty"`

// Timeout threshold when pd get started
// +kubebuilder:default=30
StartTimeout int `json:"startTimeout,omitempty"`
Expand Down Expand Up @@ -1414,6 +1423,8 @@ type PDMSStatus struct {
Synced bool `json:"synced"`
Phase MemberPhase `json:"phase,omitempty"`
StatefulSet *apps.StatefulSetStatus `json:"statefulSet,omitempty"`
// Volumes contains the status of all volumes.
Volumes map[StorageVolumeName]*StorageVolumeStatus `json:"volumes,omitempty"`
// Members contains other service in current TidbCluster
Members []string `json:"members,omitempty"`
Image string `json:"image,omitempty"`
Expand Down
14 changes: 14 additions & 0 deletions pkg/apis/pingcap/v1alpha1/validation/validation.go
Original file line number Diff line number Diff line change
Expand Up @@ -130,6 +130,11 @@ func validateTiDBClusterSpec(spec *v1alpha1.TidbClusterSpec, fldPath *field.Path
if spec.PD != nil {
allErrs = append(allErrs, validatePDSpec(spec.PD, fldPath.Child("pd"))...)
}
if spec.PDMS != nil {
for _, comp := range spec.PDMS {
allErrs = append(allErrs, validatePDMSSpec(comp, fldPath.Child(comp.Name))...)
}
}
if spec.TiKV != nil {
allErrs = append(allErrs, validateTiKVSpec(spec.TiKV, fldPath.Child("tikv"))...)
}
Expand Down Expand Up @@ -175,6 +180,15 @@ func validatePDSpec(spec *v1alpha1.PDSpec, fldPath *field.Path) field.ErrorList
return allErrs
}

func validatePDMSSpec(spec *v1alpha1.PDMSSpec, fldPath *field.Path) field.ErrorList {
allErrs := field.ErrorList{}
allErrs = append(allErrs, validateComponentSpec(&spec.ComponentSpec, fldPath)...)
if len(spec.StorageVolumes) > 0 {
allErrs = append(allErrs, validateStorageVolumes(spec.StorageVolumes, fldPath.Child("storageVolumes"))...)
}
return allErrs
}

func validatePDAddresses(arrayOfAddresses []string, fldPath *field.Path) field.ErrorList {
allErrs := field.ErrorList{}
for i, address := range arrayOfAddresses {
Expand Down
1 change: 1 addition & 0 deletions pkg/apis/pingcap/v1alpha1/validation/validation_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -541,6 +541,7 @@ func newTidbCluster() *v1alpha1.TidbCluster {
PD: &v1alpha1.PDSpec{},
TiKV: &v1alpha1.TiKVSpec{},
TiDB: &v1alpha1.TiDBSpec{},
PDMS: []*v1alpha1.PDMSSpec{},
},
}
tc.Name = "test-validate-requests-storage"
Expand Down
Loading
Loading