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

Ensure release-notes tool doesn't skip automated cherry picks #2689

Merged
merged 1 commit into from
Oct 10, 2022

Conversation

xmudrii
Copy link
Member

@xmudrii xmudrii commented Sep 28, 2022

What type of PR is this?

/kind bug

What this PR does / why we need it:

Motivation

We've recently discovered a bug in the release-notes tool causing automated cherry picks to be skipped. This is because those PRs have an empty release note block, which is handled like the release note is present. This is not correct behavior, instead, those PRs should be skipped. Instead of those PRs, the release-notes tool should take the parent PR and its release note.

Problem explained

Before I start with the problem explanation, the following diagram shows our workflow:

flowchart TD
    A[release-notes] --> B[GatherReleaseNotes]
    B --> C[ListReleaseNotes]
    C --> D[gatherNotes]
    D --> E[notesForCommit]
    E --> F[prsFromCommit]
    F --> G[prsForCommitFromMessage]
    G --> H[prsNumForCommitFromMessage]

    H --> |slice of PR numbers| G
    G --> |slice of PRs| F
    F --> |slice of PRs| E
    E --> |SINGLE PR selected based  on heuristics| D
    D --> |slice of release notes for all PRs| C
    C --> |complete release notes for all PRs| B
Loading

The release-notes tool calls a bunch of functions to determine a release note for PRs. We first take a list of commits for which we need to determine PRs. Those list of commits is passed to gatherNotes which takes each commit and passes it to notesForCommit. After calling a few more functions (as shown in the diagram), we end up with a list of candidate PRs for that commit (prsNumForCommitFromMessage function). Those candidate PRs are the original PR, parent PR if it's a cherry-pick, and we have special handling for squashed commits.

Those candidate PRs are passed back to notesForCommit where we select a single PR out of those candidate PRs.

This is where the problem appears. This function takes the PR body and checks if it contains the release-note block OR the Does this PR introduce a user-facing change? text. However, we do NOT check if it's a valid release note. We pass that single PR to gatherNotes where we check if it's actually a valid release note. However, we pass only that one single PR, we don't pass other candidate PRs. If it turns out to be an invalid release note, we can't check other PRs because we discarded them.

That's not a problem for PRs targeting the master/main branch. However, that is a problem for cherry picks where we have an empty release note block and where we excpect to inherit release note from the parent PR. In this case, notesForCommit will think that the cherry pick has a valid release note (even if it's empty) and will discard the parent PR. This causes release notes to lose release note for that change/PR.

Fix explained

This PR introduces two major changes:

  • notesForCommit checks if the release note is valid instead of just checking for the presence of the release-note block or Does this PR introduce a user-facing change? text
    • If the PR is supposed to be excluded (NONE/release-note-none), we return that PR because it might have a map with a release note. If it doesn't, it will be skipped and that's okay because it has NONE/release-note-none.
  • noteExclusionFilters is updated so that the release note MUST contain NONE/NO/NA. Currently, it excludes PRs with empty release notes, but this seems wrong because a PR without a release note should be considered as invalid

Which issue(s) this PR fixes:

xref #2679
ListReleaseNotesV2 is affected as well, but not fixed by this PR. It'll be done in a follow up PR.

Special notes for your reviewer:

Release note for this PR might include more details, I can update it if needed.

Does this PR introduce a user-facing change?

Ensure release-notes tool doesn't skip automated cherry picks

/assign @puerco @jeremyrickard @cpanato @Verolop @palnabarun
cc @kubernetes/release-engineering

@k8s-ci-robot k8s-ci-robot added the release-note Denotes a PR that will be considered when it comes time to generate release notes. label Sep 28, 2022
@k8s-ci-robot k8s-ci-robot added the kind/bug Categorizes issue or PR as related to a bug. label Sep 28, 2022
@k8s-ci-robot k8s-ci-robot added cncf-cla: yes Indicates the PR's author has signed the CNCF CLA. needs-priority labels Sep 28, 2022
@k8s-ci-robot k8s-ci-robot added area/release-eng Issues or PRs related to the Release Engineering subproject sig/release Categorizes an issue or PR as relevant to SIG Release. 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 Sep 28, 2022
@xmudrii
Copy link
Member Author

xmudrii commented Sep 28, 2022

/hold
for discussion

@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 Sep 28, 2022
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, this seems to fix a valid bug and simplifies the code. Great work!

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

[APPROVALNOTIFIER] This PR is APPROVED

This pull-request has been approved by: saschagrunert, 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:

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

@xmudrii
Copy link
Member Author

xmudrii commented Oct 10, 2022

/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 Oct 10, 2022
@k8s-ci-robot k8s-ci-robot merged commit cac8772 into kubernetes:master Oct 10, 2022
@k8s-ci-robot k8s-ci-robot added this to the v1.26 milestone Oct 10, 2022
@xmudrii xmudrii deleted the release-note-cherry-picks branch October 10, 2022 13:16
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/bug Categorizes issue or PR as related to a bug. 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/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.

8 participants