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

Vdc bug fixes for disabling storage profile and deserializing type.Task on vdc.update #433

Merged
merged 30 commits into from
Feb 21, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
30 commits
Select commit Hold shift + click to select a range
d05517b
add main implementation
vbauzys Aug 25, 2020
3faee0a
git push origin master
vbauzys Aug 25, 2020
a497ca1
git push origin master
vbauzys Sep 3, 2020
71d524d
git push origin master
vbauzys Sep 22, 2020
879296d
Merge branch 'master' of github.com:vmware/go-vcloud-director
vbauzys Oct 21, 2020
02a4d81
git push origin masterMerge branch 'master' of github.com:vmware/go-v…
vbauzys Oct 21, 2020
b365d6c
git push origin masterMerge branch 'master' of github.com:vmware/go-v…
vbauzys Oct 27, 2020
808752b
removed not needed after merge
vbauzys Oct 29, 2020
29c17ae
git push origin masterMerge branch 'master' of github.com:vmware/go-v…
vbauzys Nov 5, 2020
9073403
git push origin masterMerge branch 'master' of github.com:vmware/go-v…
vbauzys Nov 12, 2020
9efad14
Merge branch 'vmware:master' into master
vbauzys Oct 11, 2021
dabfd82
git push origin masterMerge branch 'master' of github.com:vmware/go-v…
vbauzys Nov 8, 2021
be532a2
Merge branch 'master' of github.com:vmware/go-vcloud-director
vbauzys Nov 10, 2021
6cf856a
git push origin masterMerge branch 'master' of github.com:vmware/go-v…
vbauzys Nov 23, 2021
144ef18
Merge branch 'master' of github.com:vmware/go-vcloud-director
vbauzys Nov 25, 2021
8c0217f
Merge branch 'master' of github.com:vmware/go-vcloud-director
vbauzys Dec 8, 2021
05ac73e
Merge branch 'master' of github.com:vmware/go-vcloud-director
vbauzys Dec 17, 2021
9056c05
Merge branch 'master' of github.com:vmware/go-vcloud-director
vbauzys Dec 20, 2021
cb919b2
Merge branch 'master' of github.com:vmware/go-vcloud-director
vbauzys Jan 5, 2022
253df2d
Merge branch 'master' of github.com:vmware/go-vcloud-director
vbauzys Jan 13, 2022
a1bccce
Merge branch 'master' of github.com:vmware/go-vcloud-director
vbauzys Jan 17, 2022
2fa708c
Merge branch 'master' of github.com:vmware/go-vcloud-director
vbauzys Jan 17, 2022
5161390
Merge branch 'main' of github.com:vmware/go-vcloud-director into main
vbauzys Jan 19, 2022
7c0cf81
Merge branch 'main' of github.com:vmware/go-vcloud-director into main
vbauzys Jan 19, 2022
b612837
fix storage profile disablement for VDC
vbauzys Feb 2, 2022
d1e125d
fix task deserialization issue when VDC updated
vbauzys Feb 2, 2022
ea6edad
add changelog
vbauzys Feb 2, 2022
366c1d1
improve changelog
vbauzys Feb 2, 2022
df41819
add check
vbauzys Feb 17, 2022
861ea7b
update changelog
vbauzys Feb 18, 2022
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions .changes/v2.15.0/433-bug-fixes.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
* Fixes Issue #431 "Wrong order in Task structure" [GH-433]
Copy link
Collaborator

Choose a reason for hiding this comment

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

IMO we need to mention "convert field types" - so that it is clear why we broke compatibility

Copy link
Contributor Author

Choose a reason for hiding this comment

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

added comment

