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

feat(pvc): support modify ebs #4683

Merged
merged 2 commits into from
Sep 22, 2022
Merged

Conversation

liubog2008
Copy link
Member

@liubog2008 liubog2008 commented Aug 23, 2022

What problem does this PR solve?

  • Sync volume status when syncing tc status
  • Support to config env for the operator when install by helm
  • Add a feature gate "VolumeModifying" to enable the volume modifying, default to disable.

What is changed and how does it work?

Code changes

  • Has Go code change
  • Has CI related scripts change

Tests

  • Unit test
  • E2E test
  • Manual test
  • No code

Side effects

  • Breaking backward compatibility
  • Other side effects:

Related changes

  • Need to cherry-pick to the release branch
  • Need to update the documentation

Release Notes

Please refer to Release Notes Language Style Guide before writing the release note.

support modify ebs

@ti-chi-bot
Copy link
Member

ti-chi-bot commented Aug 23, 2022

[REVIEW NOTIFICATION]

This pull request has been approved by:

  • KanShiori
  • csuzhangxc

To complete the pull request process, please ask the reviewers in the list to review by filling /cc @reviewer in the comment.
After your PR has acquired the required number of LGTMs, you can assign this pull request to the committer in the list by filling /assign @committer in the comment to help you merge this pull request.

The full list of commands accepted by this bot can be found here.

Reviewer can indicate their review by submitting an approval review.
Reviewer can cancel approval by submitting a request changes review.

@liubog2008 liubog2008 marked this pull request as draft August 23, 2022 08:15
@codecov-commenter
Copy link

codecov-commenter commented Aug 23, 2022

Codecov Report

Merging #4683 (05d53ca) into master (7c188d4) will increase coverage by 9.37%.
The diff coverage is 58.93%.

Additional details and impacted files
@@            Coverage Diff             @@
##           master    #4683      +/-   ##
==========================================
+ Coverage   62.13%   71.51%   +9.37%     
==========================================
  Files         197      210      +13     
  Lines       21917    25492    +3575     
==========================================
+ Hits        13619    18230    +4611     
+ Misses       7053     5954    -1099     
- Partials     1245     1308      +63     
Flag Coverage Δ
e2e 58.51% <33.26%> (?)
unittest 61.56% <49.10%> (-0.57%) ⬇️


type VolumeModifier interface {
MinWaitDuration() time.Duration
// ModifyVolume modifies the underlay volume of pvc to match the args of storageclass
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

it's better to explain the bool return value here.

pkg/manager/volumes/delegation/aws/ebs_modifier.go Outdated Show resolved Hide resolved
}

func (m *EBSModifier) setArgsFromPV(v *Volume, pv *corev1.PersistentVolume) error {
v.VolumeId = pv.Spec.CSI.VolumeHandle
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

is it needed to check pv.Spec.CSI != nil and pv.Spec.CSI.VolumeHandle != "" here?


func (m *EBSModifier) setArgsFromStorageClass(v *Volume, sc *storagev1.StorageClass) error {
if sc == nil {
return nil
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

When will sc be nil, and what's the expect behaviour?

Comment on lines 53 to 59
m.vs[i] = Volume{
VolumeId: *param.VolumeId,
Size: param.Size,
IOPS: param.Iops,
Throughput: param.Throughput,
Type: param.VolumeType,
}
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

useless?

return isPVCStatusMatched(pvc, scName, size)
}

func isPVCStatusMatched(pvc *corev1.PersistentVolumeClaim, scName, size string) bool {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

any better name? the returned value is changed not matched. the same for isPVCSpecMatched in pod_vol_modifier.go

}

func (p *podVolModifier) Modify(tc *v1alpha1.TidbCluster, pod *corev1.Pod, expected []DesiredVolume, shouldEvictLeader bool) (bool, error) {
ctx := context.TODO()
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

pass ctx in as a parameter?

func (p *podVolModifier) modifyVolume(ctx context.Context, vol *ActualVolume) (bool, error) {
m := p.getVolumeModifier(vol.Desired.StorageClass)
if m == nil {
// skip modifying volume by delegation.VolumeModifier
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

log here?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It's not an invalid path. Size of some volumes can be modified even though delegation.VolumeModifier is not implemented.

@liubog2008 liubog2008 marked this pull request as ready for review September 13, 2022 06:23
@liubog2008 liubog2008 changed the title wip: support modify ebs feat(pvc): support modify ebs Sep 13, 2022
pkg/controller/dependences.go Show resolved Hide resolved
Comment on lines -181 to -199
return fmt.Errorf("upgradeTiKVPod: failed to get pods %s for cluster %s/%s, error: %s", upgradePodName, ns, tcName, err)
return fmt.Errorf("upgradeTiKVPod: failed to get pod %s for tc %s/%s, error: %s", upgradePodName, ns, tcName, err)
}

storeID, err := TiKVStoreIDFromStatus(tc, upgradePodName)
done, err := u.evictLeaderBeforeUpgrade(tc, upgradePod)
if err != nil {
if err == ErrNotFoundStoreID {
return controller.RequeueErrorf("tidbcluster: [%s/%s] no store status found for tikv pod: [%s]", ns, tcName, upgradePodName)
}
return err
return fmt.Errorf("upgradeTiKVPod: failed to evict leader of pod %s for tc %s/%s, error: %s", upgradePodName, ns, tcName, err)
}

_, evicting := upgradePod.Annotations[EvictLeaderBeginTime]
if !evicting {
return u.beginEvictLeader(tc, storeID, upgradePod)
if !done {
return controller.RequeueErrorf("upgradeTiKVPod: evicting leader of pod %s for tc %s/%s", upgradePodName, ns, tcName)
}

if u.readyToUpgrade(upgradePod, tc) {
mngerutils.SetUpgradePartition(newSet, ordinal)
return nil
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

have moved into the func evictLeaderBeforeUpgrade

@liubog2008
Copy link
Member Author

/test pull-e2e-kind-serial

@liubog2008
Copy link
Member Author

/test pull-e2e-kind

@liubog2008
Copy link
Member Author

/test pull-e2e-kind

@liubog2008
Copy link
Member Author

/test pull-e2e-kind-serial

@liubog2008
Copy link
Member Author

/test pull-e2e-kind-tngm

@liubog2008 liubog2008 force-pushed the support-modify-ebs branch 2 times, most recently from 062efd3 to 77f741e Compare September 21, 2022 06:34
Comment on lines +29 to +47
VolumePhaseUnknown VolumePhase = iota
// 1. isPVCRevisionChanged: false
// 2. needModify: true
// 3. waitForNextTime: true
VolumePhasePending
// 1. isPVCRevisionChanged: false
// 2. needModify: true
// 3. waitForNextTime: false
VolumePhasePreparing
// 1. isPVCRevisionChanged: true
// 2. needModify: true/false
// 3. waitForNextTime: true/false
VolumePhaseModifying
// 1. isPVCRevisionChanged: false
// 2. needModify: false
// 3. waitForNextTime: true/false
VolumePhaseModified

VolumePhaseCannotModify
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

How about adding some comments to describe every phase?

Comment on lines +37 to +45
annoKeyPVCSpecRevision = "spec.tidb.pingcap.com/revision"
annoKeyPVCSpecStorageClass = "spec.tidb.pingcap.com/storage-class"
annoKeyPVCSpecStorageSize = "spec.tidb.pingcap.com/storage-size"

annoKeyPVCStatusRevision = "status.tidb.pingcap.com/revision"
annoKeyPVCStatusStorageClass = "status.tidb.pingcap.com/storage-class"
annoKeyPVCStatusStorageSize = "status.tidb.pingcap.com/storage-size"

annoKeyPVCLastTransitionTimestamp = "status.tidb.pingcap.com/last-transition-timestamp"
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

how about adding some comments to describe every annotation?

Comment on lines +162 to +168
sort.Slice(pods, func(i, k int) bool {
a, b := pods[i].Name, pods[k].Name
if len(a) != len(b) {
return len(a) < len(b)
}
return a < b
})
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

how about adding comments to describe the reason for the sorting?

liubog2008 and others added 2 commits September 21, 2022 16:21
Co-authored-by: Shiori <sihao.yu@pingcap.com>
@KanShiori KanShiori mentioned this pull request Sep 21, 2022
6 tasks
@csuzhangxc
Copy link
Member

/test pull-e2e-kind-br

1 similar comment
@KanShiori
Copy link
Collaborator

/test pull-e2e-kind-br

@csuzhangxc
Copy link
Member

/test pull-e2e-kind-tikv-scale-simultaneously

@csuzhangxc
Copy link
Member

/test pull-e2e-kind

@csuzhangxc
Copy link
Member

/test pull-e2e-kind-basic

@csuzhangxc
Copy link
Member

/merge

@ti-chi-bot
Copy link
Member

This pull request has been accepted and is ready to merge.

Commit hash: 05d53ca

@csuzhangxc
Copy link
Member

/test pull-e2e-kind-tikv-scale-simultaneously

@liubog2008
Copy link
Member Author

/test pull-e2e-kind-basic

@csuzhangxc
Copy link
Member

/test pull-e2e-kind

@csuzhangxc
Copy link
Member

/test pull-e2e-kind-basic

@csuzhangxc
Copy link
Member

/test pull-e2e-kind

@csuzhangxc
Copy link
Member

/test pull-e2e-kind-basic

@ti-chi-bot ti-chi-bot merged commit 755dff3 into pingcap:master Sep 22, 2022
@KanShiori KanShiori mentioned this pull request Oct 10, 2022
6 tasks
</td>
<td>
<em>(Optional)</em>
<p>ModifiedStorageClass is the modified storage calss of the volume.</p>
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

incorrect description?

<p>CurrentCapacity is the current capacity of the volume.
If any volume is resizing, it is the capacity before resizing.
If all volumes are resized, it is the resized capacity and same as desired capacity.</p>
</td>
</tr>
<tr>
<td>
<code>modifiedCapacity</code></br>
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The terms "resizedCapacity" and "modifiedCapacity" are confusingly named.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

6 participants