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

correct SetControlFlags and ClearControlFlags APIs #2864

Merged
merged 1 commit into from
Jun 1, 2022

Conversation

divyenpatel
Copy link
Member

@divyenpatel divyenpatel commented Jun 1, 2022

Description

This PR is correcting SetControlFlags and ClearControlFlags APIs to supply Volume ID.
When we call these APIs without Volume ID, APIs fail with ServerFaultCode: VolumeId is empty.

Please mark options that are relevant:

  • Bug fix (non-breaking change which fixes an issue)

How Has This Been Tested?

Created VMDK and executed tests

% go test -v
=== RUN   TestClient
    client_test.go:60: Successfully registered disk with path https://10.187.116.17/folder/29be9662-ce3c-0818-fd35-0200ad8e5983/test-disk.vmdk?dcPath=VSAN-DC&dsName=vsanDatastore as FCD with storage object id e60716d1-6447-4041-9b2a-ca45bebbdd35
    client_test.go:91: Creating volume using the spec: types.CnsVolumeCreateSpec{
            Name:       "pvc-abc123",
            VolumeType: "BLOCK",
            Datastores: nil,
            Metadata:   types.CnsVolumeMetadata{
                ContainerCluster: types.CnsContainerCluster{
                    ClusterType:         "KUBERNETES",
                    ClusterId:           "demo-cluster-id",
                    VSphereUser:         "Administrator@vsphere.local",
                    ClusterFlavor:       "VANILLA",
                    ClusterDistribution: "KUBERNETES",
                },
                EntityMetadata:        nil,
                ContainerClusterArray: nil,
            },
            BackingObjectDetails: &types.CnsBlockBackingDetails{
                CnsBackingObjectDetails: types.CnsBackingObjectDetails{
                    CapacityInMb: 5120,
                },
                BackingDiskId:       "e60716d1-6447-4041-9b2a-ca45bebbdd35",
                BackingDiskUrlPath:  "",
                BackingDiskObjectId: "",
            },
            Profile:      nil,
            CreateSpec:   nil,
            VolumeSource: nil,
        }
    client_test.go:117: volumeCreateResult &{CnsVolumeOperationResult:{DynamicData:{} VolumeId:{DynamicData:{} Id:e60716d1-6447-4041-9b2a-ca45bebbdd35} Fault:<nil>} Name:pvc-abc123 PlacementResults:[]}
    client_test.go:118: Volume created sucessfully. volumeId: e60716d1-6447-4041-9b2a-ca45bebbdd35
    client_test.go:124: Control flag: FCD_KEEP_AFTER_DELETE_VM set for the volumeId: e60716d1-6447-4041-9b2a-ca45bebbdd35
    client_test.go:129: Control flags removed the volumeId: e60716d1-6447-4041-9b2a-ca45bebbdd35
--- PASS: TestClient (10.64s)
PASS
ok      github.com/vmware/govmomi/vslm  10.830s

snap

This PR is required for kubernetes-sigs/vsphere-csi-driver#1762

cc: @chethanv28 @bandyopadhyays-vmware

dougm
dougm previously approved these changes Jun 1, 2022
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.

lgtm. I don't know what's causing the linter action to fail though cc @embano1
https://github.com/vmware/govmomi/runs/6681587156?check_suite_focus=true

@embano1
Copy link
Contributor

embano1 commented Jun 1, 2022

Yup, linter is complaining about the order of imports. Just run the proposed command from the failure execution accordingly to format the code.

chethanv28
chethanv28 previously approved these changes Jun 1, 2022
Comment on lines 23 to 28
"github.com/dougm/pretty"

"github.com/vmware/govmomi"
"github.com/vmware/govmomi/cns"
cnstypes "github.com/vmware/govmomi/cns/types"
"github.com/vmware/govmomi/vim25/soap"
"github.com/vmware/govmomi/vim25/types"
Copy link
Contributor

Choose a reason for hiding this comment

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

Please fix linter errors

Copy link
Member Author

Choose a reason for hiding this comment

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

fixed linter issue

% golangci-lint run -v --fast=false        
INFO [config_reader] Config search paths: [./ /Users/divyenp/go/src/github.com/divyenpatel/govmomi /Users/divyenp/go/src/github.com/divyenpatel /Users/divyenp/go/src/github.com /Users/divyenp/go/src /Users/divyenp/go /Users/divyenp /Users /] 
INFO [config_reader] Used config file .golangci.yml 
INFO [lintersdb] Active 2 linters: [goimports govet] 
INFO [loader] Go packages loading at mode 575 (compiled_files|deps|imports|types_sizes|exports_file|files|name) took 1.103482096s 
INFO [runner/filename_unadjuster] Pre-built 0 adjustments in 105.520716ms 
INFO [linters context/goanalysis] analyzers took 0s with no stages 
INFO [runner/skip dirs] Skipped 2 issues from dir cns/types by pattern cns/types 
INFO [runner] Issues before processing: 19, after processing: 0 
INFO [runner] Processors filtering stat (out/in): exclude: 17/17, filename_unadjuster: 19/19, skip_dirs: 17/19, autogenerated_exclude: 17/17, identifier_marker: 17/17, exclude-rules: 17/17, nolint: 0/17, cgo: 19/19, path_prettifier: 19/19, skip_files: 19/19 
INFO [runner] processing took 2.894046ms with stages: nolint: 934.182µs, exclude-rules: 816.604µs, autogenerated_exclude: 665.116µs, identifier_marker: 303.128µs, path_prettifier: 109.216µs, skip_dirs: 53.233µs, cgo: 5.092µs, filename_unadjuster: 3.253µs, max_same_issues: 1.091µs, uniq_by_line: 630ns, skip_files: 364ns, source_code: 320ns, max_from_linter: 290ns, diff: 277ns, exclude: 230ns, path_prefixer: 222ns, severity-rules: 221ns, sort_results: 198ns, path_shortener: 194ns, max_per_file_from_linter: 185ns 
INFO [runner] linters took 634.801611ms with stages: goanalysis_metalinter: 631.844527ms 
INFO File cache stats: 0 entries of total size 0B 
INFO Memory: 20 samples, avg is 73.2MB, max is 74.1MB 
INFO Execution took 1.85445765s 

Copy link
Contributor

@embano1 embano1 left a comment

Choose a reason for hiding this comment

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

Just linter errors need to be fixed

Copy link
Contributor

@embano1 embano1 left a comment

Choose a reason for hiding this comment

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

LGTM!

@embano1
Copy link
Contributor

embano1 commented Jun 1, 2022

Just noticed your commit message doesn't have a prefix, so it won't show up in the release notes section. Is this API related? If so, and if you want, please prefix the commit title with api: 🙏

Happy to merge otherwise

@divyenpatel divyenpatel merged commit 0f1f07e into vmware:master Jun 1, 2022
@divyenpatel
Copy link
Member Author

Just noticed your commit message doesn't have a prefix, so it won't show up in the release notes section. Is this API related? If so, and if you want, please prefix the commit title with api: 🙏

Happy to merge otherwise

Thanks @embano1 I will follow this in the next commit.

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.

5 participants