Skip to content
This repository has been archived by the owner on Nov 9, 2020. It is now read-only.

Adds utility to reuse a single PowerShell session #1775

Merged
merged 2 commits into from
Aug 19, 2017

Conversation

venilnoronha
Copy link
Contributor

Description

This PR adds the powershell utility that reuses a single session to execute commands over the plugin's lifetime.

Tests

The test-e2e-windows target passes locally, and following is the tail'd output.

2017/08/18 00:02:38 Creating volume [option_volume_247591] with options [ -o access=read-write] on VM [10.162.24.4]
2017/08/18 00:04:31 Checking volume [clone_src_volume_582587 option_volume_917152 option_volume_363414 option_volume_867138 option_volume_259466 option_volume_886045 option_volume_461698 option_volume_571036 option_volume_842558 option_volume_327807 option_volume_247591] availability from VM [10.162.24.4]
2017/08/18 00:04:32 END: VolumeCreateTestSuite.TestValidOptions
2017/08/18 00:04:32 Destroying volume [clone_src_volume_582587 option_volume_917152 option_volume_363414 option_volume_867138 option_volume_259466 option_volume_886045 option_volume_461698 option_volume_571036 option_volume_842558 option_volume_327807 option_volume_247591]
OK: 5 passed
--- PASS: Test (318.41s)
PASS
ok  	github.com/vmware/vsphere-storage-for-docker/tests/e2e	318.415s
make: Leaving directory `/go/src/github.com/vmware/vsphere-storage-for-docker/client_plugin'

@msterin
Copy link
Contributor

msterin commented Aug 18, 2017

what's the impact on time consumption ?

powershell = "powershell"
diskNotFound = "DiskNotFound"
// maxDiskAttachWaitSec is the max time to wait for a disk to be attached.
// TODO: Reduce disk attach wait time once parallel disk identification
Copy link
Contributor

Choose a reason for hiding this comment

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

Do you plan to address this TODO in a follow-up PR? If not, can you please file an issue?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I've filed an issue in #1780.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I've updated the comment in 0653f74.

Copy link
Contributor

Choose a reason for hiding this comment

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

Addressing via #1991

if err != nil {
log.WithField("err", err).Fatal("Failed to create a PowerShell session")
fmt.Println("Failed to create a PowerShell session")
os.Exit(1)
Copy link
Contributor

Choose a reason for hiding this comment

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

Can this error be a temporary issue that can be recovered later? If the answer is yes, we should not exit the plugin. Instead, we can log the error, and retry in the next attempt. That means you may need to move this out of the init function.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Since this is happening in init, the Windows service itself will fail to start. Therefore, I suggest we still keep this as is.

Copy link
Contributor

@pshahzeb pshahzeb left a comment

Choose a reason for hiding this comment

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

Looks Good. See comments inline.

default:
log.WithFields(log.Fields{"err": err, "out": string(out)}).Warn("Couldn't emit error, continuing.. ")
log.WithFields(log.Fields{"err": err, "stdout": stdout,
Copy link
Contributor

Choose a reason for hiding this comment

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

log.Fields{"err": err
Is this gonna work in case where err isn't valid?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

There's a err != nil check, and it would print nil even if that wasn't in place.

"sync"

log "github.com/Sirupsen/logrus"
ps "github.com/gorillalabs/go-powershell"
Copy link
Contributor

Choose a reason for hiding this comment

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

A bit concerned about this usage. The last checkin was on Feb 6th. What other alternatives do we have?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Mark has approved use of that package. The package is very small in itself, so it shouldn't be of too much concern.

This commit adds the powershell utility that reuses a single session to
execute commands over the plugin's lifetime.
@venilnoronha
Copy link
Contributor Author

@msterin: @pshahzeb will be posting the stats.

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

6 participants