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

Add SkipInitialHealthCheck flag to MachineBasedResource #850

Merged
merged 2 commits into from
May 20, 2024

Conversation

scme0
Copy link
Contributor

@scme0 scme0 commented May 17, 2024

Background

There are a few tests in Server which use Octopus.Server.Client to create machines but they don't want background processes like HealthChecks to run. Adding this property allows us to skip the initial health check when adding a machine to make testing easier, more stable and decrease the load on the server running in the test.

Results

In the Client all we have to do is add the additional property. The server PR (https://github.com/OctopusDeploy/OctopusDeploy/pull/24785) will handle this flag and ensure an initial health check isn't executed if the flag is true.

@@ -51,5 +50,8 @@ public abstract class MachineBasedResource : Resource, INamedResource, IHaveSlug
public string Architecture { get; set; }

public string Slug { get; set; }

[Writeable]
public bool SkipInitialHealthCheck { get; set; }
Copy link
Contributor Author

Choose a reason for hiding this comment

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

The only way I could get this information through the Client is by adding it to the MachineBasedResource. I don't love this but I also feel like the benefits outweigh the drawbacks in this case. Most people won't even care about this property.

I did consider adding a code comment above it to explain that it's only used when creating a new Machine (Deployment Target or Worker).

Copy link
Contributor Author

Choose a reason for hiding this comment

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

@APErebus I'm interested in your opinion on this.

Copy link
Contributor

@APErebus APErebus May 17, 2024

Choose a reason for hiding this comment

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

Do workers also have this initial health-check?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Yes, I believe they do, Although your comment made me realise I forgot to update the CreateWorkerCommandHandler in server.

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 Server codebase to also pass this flag down when a worker is created.

It's interesting that the same test doesn't fail very often (it has failed the same way once) when it uses a worker instead of a deployment target. I believe this is because there is a second level of indirection with the event that causes a health check after creating a worker.

When you create a worker a MachineCreatedDomainEvent is created which is handled in MachineCreatedDomainEventMapper. This mapper returns a MachineCreatedEventV2 which is the same event directly raised when creating a deployment target.

@APErebus APErebus merged commit 96566ff into master May 20, 2024
17 checks passed
@APErebus APErebus deleted the scme/add-skiphcf branch May 20, 2024 02:22
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants