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

Release notes mappings libraries and in krel release-notes #1373

Merged
merged 5 commits into from
Jul 27, 2020

Conversation

puerco
Copy link
Member

@puerco puerco commented Jun 22, 2020

What type of PR is this?

/kind feature

What this PR does / why we need it:

This is the first effort to add the capability to process mapping files to the release notes package.

The release notes mapping files (format is detailed below) will allow expanding the information in release notes in two ways:

  • Modifying original data: The map can supersede release note data defined in the original pull request by overriding certain fields in a file which will eventually end up in the release notes document.

  • Adding new fields of information: A map file can define new data structures which can be associated with the release note to add more information to the release note. Current plans include adding security information and a quality score.

Mapping files can come from a variety of sources. This PR adds a new interface MapProvider whose job is to obtain and parse map files. MapProviders can be written to collect release notes files from a variety of sources: reading from a directory (a proof of concept is included), a bucket, a private GitHub repo, an encrypted archive, etc.

The krel release-notes subcommand has been modified with a new --maps-from flag to enable MapProviders when generating release notes. For example, to invoke it with a DirectoryMapProvider we would use the following flags

krel release-notes --create-website-pr --tag v1.19.beta.2 \
   --maps-from=/notes-maps/
# With an hypothetical provider for a bucket
krel release-notes --create-website-pr --tag v1.19.beta.2 \
   --maps-from=gs://k8s-release-notes-bucket

When MapProviders are active, the notes gatherer will query the provider for mappings for a specific note when generating it. Using a new method ApplyMap() the gatherer will modify the release note with data from the map.

The proposed map file format has two parts: one that overrides the original release note data and one that adds data fields, which are free-form data structures keyed in associative array fashion by a keyword. An example:

---
pr:  123
commit: 1a89038915fe77d73bf7c9cfa8f2ce123a464c82
release-note:  
  text: Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. 
  author: kubernetes-ci-robot
  areas:
    - testarea
  kinds:
    - documentation
  sigs:
    - api-machinery
  feature: true
  action_required: false
  release_version: v1.18.4
  documentation:
    - description: Test documentation
      url: https://wkdkjdjkdkfj
      type: kep
datafields:
  # Score is a simple float
  score: 5.2
  # CVE data is a full blown struct
  cve:
    id: CVE-2019-1010260
    description: Really bad SSRF in KCM
    published: 2020-10-05
    issues:
    - 9876
    - 9875

Which issue(s) this PR fixes:

Related to

Special notes for your reviewer:

This PR is a proof of concept, should run but is still untested.

I've provided a few sample maps in pkg/notes/maps/testdata/ to illustrate the format and its capabilities.

A simple implementation of a MapProvider is included in this PR: DirectoryMapProvider. This MapProvider is the simplest provider possible: it reads a directory, looking for yaml files and tries to open them as release notes maps.

Does this PR introduce a user-facing change?

* New capability in release notes pkg to read map files which can modify release notes data and add new, arbitrary fields.
* Function `ApplyMap()` was added to `ReleasNote`  type to enable it to get a map and modify itself
* New interface `MapProvider` which gets release notes map files
* New flag in `krel release-notes` to enable map providers: `--maps-from` 

@k8s-ci-robot k8s-ci-robot added do-not-merge/work-in-progress Indicates that a PR should not merge because it is a work in progress. release-note Denotes a PR that will be considered when it comes time to generate release notes. cncf-cla: yes Indicates the PR's author has signed the CNCF CLA. needs-kind Indicates a PR lacks a `kind/foo` label and requires one. needs-priority size/L Denotes a PR that changes 100-499 lines, ignoring generated files. labels Jun 22, 2020
@k8s-ci-robot k8s-ci-robot added the sig/release Categorizes an issue or PR as relevant to SIG Release. label Jun 22, 2020
@puerco
Copy link
Member Author

puerco commented Jun 22, 2020

/assign @saschagrunert
/hold

@k8s-ci-robot k8s-ci-robot added the do-not-merge/hold Indicates that a PR should not merge because someone has issued a /hold command. label Jun 22, 2020
Copy link
Member

@saschagrunert saschagrunert left a comment

Choose a reason for hiding this comment

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

Good good, I added some notes on the general design that we can agree on an overall direction. 👍

url: https://wkdkjdjkdkfj
type: kep
datafields:
score: 5.2
Copy link
Member

Choose a reason for hiding this comment

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

The score should be part of the cve

Copy link
Member Author

Choose a reason for hiding this comment

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

You're right. I thought this was the ML quality score.

The idea was to illustrate a different field. In this case the ML quality score. While cve data would be a whole struct this is only a float .

Copy link
Member

@saschagrunert saschagrunert Jun 23, 2020

Choose a reason for hiding this comment

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

Okay, I guess we do not have to add anything related to ML for now. In any case I guess the CVE needs a score. The idea was to highlight high impact CVE's or sort them by severity.

(I was thinking about being able to link multiple PRs together, so we could add something like linkedPRs. The overall implementation might be a bit complicated, but features made of multiple PRs are a common use-case in Kubernetes.)

Copy link
Member Author

Choose a reason for hiding this comment

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

I've added more (hypothetical) examples to the fullmap.yaml file and updated the cve field. Although right now i'm only adjusting how the data would fit in the map. Once we settle how we inject the new fields we can decide on the actual formats for the fields and how they would render.

@puerco
Copy link
Member Author

puerco commented Jun 22, 2020

Thanks for your review @saschagrunert this is precisely what I was hoping for, laying out a bit of code to kick start the design discussion 😀

@puerco
Copy link
Member Author

puerco commented Jun 24, 2020

