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

🌱 Set condition to false if server resource unavailable #1394

Merged
merged 1 commit into from
Jul 25, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions api/v1beta1/conditions_const.go
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,10 @@ const (
ServerLimitExceededReason = "ServerLimitExceeded"
// ServerTypeNotFoundReason indicates that server type could not be found.
ServerTypeNotFoundReason = "ServerTypeNotFound"
// ServerResourceUnavailableReason indicates that server resource is unavailable.
ServerResourceUnavailableReason = "ServerResourceUnavailable"
// ServerPlacementErrorReason indicates placement error while creating server.
ServerPlacementErrorReason = "ServerPlacementError"
)

const (
Expand Down
32 changes: 26 additions & 6 deletions pkg/services/hcloud/server/server.go
Original file line number Diff line number Diff line change
Expand Up @@ -459,14 +459,34 @@ func (s *Service) createServer(ctx context.Context) (*hcloud.Server, error) {
clusterv1.ConditionSeverityError,
err.Error(),
)
record.Warnf(s.scope.HCloudMachine,
"FailedCreateHCloudServer",
"Failed to create HCloud server %s: %s",
s.scope.Name(),
err,

err = errors.Join(errServerCreateNotPossible, err)
Dhairya-Arora01 marked this conversation as resolved.
Show resolved Hide resolved
}

if hcloud.IsError(err, hcloud.ErrorCodeResourceUnavailable) {
conditions.MarkFalse(
s.scope.HCloudMachine,
infrav1.ServerCreateSucceededCondition,
infrav1.ServerResourceUnavailableReason,
clusterv1.ConditionSeverityWarning,
err.Error(),
)
return nil, errServerCreateNotPossible

err = errors.Join(errServerCreateNotPossible, err)
}

if hcloud.IsError(err, hcloud.ErrorCodePlacementError) {
conditions.MarkFalse(
s.scope.HCloudMachine,
infrav1.ServerCreateSucceededCondition,
infrav1.ServerPlacementErrorReason,
clusterv1.ConditionSeverityWarning,
err.Error(),
)

err = errors.Join(errServerCreateNotPossible, err)
}

record.Warnf(s.scope.HCloudMachine,
"FailedCreateHCloudServer",
"Failed to create HCloud server %s: %s",
Expand Down
Loading