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

Handle reports with missing result property #2696

Merged
merged 4 commits into from Nov 9, 2021

Conversation

AverageMarcus
Copy link
Contributor

Related issue

We experienced an issue where we had PolicyReports without a result property in their results. We're not 100% clear how this happened by my best guess is they were previously v1alpha1 and were converted to v1alpha2 incorrectly somehow.
The missing result property results in Kyverno crashing on startup due to a nil pointer. This change guards against that nil pointer to at least allow Kyverno to start up successfully.

Milestone of this PR

What type of PR is this

/kind bug

Proposed Changes

Proof Manifests

N/A

Checklist

  • I have read the contributing guidelines.
  • I have added tests that prove my fix is effective or that my feature works.
  • [] My PR contains new or altered behavior to Kyverno and
    • [] CLI support should be added my PR doesn't contain that functionality.
    • [] I have added or changed the documentation myself in an existing PR and the link is:
    • [] I have raised an issue in kyverno/website to track the doc update and the link is:
    • [] I have read the PR documentation guide and followed the process including adding proof manifests to this PR.

Further Comments

@MarcelMue MarcelMue self-assigned this Nov 8, 2021
MarcelMue
MarcelMue previously approved these changes Nov 8, 2021
Signed-off-by: Marcus Noble <github@marcusnoble.co.uk>
Signed-off-by: Marcus Noble <github@marcusnoble.co.uk>
Signed-off-by: Marcus Noble <github@marcusnoble.co.uk>
Signed-off-by: Marcus Noble <github@marcusnoble.co.uk>
@@ -225,3 +215,8 @@ func isDeletedPolicyKey(key string) (policyName, ruleName string, isDelete bool)

return "", "", false
}

func mapToStruct(in, out interface{}) error {
Copy link
Collaborator

Choose a reason for hiding this comment

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

Is mapToStruct an accurate name here? I don't have a better suggestion unfortunately 😅

Copy link
Collaborator

@MarcelMue MarcelMue left a comment

Choose a reason for hiding this comment

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

@realshuting This PR is a first step to using more strongly typed structs in the code. It saves us a lot type casting all over the place. We would like to do this in more places. Let's check in the next contributor meeting.

@MarcelMue MarcelMue merged commit 8690f8b into kyverno:main Nov 9, 2021
@realshuting
Copy link
Member

@realshuting This PR is a first step to using more strongly typed structs in the code. It saves us a lot type casting all over the place. We would like to do this in more places. Let's check in the next contributor meeting.

Sure.

fiunchinho pushed a commit to fiunchinho/kyverno that referenced this pull request Nov 11, 2021
* Handle reports with missing result property

Signed-off-by: Marcus Noble <github@marcusnoble.co.uk>

* Make use of type structs

Signed-off-by: Marcus Noble <github@marcusnoble.co.uk>

* Fix import

Signed-off-by: Marcus Noble <github@marcusnoble.co.uk>

* Fix cast from map to struct

Signed-off-by: Marcus Noble <github@marcusnoble.co.uk>
@JimBugwadia JimBugwadia added this to the Kyverno Release 1.5.2 milestone Nov 19, 2021
@realshuting realshuting added the milestone 1.5.2 PRs for 1.5.2release label Nov 30, 2021
realshuting pushed a commit to realshuting/kyverno that referenced this pull request Nov 30, 2021
* Handle reports with missing result property

Signed-off-by: Marcus Noble <github@marcusnoble.co.uk>

* Make use of type structs

Signed-off-by: Marcus Noble <github@marcusnoble.co.uk>

* Fix import

Signed-off-by: Marcus Noble <github@marcusnoble.co.uk>

* Fix cast from map to struct

Signed-off-by: Marcus Noble <github@marcusnoble.co.uk>
realshuting pushed a commit that referenced this pull request Nov 30, 2021
* Handle reports with missing result property

Signed-off-by: Marcus Noble <github@marcusnoble.co.uk>

* Make use of type structs

Signed-off-by: Marcus Noble <github@marcusnoble.co.uk>

* Fix import

Signed-off-by: Marcus Noble <github@marcusnoble.co.uk>

* Fix cast from map to struct

Signed-off-by: Marcus Noble <github@marcusnoble.co.uk>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
milestone 1.5.2 PRs for 1.5.2release
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

4 participants