* Fixes Issue where VDC creation with storage profile `enabled=false` wasn't working. `VdcStorageProfile.enabled` and `VdcStorageProfileConfiguration.enabled` changed to pointers [GH-433]
2 changes: 1 addition & 1 deletion govcd/adminvdc.go
Original file line number Diff line number Diff line change
Expand Up @@ -483,7 +483,7 @@ func (vdc *AdminVdc) RemoveStorageProfile(storageProfileName string) (Task, erro
if err != nil {
return Task{}, fmt.Errorf("cannot retrieve VDC storage profile '%s' details: %s", storageProfileName, err)
}
if vdcStorageProfileDetails.Enabled {
if vdcStorageProfileDetails.Enabled != nil && *vdcStorageProfileDetails.Enabled {
_, err = vdc.UpdateStorageProfile(extractUuid(storageProfile.HREF), &types.AdminVdcStorageProfile{
Name: vdcStorageProfileDetails.Name,
Units: vdcStorageProfileDetails.Units,
Expand Down
2 changes: 1 addition & 1 deletion govcd/adminvdc_nsxt_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,7 @@ func (vcd *TestVCD) Test_CreateNsxtOrgVdc(check *C) {
},
},
VdcStorageProfile: []*types.VdcStorageProfileConfiguration{&types.VdcStorageProfileConfiguration{
Enabled: true,
Enabled: takeBoolPointer(true),
Units: "MB",
Limit: 1024,
Default: true,
Expand Down
74 changes: 69 additions & 5 deletions govcd/adminvdc_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -41,11 +41,19 @@ func (vcd *TestVCD) Test_CreateOrgVdcWithFlex(check *C) {

providerVdcHref := getVdcProviderVdcHref(vcd, check)

storageProfile, err := vcd.client.QueryProviderVdcStorageProfileByName(vcd.config.VCD.ProviderVdc.StorageProfile, providerVdcHref)
storageProfile, err := vcd.client.QueryProviderVdcStorageProfileByName(vcd.config.VCD.StorageProfile.SP1, providerVdcHref)
check.Assert(err, IsNil)
providerVdcStorageProfileHref := storageProfile.HREF
firstStorageProfileHref := storageProfile.HREF
networkPoolHref := getVdcNetworkPoolHref(vcd, check)

secondStorageProfileHref := ""
// Make test more robust and tests additionally disabled storage profile
if vcd.config.VCD.StorageProfile.SP2 != "" {
storageProfile, err := vcd.client.QueryProviderVdcStorageProfileByName(vcd.config.VCD.StorageProfile.SP2, providerVdcHref)
check.Assert(err, IsNil)
secondStorageProfileHref = storageProfile.HREF
}

allocationModels := []string{"AllocationVApp", "AllocationPool", "ReservationPool", "Flex"}
trueValue := true
for i, allocationModel := range allocationModels {
Expand All @@ -67,12 +75,12 @@ func (vcd *TestVCD) Test_CreateOrgVdcWithFlex(check *C) {
},
},
VdcStorageProfile: []*types.VdcStorageProfileConfiguration{&types.VdcStorageProfileConfiguration{
Enabled: true,
Enabled: takeBoolPointer(true),
Units: "MB",
Limit: 1024,
Default: true,
ProviderVdcStorageProfile: &types.Reference{
HREF: providerVdcStorageProfileHref,
HREF: firstStorageProfileHref,
},
},
},
Expand All @@ -92,6 +100,18 @@ func (vcd *TestVCD) Test_CreateOrgVdcWithFlex(check *C) {
vdcConfiguration.IncludeMemoryOverhead = &trueValue
}

if secondStorageProfileHref != "" {
vdcConfiguration.VdcStorageProfile = append(vdcConfiguration.VdcStorageProfile, &types.VdcStorageProfileConfiguration{
Enabled: takeBoolPointer(false),
Units: "MB",
Limit: 1024,
Default: false,
ProviderVdcStorageProfile: &types.Reference{
HREF: secondStorageProfileHref,
},
})
}

vdc, _ := adminOrg.GetVDCByName(vdcConfiguration.Name, false)
if vdc != nil {
err = vdc.DeleteWait(true, true)
Expand All @@ -108,8 +128,8 @@ func (vcd *TestVCD) Test_CreateOrgVdcWithFlex(check *C) {
vdcConfiguration.ComputeCapacity[0].Memory.Units = "MB"

vdc, err = adminOrg.CreateOrgVdc(vdcConfiguration)
check.Assert(vdc, NotNil)
check.Assert(err, IsNil)
check.Assert(vdc, NotNil)

AddToCleanupList(vdcConfiguration.Name, "vdc", vcd.org.Org.Name, "Test_CreateVdcWithFlex")

Expand All @@ -119,6 +139,15 @@ func (vcd *TestVCD) Test_CreateOrgVdcWithFlex(check *C) {
check.Assert(vdc.Vdc.Name, Equals, vdcConfiguration.Name)
check.Assert(vdc.Vdc.IsEnabled, Equals, vdcConfiguration.IsEnabled)
check.Assert(vdc.Vdc.AllocationModel, Equals, vdcConfiguration.AllocationModel)
if secondStorageProfileHref != "" {
check.Assert(vdc.Vdc.VdcStorageProfiles, NotNil)
check.Assert(vdc.Vdc.VdcStorageProfiles.VdcStorageProfile, NotNil)
check.Assert(vdc.Vdc.VdcStorageProfiles.VdcStorageProfile[1], NotNil)
}

vdcStorageProfileDetails, err := adminOrg.client.GetStorageProfileByHref(vdc.Vdc.VdcStorageProfiles.VdcStorageProfile[1].HREF)
check.Assert(err, IsNil)
check.Assert(*vdcStorageProfileDetails.Enabled, Equals, false)

err = vdc.DeleteWait(true, true)
check.Assert(err, IsNil)
Expand Down Expand Up @@ -147,6 +176,41 @@ func (vcd *TestVCD) Test_UpdateVdcFlex(check *C) {
check.Assert(adminVdc.AdminVdc.IsEnabled, Equals, vdcConfiguration.IsEnabled)
check.Assert(adminVdc.AdminVdc.AllocationModel, Equals, vdcConfiguration.AllocationModel)

// test part to reproduce https://github.com/vmware/go-vcloud-director/issues/431
// this part manages to create task error which later on VDC update fails if type properties order is bad
providerVdcHref := getVdcProviderVdcHref(vcd, check)
pvdcStorageProfile, err := vcd.client.QueryProviderVdcStorageProfileByName(vcd.config.VCD.StorageProfile.SP2, providerVdcHref)
check.Assert(err, IsNil)

err = adminVdc.AddStorageProfileWait(&types.VdcStorageProfileConfiguration{
Enabled: takeBoolPointer(true),
Default: false,
Units: "MB",
ProviderVdcStorageProfile: &types.Reference{HREF: pvdcStorageProfile.HREF},
},
"")
check.Assert(err, IsNil)

vdc, err := adminOrg.GetVDCByName(vdcConfiguration.Name, true)
check.Assert(err, IsNil)

vappName := check.TestName()
vmName := check.TestName()
vapp, err := makeEmptyVapp(vdc, vappName, "")
check.Assert(err, IsNil)
_, err = makeEmptyVm(vapp, vmName)
check.Assert(err, IsNil)
AddToCleanupList(vappName, "vapp", "", vappName)

err = adminVdc.SetDefaultStorageProfile(vcd.config.VCD.StorageProfile.SP2)
check.Assert(err, IsNil)
err = adminVdc.RemoveStorageProfileWait(vcd.config.VCD.StorageProfile.SP1)
// fails with error in task which stays referenced in VDC as `history` element
check.Assert(err, NotNil)
err = adminVdc.Refresh()
check.Assert(err, IsNil)
// end

updateDescription := "updateDescription"
computeCapacity := []*types.ComputeCapacity{
&types.ComputeCapacity{
Expand Down
2 changes: 1 addition & 1 deletion govcd/common_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -764,7 +764,7 @@ func spawnTestVdc(vcd *TestVCD, check *C, adminOrgName string) *Vdc {
},
},
VdcStorageProfile: []*types.VdcStorageProfileConfiguration{&types.VdcStorageProfileConfiguration{
Enabled: true,
Enabled: takeBoolPointer(true),
Units: "MB",
Limit: 1024,
Default: true,
Expand Down
8 changes: 4 additions & 4 deletions govcd/org_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -282,7 +282,7 @@ func (vcd *TestVCD) Test_CreateVdc(check *C) {
},
},
VdcStorageProfile: []*types.VdcStorageProfileConfiguration{&types.VdcStorageProfileConfiguration{
Enabled: true,
Enabled: takeBoolPointer(true),
Units: "MB",
Limit: 1024,
Default: true,
Expand Down Expand Up @@ -651,7 +651,7 @@ func setupVdc(vcd *TestVCD, check *C, allocationModel string) (AdminOrg, *types.
},
},
VdcStorageProfile: []*types.VdcStorageProfileConfiguration{&types.VdcStorageProfileConfiguration{
Enabled: true,
Enabled: takeBoolPointer(true),
Units: "MB",
Limit: 1024,
Default: true,
Expand Down Expand Up @@ -822,7 +822,7 @@ func (vcd *TestVCD) Test_AddRemoveVdcStorageProfiles(check *C) {

// Add another storage profile
err = adminVdc.AddStorageProfileWait(&types.VdcStorageProfileConfiguration{
Enabled: true,
Enabled: takeBoolPointer(true),
Units: "MB",
Limit: 1024,
Default: false,
Expand All @@ -846,7 +846,7 @@ func (vcd *TestVCD) Test_AddRemoveVdcStorageProfiles(check *C) {

// Add the second storage profile again
err = adminVdc.AddStorageProfileWait(&types.VdcStorageProfileConfiguration{
Enabled: true,
Enabled: takeBoolPointer(true),
Units: "MB",
Limit: 1024,
Default: false,
Expand Down
2 changes: 1 addition & 1 deletion govcd/vdc_group_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -128,7 +128,7 @@ func createNewVdc(vcd *TestVCD, check *C, vdcName string) *Vdc {
},
},
VdcStorageProfile: []*types.VdcStorageProfileConfiguration{&types.VdcStorageProfileConfiguration{
Enabled: true,
Enabled: takeBoolPointer(true),
Units: "MB",
Limit: 1024,
Default: true,
Expand Down
15 changes: 8 additions & 7 deletions types/v56/types.go
Original file line number Diff line number Diff line change
Expand Up @@ -470,7 +470,7 @@ type AdminVdc struct {
// Since: 5.1
// https://code.vmware.com/apis/220/vcloud#/doc/doc/types/VdcStorageProfileParamsType.html
type VdcStorageProfileConfiguration struct {
Enabled bool `xml:"Enabled,omitempty"`
Enabled *bool `xml:"Enabled,omitempty"`
Units string `xml:"Units"`
Limit int64 `xml:"Limit"`
Default bool `xml:"Default"`
Expand All @@ -485,7 +485,7 @@ type VdcStorageProfileConfiguration struct {
type VdcStorageProfile struct {
Xmlns string `xml:"xmlns,attr"`
Name string `xml:"name,attr"`
Enabled bool `xml:"Enabled,omitempty"`
Enabled *bool `xml:"Enabled,omitempty"`
Units string `xml:"Units"`
Limit int64 `xml:"Limit"`
Default bool `xml:"Default"`
Expand Down Expand Up @@ -576,15 +576,16 @@ type Task struct {
EndTime string `xml:"endTime,attr,omitempty"` // The date and time that processing of the task was completed. May not be present if the task is still being executed.
ExpiryTime string `xml:"expiryTime,attr,omitempty"` // The date and time at which the task resource will be destroyed and no longer available for retrieval. May not be present if the task has not been executed or is still being executed.
CancelRequested bool `xml:"cancelRequested,attr,omitempty"` // Whether user has requested this processing to be canceled.
Link *Link `xml:"Link,omitempty"` // A reference to an entity or operation associated with this object.
Description string `xml:"Description,omitempty"` // Optional description.
Details string `xml:"Details,omitempty"` // Detailed message about the task. Also contained by the Owner entity when task status is preRunning.
Tasks *TasksInProgress `xml:"Tasks,omitempty"` // A list of queued, running, or recently completed tasks associated with this entity.
Owner *Reference `xml:"Owner,omitempty"` // Reference to the owner of the task. This is typically the object that the task is creating or updating.
Error *Error `xml:"Error,omitempty"` // Represents error information from a failed task.
Link *Link `xml:"Link,omitempty"` // A reference to an entity or operation associated with this object.
User *Reference `xml:"User,omitempty"` // The user who started the task.
Organization *Reference `xml:"Organization,omitempty"` // The organization to which the User belongs.
Owner *Reference `xml:"Owner,omitempty"` // Reference to the owner of the task. This is typically the object that the task is creating or updating.
Progress int `xml:"Progress,omitempty"` // Read-only indicator of task progress as an approximate percentage between 0 and 100. Not available for all tasks.
Tasks *TasksInProgress `xml:"Tasks,omitempty"` // A list of queued, running, or recently completed tasks associated with this entity.
User *Reference `xml:"User,omitempty"` // The user who started the task.
Details string `xml:"Details,omitempty"` // Detailed message about the task. Also contained by the Owner entity when task status is preRunning.

//
// TODO: add the following fields
// Params anyType The parameters with which this task was started.
Expand Down