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

Make license package more resilient to unexpected output #189

Merged
merged 4 commits into from
Oct 30, 2022

Conversation

puerco
Copy link
Member

@puerco puerco commented Oct 30, 2022

What type of PR is this?

/kind bug
/kind cleanup

What this PR does / why we need it:

This PR improves the licensing code to be more resilient when encountering unexpected license tags in the
classifier output. Since v2.0.0, [the classifier will now return a pseudo license tag when finding copyright information] in files. This caused our libraries to return an error when scanning files.

It also fixes another bug where the secondary license list was lost after scanning and classifying a file.

The verbosity of the licensing code has now been reduced to make it more understandable.

Which issue(s) this PR fixes:

Part of kubernetes/release#2729

Special notes for your reviewer:

/assign @jeremyrickard @xmudrii @cpanato

Does this PR introduce a user-facing change?

- Fixed a bug where the secondary license list returned by the classifier was not being returned
- Improved the licensing code to be more resilient to unexpected output from the classifier
- Licensing output is now less verbose. Use `--log-level=debug` to see all messages

When classifying a file, the list of secondary licenses was nil. We now return the
rest of the licenses detected by the classifier.

Signed-off-by: Adolfo García Veytia (Puerco) <[email protected]>
If the license classifier returned unknown licenses, the license
module returned an error. We now simply ignore them as we pull the
official SPDX licenses and we know which ones are correct.

Signed-off-by: Adolfo García Veytia (Puerco) <[email protected]>
As of v2.0.0, the license classifier returns "Copyright"
as one of the license tags. If we let it go the license module
will ignore it but it will write it to the debug output.
So we simply skip it.

Signed-off-by: Adolfo García Veytia (Puerco) <[email protected]>
This commit reduces the verbosity of the licensing code.  Messages are still
available when running with --log-level=debug.

Signed-off-by: Adolfo García Veytia (Puerco) <[email protected]>
@k8s-ci-robot k8s-ci-robot added the kind/bug Categorizes issue or PR as related to a bug. label Oct 30, 2022
@k8s-ci-robot k8s-ci-robot added the kind/cleanup Categorizes issue or PR as related to cleaning up code, process, or technical debt. label Oct 30, 2022
@k8s-ci-robot k8s-ci-robot added cncf-cla: yes Indicates the PR's author has signed the CNCF CLA. approved Indicates a PR has been approved by an approver from all required OWNERS files. size/M Denotes a PR that changes 30-99 lines, ignoring generated files. labels Oct 30, 2022
@puerco puerco changed the title License fix Make license package more resilient to unexpected output Oct 30, 2022
Copy link
Member

@cpanato cpanato left a comment

Choose a reason for hiding this comment

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

/lgtm

But i will add a
/hold

Would like to run some manual test
But if you already ran feel.free to lift

// as one of the license tags. If we let it go the license module
// will ignore it but it will write it to the debug output.
// So we simply skip it.
if match.Name == "Copyright" {
Copy link
Member

Choose a reason for hiding this comment

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

I was not sure if that was correct, i see now

@k8s-ci-robot k8s-ci-robot added do-not-merge/hold Indicates that a PR should not merge because someone has issued a /hold command. lgtm "Looks good to me", indicates that a PR is ready to be merged. labels Oct 30, 2022
@puerco
Copy link
Member Author

puerco commented Oct 30, 2022

The CLI runs. It should run in krel too as we're not changing anything that affects it. But I can only test it once this merges and we can run a build using someones branch

Copy link
Member

@xmudrii xmudrii 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

@jeremyrickard
Copy link
Member

/lgtm
/approve

@k8s-ci-robot
Copy link
Contributor

[APPROVALNOTIFIER] This PR is APPROVED

This pull-request has been approved by: cpanato, jeremyrickard, puerco, xmudrii

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:
  • OWNERS [cpanato,jeremyrickard,puerco]

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

@puerco
Copy link
Member Author

puerco commented Oct 30, 2022

@cpanato let me know when we can lift the hold to test krel 🚀

2 similar comments
@puerco
Copy link
Member Author

puerco commented Oct 30, 2022

@cpanato let me know when we can lift the hold to test krel 🚀

@puerco
Copy link
Member Author

puerco commented Oct 30, 2022

@cpanato let me know when we can lift the hold to test krel 🚀

@cpanato
Copy link
Member

cpanato commented Oct 30, 2022

/unhold

@k8s-ci-robot k8s-ci-robot removed the do-not-merge/hold Indicates that a PR should not merge because someone has issued a /hold command. label Oct 30, 2022
@cpanato
Copy link
Member

cpanato commented Oct 30, 2022

doing the update in krel and testing

@k8s-ci-robot k8s-ci-robot merged commit eaf47e5 into kubernetes-sigs:main Oct 30, 2022
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. cncf-cla: yes Indicates the PR's author has signed the CNCF CLA. kind/bug Categorizes issue or PR as related to a bug. kind/cleanup Categorizes issue or PR as related to cleaning up code, process, or technical debt. lgtm "Looks good to me", indicates that a PR is ready to be merged. size/M Denotes a PR that changes 30-99 lines, ignoring generated files.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants