-
Notifications
You must be signed in to change notification settings - Fork 987
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
fixes #23369 - load vmware datastores async #6103
fixes #23369 - load vmware datastores async #6103
Conversation
Issues: #23369 |
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.
Thanks @timogoebel 👍
I left few inline comments about the javascript part :)
const { allowClear } = this.props; | ||
|
||
if ($.fn.select2) { | ||
$(this.refs.select) |
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.
react 16.3 uses createRef
API instead
Would you mind to use it?
https://reactjs.org/docs/refs-and-the-dom.html
.set('datastoresError', undefined) | ||
.set('storagePods', {}) | ||
.set('storagePodsLoading', true) | ||
.set('storagePodsError', undefined) |
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.
instead of a lot of nested .set
you can use merge
}); | ||
}; | ||
|
||
export const fetchDatastores = url => (dispatch) => { |
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.
should it be exported while it's used only in this file?
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.
on the other hand, i tend to prefer to call this action from the component's componentDidMount
}); | ||
}; | ||
|
||
export const fetchStoragePods = url => (dispatch) => { |
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.
ditto
@@ -17,6 +17,12 @@ const Controller = ({ | |||
controllerVolumes, | |||
removeController, | |||
config, | |||
datastores, |
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.
Could you add Proptype? It would be much easier to understand the component's props with it
@amirfefer: Thanks for the review, will take a look at your invaluable comments (and probably learn a lot!). 👍 |
caeac4d
to
a24ce0f
Compare
@amirfefer: I hope I addressed most of your comments. Unfortunately, I did not get |
I've tested the functionality and works great with and without cache enabled. I defer to @amirfefer for the |
return state | ||
.set('datastoresError', undefined) | ||
.set('datastores', {}) | ||
.set('datastoresLoading', true); |
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.
please use merge instead of multiple sets, its suppose to be faster :)
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.
could you please also have a look at the storybook? I think it needs an update after these changes.
nice additions, thanks!
@ohadlevy: Sure, but after 20 minutes trying to get the storybook server running I gave up. Does it work for you?
|
@timogoebel it seems to work for me:
|
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.
Thanks @timogoebel 👍
just few minor issues with PropType
config: PropTypes.object, | ||
controllers: PropTypes.array, | ||
data: PropTypes.object, | ||
datastores: PropTypes.object, |
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.
PropTypes.object is not informative
Proptype.shape
is much better for arrays and objects.
Plus, if a prop is required, add isRequired
to it
i.e:
PropTypes.shape({
color: PropTypes.string,
fontSize: PropTypes.number
}).isRequired, // if a prop is required, add `.isRequired`, else just add a default value
const mapDispatchToProps = (state) => { | ||
const { controllers, config, volumes = [] } = state.hosts.storage.vmware; | ||
const { | ||
controllers, config, volumes = [], datastores, datastoresLoading, datastoresError, |
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 use default values with Proptype:
StorageContainer.defaultProps = {
volumes: []
};
what is the status of this PR? (if its ready for today's cut of date?) |
@ohadlevy: I won't be able to look at this today. Let's to it in the 1.21 cycle. |
a24ce0f
to
41d6490
Compare
41d6490
to
b5f603e
Compare
@amirfefer, @ohadlevy, @ares: Improved the prop types and fixed up storybook. Can you please re-review? |
LGFM 👍 |
c554d37
to
ad0e808
Compare
This is my final attempt to get this in, I rebased the code and added support for statistics of the datastore and storage pods. |
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, I don't have a working VMWare env to test.
@timogoebel or anyone interested, regarding storybook issue (if you still have it), this workaround works for me - https://gist.github.com/lizagilman/d3a94114fc3fd3214138ec120fca4a5c |
@lizagilman: Thanks. I chose the "reboot" approach. That was quite popular in ancient times. |
@chris1984: Can you do me a favor and test and ack this? Thanks a bunch. |
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.
ACK, looks good Thanks @timogoebel
[test foreman] |
It seems like test failures are related, mind to take a look? |
6fa1416
ad0e808
to
6fa1416
Compare
Fixed the tests. |
Tests passed. |
@@ -83,6 +83,7 @@ | |||
"jstz": "~1.0.7", | |||
"lodash": "^4.17.10", | |||
"multiselect": "~0.9.12", | |||
"number_helpers": "^0.1.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.
I tried packaging this, but it fails, I assume before merge we would need a packaging ACK.
EDIT: for completion, the error is
./add_npm_package.sh number_helpers 0.1.1
Found 0 dependencies - using single strategy
Making directory...FINISHED
Creating specs and downloading sources...---- npm2rpm ----
-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-
- Starting npm module download: https://registry.npmjs.org/number_helpers/-/number_helpers-0.1.1.tgz
- Unpacking in /tmp/npm2rpm-15831E09pZQE4YSYD ...
- Finished extracting for number_helpers
- Reading package.json for number_helpers
Warning: No README data
Warning: No license field.
- Finished reading package.json for number_helpers
fs.js:133
throw new ERR_INVALID_CALLBACK();
^
TypeError [ERR_INVALID_CALLBACK]: Callback must be a function
at maybeCallback (fs.js:133:9)
at Object.writeFile (fs.js:1139:14)
at writeSpecFile (/home/ohad/git/foreman-packaging/node_modules/npm2rpm/bin/npm2rpm.js:87:6)
at Extract.tar_extract.stream.on (/home/ohad/git/foreman-packaging/node_modules/npm2rpm/bin/npm2rpm.js:78:5)
at Extract.emit (events.js:187:15)
at DirWriter.<anonymous> (/home/ohad/git/foreman-packaging/node_modules/tar/lib/extract.js:81:8)
at DirWriter.emit (events.js:187:15)
at end (/home/ohad/git/foreman-packaging/node_modules/fstream/lib/writer.js:324:14)
at /home/ohad/git/foreman-packaging/node_modules/fstream/lib/writer.js:314:34
at endUtimes (/home/ohad/git/foreman-packaging/node_modules/fstream/lib/writer.js:238:46)
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 that was a warning for a while already but likely that there's an update which makes it strict. I'll have a look.
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.
also TODO: add this package to webpack vendor file (can be done in a follow up pr).
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.
theforeman/foreman-packaging#3174. Luckily in theforeman/npm2rpm#48 I already fixed that issue.
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.
@ekohl great, once you are ready please ack this PR.
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.
Packaging ACK, haven't looked at the code :)
thanks @timogoebel! |
Thanks, @ohadlevy + @amirfefer + @ares + @ekohl + @chris1984! |
This commit introduces async loading of vSphere Datastores and Storage Pods.
This speeds up the time before the form is required and is a prerequisite for #3559, a feature requested in 2013 that we still haven't delivered.
@ohadlevy: Do you mind reviewing this as this is react code?