Hey sascha, I've pushed a new prototype addressing the following:

  1. Flags have been updated as we discussed:
    --maps-from=/path/ will create a provider to read a directory to get yaml files. I added a demo hook for a CloudStorageProvider to demonstrate how/where we would add new providers in the future.
  2. The parser now support multiple YAML documents from a single file
  3. I've updated the sample file fullmap.yaml to better illustrate how I think future data can be aggregated. (All of these are just examples, not proposals for actual uses)
  4. The data structure has not been changed yet, except for making fields pointers, Checkout the comment/question on the code review.
  5. I've modified the data that the parser returns to support returning multiple maps for the same PR

Needless to say, it is still a rough demo until we settle on a design.

Copy link
Member

@saschagrunert saschagrunert left a comment

Choose a reason for hiding this comment

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

Pretty good, I like the implementation and just have a few minor nits left. Do you wanna merge that PR before the demo or do we wanna demo it first and then gather further feedback?

@puerco
Copy link
Member Author

puerco commented Jun 24, 2020

I've pushed another commit addressing these nits. I think we should merge it because it does not alter the current tools but we need these if we want to produce some output (in a document, not just yamls) we can show.

What do you say if I give it a final polish tonight, squash the commits and resubmit. Then, based on this, we can start thinking how to assert the datafield interfaces and where/how we would add the data (like the CVE info) on the final documents.

Sounds good?

@puerco puerco force-pushed the release-notes-maps branch from 7db1216 to be7dd24 Compare June 24, 2020 22:52
@saschagrunert
Copy link
Member

I've pushed another commit addressing these nits. I think we should merge it because it does not alter the current tools but we need these if we want to produce some output (in a document, not just yamls) we can show.

What do you say if I give it a final polish tonight, squash the commits and resubmit. Then, based on this, we can start thinking how to assert the datafield interfaces and where/how we would add the data (like the CVE info) on the final documents.

Sounds good?

Yep, sounds wonderful to me :)

@puerco puerco force-pushed the release-notes-maps branch 3 times, most recently from 42a1e10 to 78f1d8e Compare June 25, 2020 20:48
@puerco puerco changed the title [WIP] Release notes mappings Release notes mappings libraries and in krel release-notes Jun 25, 2020
@k8s-ci-robot k8s-ci-robot removed the do-not-merge/work-in-progress Indicates that a PR should not merge because it is a work in progress. label Jun 25, 2020
Copy link
Member

@saschagrunert saschagrunert 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 26, 2020
@saschagrunert
Copy link
Member

/approve

@puerco
Copy link
Member Author

puerco commented Jun 27, 2020

/kind feature

@k8s-ci-robot k8s-ci-robot added kind/feature Categorizes issue or PR as related to a new feature. and removed needs-kind Indicates a PR lacks a `kind/foo` label and requires one. labels Jun 27, 2020
Copy link
Contributor

@hasheddan hasheddan left a comment

Choose a reason for hiding this comment

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

/lgtm

@puerco
Copy link
Member Author

puerco commented Jul 15, 2020

@justaugustus do you think we can merge this one to get the next ones rolling ? :)

@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 22, 2020
@puerco
Copy link
Member Author

puerco commented Jul 22, 2020

OK, this this PR and its following changes are officially in rebase hell.

I was trying to push the enhancement in steps: first the libraries, then the tools and finally the template and its tests. I think that now I will rebase and push these changes again but along the rest of the steps (except the template) in the same PR.

@saschagrunert
Copy link
Member

OK, this this PR and its following changes are officially in rebase hell.

I was trying to push the enhancement in steps: first the libraries, then the tools and finally the template and its tests. I think that now I will rebase and push these changes again but along the rest of the steps (except the template) in the same PR.

Whoops big sorry for that! Let's try to get those changes in ASAP.

@puerco
Copy link
Member Author

puerco commented Jul 23, 2020

No worries :) We cannot stop pushing ahead just for a small part getting stuck. Lets code some more! 💪

@puerco puerco force-pushed the release-notes-maps branch from 78f1d8e to 45e4104 Compare July 27, 2020 02:38
@k8s-ci-robot k8s-ci-robot added size/XL Denotes a PR that changes 500-999 lines, ignoring generated files. approved Indicates a PR has been approved by an approver from all required OWNERS files. and removed lgtm "Looks good to me", indicates that a PR is ready to be merged. needs-rebase Indicates a PR cannot be merged because it has merge conflicts with HEAD. size/L Denotes a PR that changes 100-499 lines, ignoring generated files. labels Jul 27, 2020
Copy link
Member

@saschagrunert saschagrunert 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 Jul 27, 2020
@k8s-ci-robot
Copy link
Contributor

[APPROVALNOTIFIER] This PR is APPROVED

This pull-request has been approved by: hasheddan, puerco, saschagrunert

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

@saschagrunert
Copy link
Member

@puerco can we lift the hold?

@puerco
Copy link
Member Author

puerco commented Jul 27, 2020

Sorry, yes. It was intended to be there while we decided on the approach. This one is fairly innocuous as it does not alter the output until we change the template.
/hold cancel

@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 Jul 27, 2020
@k8s-ci-robot k8s-ci-robot merged commit 3a0d268 into kubernetes:master Jul 27, 2020
@k8s-ci-robot k8s-ci-robot added this to the v1.19 milestone Jul 27, 2020
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/release-eng Issues or PRs related to the Release Engineering subproject cncf-cla: yes Indicates the PR's author has signed the CNCF CLA. kind/feature Categorizes issue or PR as related to a new feature. lgtm "Looks good to me", indicates that a PR is ready to be merged. needs-priority release-note Denotes a PR that will be considered when it comes time to generate release notes. sig/release Categorizes an issue or PR as relevant to SIG Release. size/XL Denotes a PR that changes 500-999 lines, ignoring generated files.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants