Closed tasadar2 closed 6 years ago
Hello @tasadar2
Sorry for the inconvenience this is causing you.
The intention of the "Move-Item" is to move the installation of the Kiuwan Local Analyzer (KLA) to the agent root directory so it can be used in subsequent builds by that agent avoiding the overhead of downloading and installing the KLA every time.
This command:
C:\Windows\System32\WindowsPowerShell\v1.0\powershell.exe -command "Move-Item -Path 'C:\TfsData\Agent\12a2e36b-7948-4c20-b3d8-12754c3511d1\KiuwanLocalAnalyzer' -Destination 'C:\TfsData\Agent'
should just move the KiuwanLocalAnalyzer directory in the 12a2e36b-7948-4c20-b3d8-12754c3511d1 directory one directory up. The result should be a new directory C:\TfsData\Agent\KiuwanLocalAnalyzer it shouldn't remove any files in the C:\TfsData\Agent directory. The task doesn't do any clean up
I'm investigating the issue. I have already tried with my local TFS and an agent I have locally and couldn't reproduced it. Please share with me some more info about your setup:
In the case that you have control over the agent I can propose a work around until we find out where the problem is:
This will avoid the task downloading and installing the KLA so it doesn't need to do the Move-Item.
If there is no cleanup in the task, then I have to assume that TFS is responsible. I wonder if the specified toolPath for the Kiuwan Analyzer is being cleaned.
Troubleshooting
After looking through the code a bit, it looks like the environment variable Agent.TempDirectory
is being overridden to the Agent.HomeDirectory
. My bet is that TFS cleans the Agent.TempDirectory
during the cleanup phase at the end of the build. And if this set to the Agent.HomeDirectory
, then it will be cleaned instead.
Although the released version is newer than the source: https://github.com/kiuwan/tfs-vsts-extension/blob/master/baseline-analysis-task/index.ts#L242
I tried running a build with a sleep after the Kiuwan task, and sure enough, the directory structure is intact. It is only after the cleanup at the end of the build, that the directory/agent is removed.
Instead of overriding the Agent.TempDirectory
, I would suggest letting it download to the default temp location, caching the extracted directory, which copies the directory to the Agent/_work/_tool
directory. This is then registerred as a tool to be used later.
// Register tool
extPath = await ttl.cacheDir(extPath, 'KiuwanLocalAnalyzer', '2.1.2');
// Lookup tool
let klaInstallPath = ttl.findLocalTool('KiuwanLocalAnalyzer', '2.1.2');
if (!klaInstallPath) {
klaInstallPath = downloadInstallKla(...)
}
Although the source seems older than the task's code, https://github.com/kiuwan/tfs-vsts-extension/pull/3
Environment This is a local instance of TFS with as local agent. We are testing it locally before installing it in our on-premise TFS Test environment.
Hi @tasadar2,
That seems to be the issue and your pull request should fix it.
We'll commit and merge your pull request. But you are right, the code here is older than the currently published extension. There is a local branch pending to be pushed. We'll do that too so the master is current, making sure the the override of the Agent temp dir is gone from that branch and after running some tests.
Thank you.
Hi @tasadar2,
just committed a new version that extends oyur fix for the override of the temp directory. It brings the code up to date with the publish version of the extension in the marketplace. And adds some refactoring to avoid duplication of code.
If you test the new version of the extension in your local TFS please, let us know if it works as expected now so we can close the issue.
Thanks.
Looks like that fixed it.
Issue After running a build with the Kiuwan VSTS task, the VSTS agent involved crashes. When digging into why it crashed, we found that most of the file/folder structure for the agent has been deleted. We have attempted multiple builds to confirm, and each time the Kiuwan task is run, regardless of the build, the agent that runs the task is no longer in a usable state.
Based on the logs and the result, my guess is that the task attempts to clean the directory Kiuwan was downloaded to, but might be using one directory too high in the directory hierarchy. Namely these lines from the Kiuwan build task log
Steps to Reproduce Queue a build with the Kiuwan VSTS build task.
Observations
Log from Kiuwan task
VSTS Agent log This is a snippet from the VSTS agent log regarding the build with the Kiuwan task.