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

added support for returning array of BaseCnsVolumeOperationResult for QueryVolumeInfo API #2041

Merged
merged 1 commit into from
Jul 1, 2020

Conversation

divyenpatel
Copy link
Member

Fixes #2010, kubernetes-sigs/vsphere-csi-driver#249

Fixed issue reported by @SandeepPissay at - kubernetes-sigs/vsphere-csi-driver#235 (comment)

QueryVolumeInfo can take multiple Volumes IDs as input and should returns an array of BaseCnsVolumeOperationResult.

In this PR, I am adding function GetTaskResultArray to help retrieve array of BaseCnsVolumeOperationResult for all specified volumes in the QueryVolumeInfo request.

Testing Done.

Request

  client_test.go:224: Calling QueryVolumeInfo using: []types.CnsVolumeId{
            {
                Id: "759f3fa8-f692-4a8e-b65c-3fcd56d0f947",
            },
            {
                Id: "c2c2d2bb-f864-4e4f-9bde-39ca6b1302b6",
            },
            {
                Id: "6885ca7d-09a3-40f5-9706-475cbd479934",
            },
        }

Response

    client_test.go:244: queryVolumeInfoTaskResults: []types.BaseCnsVolumeOperationResult{
            &types.CnsQueryVolumeInfoResult{
                CnsVolumeOperationResult: types.CnsVolumeOperationResult{},
                VolumeInfo:               &types.CnsBlockVolumeInfo{
                    CnsVolumeInfo:  types.CnsVolumeInfo{},
                    VStorageObject: types.VStorageObject{
                        Config: types.VStorageObjectConfigInfo{
                            BaseConfigInfo: types.BaseConfigInfo{
                                Id: types.ID{
                                    Id: "759f3fa8-f692-4a8e-b65c-3fcd56d0f947",
                                },
                                Name:                        "pvc-901e87eb-c2bd-11e9-806f-005056a0c9a0",
                                CreateTime:                  time.Now(),
                                KeepAfterDeleteVm:           types.NewBool(true),
                                RelocationDisabled:          types.NewBool(false),
                                NativeSnapshotSupported:     types.NewBool(false),
                                ChangedBlockTrackingEnabled: types.NewBool(false),
                                Backing:                     &types.BaseConfigInfoDiskFileBackingInfo{
                                    BaseConfigInfoFileBackingInfo: types.BaseConfigInfoFileBackingInfo{
                                        BaseConfigInfoBackingInfo: types.BaseConfigInfoBackingInfo{
                                            Datastore: types.ManagedObjectReference{Type:"Datastore", Value:"datastore-68"},
                                        },
                                        FilePath:        "[vsanDatastore] 879cd65e-6165-91a3-d047-02000359156d/cdde909c19b64305826a0e0e96fbdc06.vmdk",
                                        BackingObjectId: "4ac6fb5e-f617-2568-199f-020003bb3e3c",
                                        Parent:          nil,
                                        DeltaSizeInMB:   0,
                                        KeyId:           (*types.CryptoKeyId)(nil),
                                    },
                                    ProvisioningType: "thin",
                                },
                                Iofilter: nil,
                            },
                            CapacityInMB:    5120,
                            ConsumptionType: []string{"disk"},
                            ConsumerId:      nil,
                        },
                    },
                },
            },
            &types.CnsQueryVolumeInfoResult{
                CnsVolumeOperationResult: types.CnsVolumeOperationResult{},
                VolumeInfo:               &types.CnsBlockVolumeInfo{
                    CnsVolumeInfo:  types.CnsVolumeInfo{},
                    VStorageObject: types.VStorageObject{
                        Config: types.VStorageObjectConfigInfo{
                            BaseConfigInfo: types.BaseConfigInfo{
                                Id: types.ID{
                                    Id: "c2c2d2bb-f864-4e4f-9bde-39ca6b1302b6",
                                },
                                Name:                        "pvc-901e87eb-c2bd-11e9-806f-005056a0c9a0",
                                CreateTime:                  time.Now(),
                                KeepAfterDeleteVm:           types.NewBool(true),
                                RelocationDisabled:          types.NewBool(false),
                                NativeSnapshotSupported:     types.NewBool(false),
                                ChangedBlockTrackingEnabled: types.NewBool(false),
                                Backing:                     &types.BaseConfigInfoDiskFileBackingInfo{
                                    BaseConfigInfoFileBackingInfo: types.BaseConfigInfoFileBackingInfo{
                                        BaseConfigInfoBackingInfo: types.BaseConfigInfoBackingInfo{
                                            Datastore: types.ManagedObjectReference{Type:"Datastore", Value:"datastore-68"},
                                        },
                                        FilePath:        "[vsanDatastore] 879cd65e-6165-91a3-d047-02000359156d/a1feda38c5ca4f9d9e63721b8fbaeb83.vmdk",
                                        BackingObjectId: "acbcfb5e-1d86-55b1-932c-020003e15f4d",
                                        Parent:          nil,
                                        DeltaSizeInMB:   0,
                                        KeyId:           (*types.CryptoKeyId)(nil),
                                    },
                                    ProvisioningType: "thin",
                                },
                                Iofilter: nil,
                            },
                            CapacityInMB:    10240,
                            ConsumptionType: []string{"disk"},
                            ConsumerId:      nil,
                        },
                    },
                },
            },
            &types.CnsQueryVolumeInfoResult{
                CnsVolumeOperationResult: types.CnsVolumeOperationResult{},
                VolumeInfo:               &types.CnsBlockVolumeInfo{
                    CnsVolumeInfo:  types.CnsVolumeInfo{},
                    VStorageObject: types.VStorageObject{
                        Config: types.VStorageObjectConfigInfo{
                            BaseConfigInfo: types.BaseConfigInfo{
                                Id: types.ID{
                                    Id: "6885ca7d-09a3-40f5-9706-475cbd479934",
                                },
                                Name:                        "pvc-60209158-c603-4534-85df-6d193490b5fa",
                                CreateTime:                  time.Now(),
                                KeepAfterDeleteVm:           types.NewBool(true),
                                RelocationDisabled:          types.NewBool(false),
                                NativeSnapshotSupported:     types.NewBool(false),
                                ChangedBlockTrackingEnabled: types.NewBool(false),
                                Backing:                     &types.BaseConfigInfoDiskFileBackingInfo{
                                    BaseConfigInfoFileBackingInfo: types.BaseConfigInfoFileBackingInfo{
                                        BaseConfigInfoBackingInfo: types.BaseConfigInfoBackingInfo{
                                            Datastore: types.ManagedObjectReference{Type:"Datastore", Value:"datastore-68"},
                                        },
                                        FilePath:        "[vsanDatastore] 879cd65e-6165-91a3-d047-02000359156d/ac0b516b5eb54abe890dae868ad36e4a.vmdk",
                                        BackingObjectId: "66a8e75e-c096-baad-99b6-020003df5b47",
                                        Parent:          nil,
                                        DeltaSizeInMB:   0,
                                        KeyId:           (*types.CryptoKeyId)(nil),
                                    },
                                    ProvisioningType: "thin",
                                },
                                Iofilter: nil,
                            },
                            CapacityInMB:    5120,
                            ConsumptionType: []string{"disk"},
                            ConsumerId:      nil,
                        },
                    },
                },
            },
        }

@divyenpatel
Copy link
Member Author

@SandeepPissay @chethanv28 please take a look

@SandeepPissay
Copy link
Contributor

/lgtm

@SandeepPissay
Copy link
Contributor

/approve

@chethanv28
Copy link
Contributor

Minor comments, otherwise lgtm-ish

@divyenpatel divyenpatel force-pushed the fix-QueryVolumeInfo branch from 0430f65 to a94b43a Compare June 30, 2020 23:32
@divyenpatel divyenpatel force-pushed the fix-QueryVolumeInfo branch from a94b43a to 12955a6 Compare June 30, 2020 23:43
@divyenpatel
Copy link
Member Author

@dougm Can you help merge this PR?

Copy link
Member

@dougm dougm left a comment

Choose a reason for hiding this comment

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

Thanks @divyenpatel

@dougm dougm merged commit a411671 into vmware:master Jul 1, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

CNS QueryVolumeInfo API does not return VolumeInfo for multiple Volumes when multiple volumeIDs are supplied
5 participants