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
mgr/dashboard: RGW buckets async validator performance enhancement and name constraints #41023
mgr/dashboard: RGW buckets async validator performance enhancement and name constraints #41023
Conversation
jenkins test dashboard |
jenkins test dashboard |
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.
Just a suggestion.
...ybind/mgr/dashboard/frontend/src/app/ceph/rgw/rgw-bucket-form/rgw-bucket-form.component.html
Outdated
Show resolved
Hide resolved
const ipv4Rgx = /^((25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)\.){3}(25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)$/i; | ||
const ipv6Rgx = /^(?:[a-f0-9]{1,4}:){7}[a-f0-9]{1,4}$/i; |
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.
Aren't there other places in our code where IPv4/6 needs be validated so we make this reusable? Or couldn't we replace part of this validation logic with some external validator library (I did a quick check but no luck)?
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.
I think we should add tests for this
const tests = [
'1.1.1.01',
'001.1.1.01',
]
const ipv4Rgx = /^((25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)\.){3}(25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)$/i;
for(let t in tests)
{
const b = ipv4Rgx.test(tests[t])
console.log(b)
}
output:
true
true
I don't think anyone will type that but who knows
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.
@epuertat There's a CdValidators.ip()
we are using, but I was not succesfull in making it work over here. It was actually used here previously but its actually incorrectly validating the fields (even if we enter IP address it doesn't give error). I checked the external libraries but none for the IP address.
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.
@pereman2 The test for the IPaddress is being covered here: https://github.com/ceph/ceph/pull/41023/files#diff-fc6d2da6d3b05b9128d9d1832bea8b55aa9c4c53c918802b19e6b915cba6415dR72
I think this will verify the IPs validity. Is that okay?
Also thank you for the idea of putting multiple IP address. Didn't thought of that until I saw the example from you.
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.
Nice, thank you!
<span class="invalid-feedback" | ||
*ngIf="bucketForm.showError('bid', frm, 'containsUpperCase')" | ||
i18n>Bucket names must not contain uppercase characters or underscores.</span> | ||
<span class="invalid-feedback" | ||
*ngIf="bucketForm.showError('bid', frm, 'lowerCaseOrNumber')" | ||
i18n>Each label must start and end with a lowercase letter or a number.</span> | ||
<span class="invalid-feedback" | ||
*ngIf="bucketForm.showError('bid', frm, 'ipAddress')" | ||
i18n>Bucket names cannot be formatted as IP address.</span> | ||
<span class="invalid-feedback" | ||
*ngIf="bucketForm.showError('bid', frm, 'shouldBeInRange')" | ||
i18n>Bucket names can be between 3 and 63 characters long.</span> |
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 there any way to reduce the amount of boilerplate code here? Perhas directly return the error message from the validator (or is that an antipatter... I'm not too familiar with this part of Angular)?
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.
I tried and I think I may need to modify showError function for that or something else. But with the current implementations I wasn't able to return error message. If I could do that I can remove these boiler plates from almost all of the form pages. Do you want me to explore that possibility along with this PR? @epuertat (if not I'll raise one tracker and explore it separately)
9c0408f
to
f180057
Compare
jenkins retest this |
jenkins retest this please |
jenkins test dashboard |
f180057
to
8eb20c8
Compare
src/pybind/mgr/dashboard/frontend/src/app/shared/forms/cd-validators.ts
Outdated
Show resolved
Hide resolved
src/pybind/mgr/dashboard/frontend/src/app/ceph/rgw/rgw-bucket-form/rgw-bucket-form.component.ts
Show resolved
Hide resolved
...nd/mgr/dashboard/frontend/src/app/ceph/rgw/rgw-bucket-form/rgw-bucket-form.component.spec.ts
Outdated
Show resolved
Hide resolved
@alfonsomthd @avanthakkar Took care of that weird behaviour. and yeah dashes are allowed but not at the end. |
b894d82
to
14d593d
Compare
The rgw bucket creation form has the Name field which have an async validator. The validator calls all the bucket name and check if the entered name is unique or not. This happens on every keystroke. So if 100 or more buckets are there, then the async validation can be real slow and causes misvalidations in different fields. I changed the validation logic and did some cleanups to improve the performance of the async validation. Fixes: https://tracker.ceph.com/issues/50514 Signed-off-by: Nizamudeen A <nia@redhat.com>
14d593d
to
9b0c723
Compare
c2d57f7
to
45fce2e
Compare
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.
Great work @nizamial09, LGTM!
jenkins test dashboard |
@nizamial09 make-check failure:
|
Explain the rgw bucket name constrains for each bucket name validation errors. Fixes: https://tracker.ceph.com/issues/50516 Signed-off-by: Nizamudeen A <nia@redhat.com>
45fce2e
to
ab04e53
Compare
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.
LGTM @nizamial09 ! Feel free to file trackers for the issues you detected while fixing this one. I still feel that understanding/debugging/extending this part of the code is not exactly straight-forward :/
jenkins test dashboard |
@epuertat I created one tracker for it: https://tracker.ceph.com/issues/50762 I'll look for some alternates to return these errors. |
testValidator('172.10.4.51', false); | ||
}); | ||
it('bucket names cannot be formatted as IP address', fakeAsync(() => { | ||
const testIPs = ['1.1.1.01', '001.1.1.01', '127.0.0.1']; |
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.
You can also add an IPv6 like 2001:0db8:85a3:0000:0000:8a2e:0370:7334
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.
Sorry @alfonsomthd I didn't had a chance to take a look at this in the morning.
Thanks @nizamial09! I liked what I read in this link that @avanthakkar shared. |
The rgw bucket creation form has the Name field which have an async
validator. The validator calls all the bucket name and check if the
entered name is unique or not. This happens on every keystroke. So if
100 or more buckets are there, then the async validation can be real
slow and causes misvalidations in different fields.
I changed the validation logic and did some cleanups to improve the
performance of the async validation.
BEFORE
bucketname-error.mp4
AFTER
bucketname_fix.mp4
Also explains the rgw bucket name constrains for each bucket name validation
errors.
Fixes: https://tracker.ceph.com/issues/50514
Fixes: https://tracker.ceph.com/issues/50516
Signed-off-by: Nizamudeen A nia@redhat.com
Checklist
Show available Jenkins commands
jenkins retest this please
jenkins test classic perf
jenkins test crimson perf
jenkins test signed
jenkins test make check
jenkins test make check arm64
jenkins test submodules
jenkins test dashboard
jenkins test api
jenkins test docs
jenkins render docs
jenkins test ceph-volume all
jenkins test ceph-volume tox