Octopus.Client .Net Library Error: You must have at least one enabled healthy machine in the environment before deployment can proceed

Hi
I am having a problem with automating releases to Machines in an Octopus environment. I have a program in .net which uses the Octopus.Client Library however when it come to deploying a release to the Machine I receive the following error:
“ErrorMessage”: “There was a problem with your request.”,
“Errors”: “You must have at least one enabled healthy machine in the environment before deployment can proceed.”

By looking in our Octopus Deploy App I can see that the machine is healthy and we are able to manually deploy to the same machine in the Octopus Deploy App.

As attached is the script we use for installing the tentacle on the Machine. The Tentacle version is 3.1.2 and there is no errors in the connectivity history of the machine or in the Logs.

octoTentacle1.txt (2 KB)

It appears on the second attempt checking the health of the machine an error occurs:
Unable to write data to the transport connection: An existing connection was forcibly closed by the remote host.
Halibut.Transport.Protocol.ConnectionInitializationFailedException: Unable to write data to the transport connection: An existing connection was forcibly closed by the remote host. —> System.IO.IOException: Unable to write data to the transport connection: An existing connection was forcibly closed by the remote host. —> System.Net.Sockets.SocketException: An existing connection was forcibly closed by the remote host

Hi Sophie,

Thanks for reaching out. After your Powershell script adds the machine to Octopus, you need to wait 30-60 seconds for the Octopus server to try to communicate to the Tentacle to finally establish the connection (a health check).

Thanks,

Dalmiro

Hi Dalmiro

I have forced the program to wait for 2 minutes after the machine has been
registered with the Environment in Octopus Deploy before trying to deploy
to it. However I am still unable to deploy to with via the API.
The Error I am receiving is as follows:

“ErrorMessage”: “There was a problem with your request.”,
“Errors”: [
“There must be at least one enabled healthy machine to deploy to in the
environment\r\nOnce you have corrected these problems you can try
again.\r\nIf the problem is related to a variable you will need to update
the variables for this release or recreate the release for the changes to
take effect.\r\nIf the problem is related to the deployment process you
will need to create a new release for the changes to take effect.”
]

When trying to do the same task with Octopus.Client, I receive the
following error:

  • You must deploy to at least one machine in the environment
    Once you have corrected these problems you can try again.
    If the problem is related to a variable you will need to update the
    variables for this release or recreate the release for the changes to take
    effect.
    If the problem is related to the deployment process you will need to create
    a new release for the changes to take effect.

Thanks

Sophie Whelan - Developer

Black Pearl Mail
Ph +64 4 974 5537 | www.blackpearlmail.com

HI Sophie,

Have you double checked that after that 2min wait, the machine shows as healthy on the Environment? I’m assuming this is the only machine in that environment, correct?

You could trigger a health check using the API, and only deploy if the health check was successful. I’ve created a Powershell cmdlet that uses the API to run a health check. It shouldn’t be too hard to translate it to C#

https://github.com/Dalmirog/OctoPosh/blob/master/Scripts/Start-OctopusHealthCheck.ps1

Thanks,

Dalmiro

Hi

I have do have other machines in the environment, and yes I have ensured
that the health check returns healthy.
I have tried again to deploy to theses same machines (now not brand new)
and I still receive the same errors.
Is there a way to force the deployment?

Thanks

Sophie

Sophie Whelan - Developer

Black Pearl Mail
Ph +64 4 974 5537 | www.blackpearlmail.com

Hi Dalmiro,

I have played around some more, and looked at the requests made from the
Octopus Deploy app Api requests. I have copied what is in those calls and
now receive the error:

“ErrorMessage”: “There was a problem with your request.”,
“Errors”: [
“You must deploy to at least one machine in the environment\r\nOnce you
have corrected these problems you can try again.\r\nIf the problem is
related to a variable you will need to update the variables for this
release or recreate the release for the changes to take effect.\r\nIf the
problem is related to the deployment process you will need to create a new
release for the changes to take effect.”
]
}

I’m sure there is something simple I’m missing

Thanks

Sophie

Sophie Whelan - Developer

Black Pearl Mail
Ph +64 4 974 5537 | www.blackpearlmail.com

Hi Sophie,

Hhave you tried creating a new release as suggested by the error message? If this doesn’t help, I’m gonna need to see the API script that you are using to start the deployment.

Thanks,

Dalmiro

Hi Dalmiro

I retried, with a new release but still receive the same errors.
I have attached the methods I have been working on.

Thanks for all your help

Sophie

Sophie Whelan - Developer

Black Pearl Mail
Ph +64 4 974 5537 | www.blackpearlmail.com

octopus.cs (8 KB)

Hi Dalmiro,

Just checking if you received the attached c# methods and octopus API calls?

Thanks

Sophie

Sophie Whelan - Developer

Black Pearl Mail
Ph +64 4 974 5537 | www.blackpearlmail.com

Hi Sophie,

Sorry for the delay. I got the code, but I haven had a moment to check it so far.

I’m gonna try to check it tonight :slight_smile:

Dalmiro

Hi Sophie,

I’ve checked your code and noticed that for the release creation, you are creating the whole request string yourself, instead of creating the release using a release object. Try creating the release as shown on this script:

That example is in Powershell, but is uses the Octopus.client library and it shouldnt be too hard to translate to c#

Let me know how it goes

Dalmiro