Merge lp:~rvb/gwacl/delete-disk-fix into lp:gwacl
Status: | Merged |
---|---|
Approved by: | Raphaël Badin |
Approved revision: | 94 |
Merged at revision: | 91 |
Proposed branch: | lp:~rvb/gwacl/delete-disk-fix |
Merge into: | lp:gwacl |
Diff against target: |
318 lines (+195/-15) 8 files modified
.bzrignore (+1/-0) deletedisk.go (+64/-0) deletedisk_test.go (+103/-0) example/live_example_managementapi.go (+0/-4) managementapi.go (+8/-0) managementapi_test.go (+5/-0) poller.go (+7/-7) poller_test.go (+7/-4) |
To merge this branch: | bzr merge lp:~rvb/gwacl/delete-disk-fix |
Related bugs: |
Reviewer | Review Type | Date Requested | Status |
---|---|---|---|
Gavin Panella | Approve | ||
Review via email: mp+159150@code.launchpad.net |
Commit message
Use a poller in ManagementAPI.
Description of the change
This branch adds a poller used to delete a disk in order to work around a Windows Azure bug: it takes an indeterminate time for a disk previously attached to a deleted VM to become "not in use" and thus be available for deletion.
I refactored the poller: isDone() now also takes the error returned by poll(). This was done because I needed it for this branch obviously but this simply makes the poller more generic: isDone() can also decide whether or not the polling should stop using the error returned by poll() (and not only using the 'response' returned by poll()).
I've made all I could to keep this workaround contained. The goal was that, once the bug will be fixed in Windows Azure, only minimal changes will be required to revert to the old implementation. That's why the test TestManagementA
- remove the existing DeleteDisk() method and rename _DeleteDisk() into DeleteDisk()
- delete the files deletedisk.go and deletedisk_test.go.
- remove the tweak to deleteDiskInterval in managementapi_
Looks good :)
[1]
+func isInUseError( errString string, diskName string) bool { "BadRequest - A disk with name %s is currently in use by virtual machine.*", regexp. QuoteMeta( diskName) ) MatchString( pattern, errString)
+ pattern := fmt.Sprintf(
+ res, err := regexp.
Do you think it's necessary to check the disk name in the error message?
It might be clearer to check that the response status is 400, and that
the body contains the phrases "A disk with name" and "is currently in
use by virtual machine".
[2]
+ res, err := regexp. MatchString( pattern, errString) Sprintf( "can not compile regular expression: %v", pattern))
+ if err != nil {
+ panic(fmt.
+ }
Fwiw, there's regexp.MustCompile for these kinds of situations; saves
having to do the 3-line-dance.