Skip to content

Conversation

@guettli
Copy link
Collaborator

@guettli guettli commented Nov 27, 2025

Some changes of this PR got extracted, so that the PR gets smaller and easier to review:

🌱 Remove usage of FailureReason and FailureMessage (baremetal) by guettli · Pull Request #1716 · syself/cluster-api-provider-hetzner

  • Add/extended comments to some parts.
  • move rate-limit handling code up, to return early if rate-limit is active.
  • avoid usage of capierrors package.
  • test code: Align capi-machine name and infra-machine name. Remediation code depends on that capi feature.
  • tee tmp/test-unit-unfiltered.log in test-unis.sh: Write unmodfied output to tmp directory. This is handy if you want to see all logs, without running tests again.
  • export func GetAssociatedHost(), so that it can be re-used.
  • refactored getAssociatedHost() to getAssociatedHostAndPatchHelper(), so that the code can be re-used.
  • add log when hbmm is deleting.
  • avoid duplicate implemenation of splitHostKey()
  • refactored setOwnerRemediatedConditionNew() to setOwnerRemediatedConditionToFailed()
  • removed named return parameters: return res, nil --> return reconcile.Result{}, nil

@github-actions github-actions bot added size/L Denotes a PR that changes 200-800 lines, ignoring generated files. area/hack Changes made in the hack directory area/code Changes made in the code directory area/api Changes made in the api directory labels Nov 27, 2025
@guettli guettli requested a review from janiskemper November 27, 2025 12:48
Copy link
Contributor

@janiskemper janiskemper left a comment

Choose a reason for hiding this comment

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

I didn't fully understand the remediation part. Please add some explanation for the refactoring in the PR description

host.Spec.Status.ProvisioningState, host.Spec.MaintenanceMode != nil && *host.Spec.MaintenanceMode,
)
return res, nil
if host == nil {
Copy link
Contributor

Choose a reason for hiding this comment

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

can this happen? We handle the not found error... at least it wouldn't make sense

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

@janiskemper, yes, it can be nil:

func GetAssociatedHost(ctx context.Context, crClient client.Client, hbmm *infrav1.HetznerBareMetalMachine) (*infrav1.HetznerBareMetalHost, error) {
	annotations := hbmm.GetAnnotations()
	// if no annotations exist on machine, no host can be associated
	if annotations == nil {
		return nil, nil
	}

Copy link
Contributor

Choose a reason for hiding this comment

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

okay, but that's weird for that GetAssociatedHost function no? Then we should probably directly handle the not found error and convert it to nil.

Or is there any reason that the function returns in two ways the same thing?

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

@janiskemper I just refactored the method, so that it could be re-used. It was like this before. For now, I would like to keep it like this. But I could change it, if you think so.

Copy link
Contributor

Choose a reason for hiding this comment

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

I would like to change it. Before, it was not a library function, so it was clear from the inline code. Right now, with having this in a separate package, that looks strange.

@guettli
Copy link
Collaborator Author

guettli commented Nov 27, 2025

I didn't fully understand the remediation part. Please add some explanation for the refactoring in the PR description

can you please point me to a line in the code?

@guettli guettli requested a review from janiskemper November 27, 2025 15:49
@janiskemper
Copy link
Contributor

@guettli I didn't understand the reason for this part "refactored setOwnerRemediatedConditionNew() to setOwnerRemediatedConditionToFailed()"

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

area/api Changes made in the api directory area/code Changes made in the code directory area/hack Changes made in the hack directory size/L Denotes a PR that changes 200-800 lines, ignoring generated files.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants