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

🌱 Deprecate obsolete errors pkg #10798

Merged

Conversation

enxebre
Copy link
Member

@enxebre enxebre commented Jun 25, 2024

The /errors package has its origin in when capi providers were machineActuators that needed to vendor core capi to function. There's no usage recommendations and value is questionable since we moved to CRDs and conditions for interoperability between core and providers. I think we should deprecate it and if there's any use case relying on it we should support it via conditions

What this PR does / why we need it:

Which issue(s) this PR fixes (optional, in fixes #<issue number>(, fixes #<issue_number>, ...) format, will close the issue(s) when PR gets merged):
Fixes #10784

@k8s-ci-robot k8s-ci-robot added the do-not-merge/needs-area PR is missing an area label label Jun 25, 2024
@k8s-ci-robot k8s-ci-robot added size/XS Denotes a PR that changes 0-9 lines, ignoring generated files. cncf-cla: yes Indicates the PR's author has signed the CNCF CLA. labels Jun 25, 2024
@enxebre enxebre changed the title Deprecate obsolete errors pkg 🌱 Deprecate obsolete errors pkg Jun 25, 2024
errors/doc.go Outdated Show resolved Hide resolved
@enxebre enxebre force-pushed the deprecate-root-errors-pkg branch 2 times, most recently from 0b6a1c2 to c22f1e1 Compare June 25, 2024 14:45
Copy link
Contributor

@killianmuldoon killianmuldoon left a comment

Choose a reason for hiding this comment

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

/lgtm

@k8s-ci-robot k8s-ci-robot added the lgtm "Looks good to me", indicates that a PR is ready to be merged. label Jun 25, 2024
@k8s-ci-robot
Copy link
Contributor

LGTM label has been added.

Git tree hash: 175a6cc5d9ea0c04b43946305ac3f18b0d933267

@fabriziopandini
Copy link
Member

Am I wrong or MachineError is still used in the machine controller?

@enxebre
Copy link
Member Author

enxebre commented Jun 27, 2024

Am I wrong or MachineError is still used in the machine controller?

I can't find any MachineError struct usage. The type MachineStatusError is used for the failureReason

FailureReason *capierrors.MachineStatusError `json:"failureReason,omitempty"`

machineStatusError := capierrors.MachineStatusError(failureReason)

We also use the InvalidConfigurationMachineError wrapper here

m.Status.FailureReason = ptr.To(capierrors.InvalidConfigurationMachineError)

These are known importers https://pkg.go.dev/sigs.k8s.io/cluster-api/errors?tab=importedby.

I think we can keep MachineStatusError type and deprecate and drop all the others unused wrappers and funcs. Or still deprecate MachineStatusError as well but don't drop it until next api bump reconsideration.

@k8s-ci-robot k8s-ci-robot added the needs-rebase Indicates a PR cannot be merged because it has merge conflicts with HEAD. label Jul 19, 2024
@fabriziopandini
Copy link
Member

Double checked this and you are correct.
PR lgtm after rebase

@fabriziopandini
Copy link
Member

/area util

(note, no rush at all to get this into the 1.8 release)

@k8s-ci-robot k8s-ci-robot added area/util Issues or PRs related to utils and removed do-not-merge/needs-area PR is missing an area label labels Aug 2, 2024
@k8s-ci-robot k8s-ci-robot removed the lgtm "Looks good to me", indicates that a PR is ready to be merged. label Aug 28, 2024
@k8s-ci-robot k8s-ci-robot removed the needs-rebase Indicates a PR cannot be merged because it has merge conflicts with HEAD. label Aug 28, 2024
@enxebre
Copy link
Member Author

enxebre commented Aug 28, 2024

rebased now cc @fabriziopandini

@@ -33,3 +33,4 @@ maintainers of providers and consumers of our Go API.
- To support Kubernetes 1.31, providers should stop setting caBundle to invalid values in there CRDs (see core CAPI PR: https://github.com/kubernetes-sigs/cluster-api/pull/10972)
Setting caBundle to `Cg==` is a pattern that is widely spread across the ecosystem but it will stop working with Kubernetes 1.31.
Please see the following Slack thread for details: https://kubernetes.slack.com/archives/C0EG7JC6T/p1722441161968339
- The Errors package [has been deprecated in v1.8](https://github.com/kubernetes-sigs/cluster-api/issues/10784). It's recommented to remove any usage of the currently exported variables.
Copy link
Member

Choose a reason for hiding this comment

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

This should go in migrations/v1.9-to-v1.9.md now 😅

@k8s-ci-robot k8s-ci-robot added size/S Denotes a PR that changes 10-29 lines, ignoring generated files. and removed size/XS Denotes a PR that changes 0-9 lines, ignoring generated files. labels Sep 2, 2024
@enxebre
Copy link
Member Author

enxebre commented Sep 2, 2024

Thanks Fabrizio, updated the doc.


### Suggested changes for providers

- The Errors package [has been deprecated in v1.8](https://github.com/kubernetes-sigs/cluster-api/issues/10784). It's recommented to remove any usage of the currently exported variables.
Copy link
Member

@sbueringer sbueringer Sep 2, 2024

Choose a reason for hiding this comment

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

I think it would be good to provide some more context.

If I understand this correctly we are basically deprecating and eventually removing the types used for FailureReason.

This means that providers have to stop using them in their API types and instead use conditions correct? (can we give them some more details what they should do instead & that the concept of "terminal failure" will go away)

(a deprecation without some hints about what to do instead is just not ideal)

Copy link
Member Author

Choose a reason for hiding this comment

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

Updated! Let me know if that works.


### Suggested changes for providers

- The Errors package was created when capi provider implementation was running as machineActuators that needed to vendor core capi to function. There is no usage recommendations today and its value is questionable since we moved to CRDs that inter-operate mostly via conditions. Instead we plan to drop the dedicated semantic for terminal failure and keep improving Machine lifecycle signal through conditions. Therefore the Errors package [has been deprecated in v1.8](https://github.com/kubernetes-sigs/cluster-api/issues/10784). It's recommented to remove any usage of the currently exported variables.
Copy link
Member

Choose a reason for hiding this comment

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

The Errors package was created when capi provider implementation was running as machineActuators that needed to vendor core capi to function. There is no usage recommendations today

Just to avoid misunderstandings (and to ensure we're talking about the same thing)

MachineStatusError & ClusterStatusError are types used in our API and they are both used to read the corresponding fields from InfrastructureCluster & InfrastructureMachine (e.g.:

failureReason, failureMessage, err := external.FailuresFrom(obj)
if err != nil {
return external.ReconcileOutput{}, err
}
if failureReason != "" {
machineStatusError := capierrors.MachineStatusError(failureReason)
m.Status.FailureReason = &machineStatusError
)

So as of right now, they are even part of our contract (vs. "no usage recommendation").
But this will be deprecated with #10897 and then removed with v1beta2.

Correct?

Copy link
Member

Choose a reason for hiding this comment

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

Copy link
Member Author

Choose a reason for hiding this comment

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

That's what I'm proposing yes. The whole package mostly got obsolete and unused when we move to CRDs, conditions and continuous reconciliation flow vs create/update. An even more as we move towards dropping existing terminal failure signal in favour of fleshed out conditions now.
If we need to have specific machine error types for v1beta2 I think we should redefine then when the time comes, but those will most likely come as conditions reasons. My intent with this PR is mainly to avoid confusion and perpetuating a dead end pattern e.g. https://github.com/kubernetes-sigs/cluster-api/pull/10360/files

Copy link
Member

Choose a reason for hiding this comment

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

Sounds good!

Copy link
Member

Choose a reason for hiding this comment

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

+1

@sbueringer
Copy link
Member

/lgtm

@k8s-ci-robot k8s-ci-robot added the lgtm "Looks good to me", indicates that a PR is ready to be merged. label Sep 2, 2024
@k8s-ci-robot
Copy link
Contributor

LGTM label has been added.

Git tree hash: dba0e84689985dacf194c6f09e86dbe07d5c1be9

Copy link
Member

@fabriziopandini fabriziopandini left a comment

Choose a reason for hiding this comment

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

/lgtm
/approve

@k8s-ci-robot
Copy link
Contributor

[APPROVALNOTIFIER] This PR is APPROVED

This pull-request has been approved by: fabriziopandini

The full list of commands accepted by this bot can be found here.

The pull request process is described here

Needs approval from an approver in each of these files:

Approvers can indicate their approval by writing /approve in a comment
Approvers can cancel approval by writing /approve cancel in a comment

@k8s-ci-robot k8s-ci-robot added the approved Indicates a PR has been approved by an approver from all required OWNERS files. label Sep 3, 2024
@fabriziopandini
Copy link
Member

/test pull-cluster-api-verify-main

@fabriziopandini
Copy link
Member

@enxebre not 100% why the job is failing, might be the PR needs a rebase 🤔

@sbueringer
Copy link
Member

It needs a fix for: Didn't find developer/providers/migrations/v1.8-to-v1.9.md in SUMMARY.md

@k8s-ci-robot k8s-ci-robot removed the lgtm "Looks good to me", indicates that a PR is ready to be merged. label Sep 4, 2024
The /errors package has its origin in when capi providers were machineActuators that needed to vendor core capi to function.
There's no usage recommendations and value is questionable since we moved to CRDs and conditions for interoperability between core and providers.
I think we should deprecate it and if there's any use case relying on it we should support it via conditions
@sbueringer
Copy link
Member

Thx!
/lgtm

@k8s-ci-robot k8s-ci-robot added the lgtm "Looks good to me", indicates that a PR is ready to be merged. label Sep 4, 2024
@k8s-ci-robot
Copy link
Contributor

LGTM label has been added.

Git tree hash: 131f2a9865480ad313c3b9e1c04f950ecc53717e

@k8s-ci-robot k8s-ci-robot merged commit 50a0714 into kubernetes-sigs:main Sep 4, 2024
20 checks passed
@k8s-ci-robot k8s-ci-robot added this to the v1.9 milestone Sep 4, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
approved Indicates a PR has been approved by an approver from all required OWNERS files. area/util Issues or PRs related to utils cncf-cla: yes Indicates the PR's author has signed the CNCF CLA. lgtm "Looks good to me", indicates that a PR is ready to be merged. size/S Denotes a PR that changes 10-29 lines, ignoring generated files.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Deprecate ancient errors/ package
5 participants