-
Notifications
You must be signed in to change notification settings - Fork 499
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
Conversation
[REVIEW NOTIFICATION] This pull request has been approved by:
To complete the pull request process, please ask the reviewers in the list to review by filling The full list of commands accepted by this bot can be found here. Reviewer can indicate their review by submitting an approval review. |
Codecov Report
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
|
|
||
type VolumeModifier interface { | ||
MinWaitDuration() time.Duration | ||
// ModifyVolume modifies the underlay volume of pvc to match the args of storageclass |
There was a problem hiding this comment.
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.
} | ||
|
||
func (m *EBSModifier) setArgsFromPV(v *Volume, pv *corev1.PersistentVolume) error { | ||
v.VolumeId = pv.Spec.CSI.VolumeHandle |
There was a problem hiding this comment.
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 |
There was a problem hiding this comment.
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?
m.vs[i] = Volume{ | ||
VolumeId: *param.VolumeId, | ||
Size: param.Size, | ||
IOPS: param.Iops, | ||
Throughput: param.Throughput, | ||
Type: param.VolumeType, | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
useless?
pkg/manager/volumes/phase.go
Outdated
return isPVCStatusMatched(pvc, scName, size) | ||
} | ||
|
||
func isPVCStatusMatched(pvc *corev1.PersistentVolumeClaim, scName, size string) bool { |
There was a problem hiding this comment.
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() |
There was a problem hiding this comment.
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 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
log here?
There was a problem hiding this comment.
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.
7db6167
to
5ef3e70
Compare
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 |
There was a problem hiding this comment.
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
b9a9f54
to
44dcf3a
Compare
/test pull-e2e-kind-serial |
47af3f4
to
21b3c70
Compare
/test pull-e2e-kind |
21b3c70
to
949fe88
Compare
/test pull-e2e-kind |
949fe88
to
f84df33
Compare
/test pull-e2e-kind-serial |
/test pull-e2e-kind-tngm |
062efd3
to
77f741e
Compare
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 |
There was a problem hiding this comment.
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?
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" |
There was a problem hiding this comment.
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?
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 | ||
}) |
There was a problem hiding this comment.
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?
Co-authored-by: Shiori <sihao.yu@pingcap.com>
77f741e
to
05d53ca
Compare
/test pull-e2e-kind-br |
1 similar comment
/test pull-e2e-kind-br |
/test pull-e2e-kind-tikv-scale-simultaneously |
/test pull-e2e-kind |
/test pull-e2e-kind-basic |
/merge |
This pull request has been accepted and is ready to merge. Commit hash: 05d53ca
|
/test pull-e2e-kind-tikv-scale-simultaneously |
/test pull-e2e-kind-basic |
/test pull-e2e-kind |
/test pull-e2e-kind-basic |
/test pull-e2e-kind |
/test pull-e2e-kind-basic |
</td> | ||
<td> | ||
<em>(Optional)</em> | ||
<p>ModifiedStorageClass is the modified storage calss of the volume.</p> |
There was a problem hiding this comment.
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> |
There was a problem hiding this comment.
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.
What problem does this PR solve?
What is changed and how does it work?
Code changes
Tests
Side effects
Related changes
Release Notes
Please refer to Release Notes Language Style Guide before writing the release note.