microsoft / vso-agent

Visual Studio Team Services and TFS agent for Mac OSX and Linux
MIT License
131 stars 57 forks source link

Linux to On-Prem: Task zip empty #190

Closed iano123 closed 8 years ago

iano123 commented 8 years ago

Hi,

I have installed vsoagent on RHEL6 with node 4.2.5.

When I start a build then it complains: Could not find task: _work/tasks/Maven/1.0.13/task.json I looked at the zip file in the same directory and it is empty (size 0).

Is there a way to solve this? We are offline, the server does not have any connection to internet and the vso agent is connected to tfs 2015

Jan

bryanmacfarlane commented 8 years ago

We were looking at a separate case yesterday with the same issue.

We think it's a name resolution issue. If you could help us confirm, that would be great.

What happens is the server sends an url to the agent for downloading the task (we download as build job demands). That url I think is based on what's in the notification field in the TFS admin console (that field represents what others know the server url to be - reachable by everyone because that's what we will put in emails etc...).

If the agent can't resolve the name in the url (let's say it's http://mytfsserver:8080 but you're addressing via ip or dns/hostname from Linux) then downloading the task fails and you end up with a 0 byte zip file on disk. You can delete _work/tasks and it will download again if the root issue is addressed. I have a bug to make it robust to failures (write to temp dir and rename etc...)

bryanmacfarlane commented 8 years ago

So - the action item is - look at the notification url in the admin console (and maybe the server url). Are those resolvable from your Linux machine? If not, a host file change to confirm the issue and don't forget to delete _work/tasks folder

bryanmacfarlane commented 8 years ago

We may have found the issue. Can you verify by commenting out part of a function

In agent/taskmanager.js at line 119, you see this function. Comment out the first check block

    TaskManager.prototype.getTaskDefinitionsUri = function () {
        var taskDefinitionsUri = this.executionContext.variables[cm.vars.systemTaskDefinitionsUri];
/*
        if (!taskDefinitionsUri) {
            taskDefinitionsUri = this.executionContext.variables[cm.vars.systemTfCollectionUri];
        }
*/
        if (!taskDefinitionsUri) {
            taskDefinitionsUri = this.executionContext.config.settings.serverUrl;
        }
        return taskDefinitionsUri;
    };
iano123 commented 8 years ago

I will need to check at work. (un)fortunatly I am off until tuesday.

the issue with the URL could be it. We have a port redirect over an F5. So TFS thinks it is on port 8080 while the agent is connected over port 80 to the F5. I believe the task should be downloaded from the location of the URL that you need to enter when connecting with the server, not via a property coming from the server. That would eliminate such an issue.

bryanmacfarlane commented 8 years ago

I agree. Should be the host from what you entered and relative path to task sent from server.

I will fix the bug I mentioned above and take a crack at using the host by Tuesday. Will reply when it's in. You'll want to stamp out a new agent. Read instructions because I also wrote docs specifically for on prem this week

bryanmacfarlane commented 8 years ago

I fixed this. Get a new agent. I would recommend installing the preview one (see instructions)

iano123 commented 8 years ago

Ok it seems to work!

bryanmacfarlane commented 8 years ago

Awesome. Thanks for confirming