diff --git a/api/v1beta1/conditions_const.go b/api/v1beta1/conditions_const.go index 6bc272f1d..bcc054364 100644 --- a/api/v1beta1/conditions_const.go +++ b/api/v1beta1/conditions_const.go @@ -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 ( diff --git a/pkg/services/hcloud/server/server.go b/pkg/services/hcloud/server/server.go index c42fe2861..10cf0aad2 100644 --- a/pkg/services/hcloud/server/server.go +++ b/pkg/services/hcloud/server/server.go @@ -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) + } + + 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",