Skip to content

Docs: Fix pkg update strategy docs — add copy-merge, correct conflict behavior - #4783

Open
kushnaidu wants to merge 3 commits into
kptdev:mainfrom
Nordix:merge-strategy-docs
Open

kushnaidu wants to merge 3 commits into
kptdev:mainfrom
Nordix:merge-strategy-docs

Conversation

@kushnaidu

@kushnaidu kushnaidu commented Oct 1, 2026 •

Copy link
Copy Markdown
Contributor

Description

Corrects and completes the kpt package update-strategy documentation so it
matches the actual implementation in pkg/lib/update.

1. Add the missing copy-merge strategy.
copy-merge is a registered update strategy (returned by
UpdateStrategiesAsStrings() and accepted by both kpt pkg update and
kpt pkg get), but it was absent from the docs. Added it to:

  • reference/cli/pkg/update/_index.md — --strategy flag list and a new
    "Copy-merge strategy" details subsection.
  • reference/cli/pkg/get/_index.md — --strategy flag list.
  • guides/3-way-merge.md — changed "three strategies" to "four" and added a
    copy-merge section.

2. Fix the conflict behavior for resource-merge.
The 3-way-merge guide previously stated that a conflict causes the update to
fail with an error. The implementation (merge3/visitor.go, VisitScalar)
does the opposite: when a field is changed in both upstream and local, it
auto-resolves by taking the upstream value and the update succeeds, with no
conflict markers. Rewrote the "Handling Conflicts" section and adjusted the
related best-practices and fast-forward wording. Also added a matching note to
the effective-customizations chapter (book/07).

3. Clarify the copy-merge root-Kptfile exception.
copy-merge is a file-level overwrite for most files, but the root Kptfile is an
exception: CopyMergeUpdater 3-way merges it via UpdateKptfile and
CopyPackage then skips the already-present root Kptfile, so local root-Kptfile
customizations are preserved. Reworded "any file" so it no longer misleads users
about this case.

4. Regenerate the committed CLI help.
commands/pkg/update/cmdupdate.go and commands/pkg/get serve their long help
from the checked-in generated internal/docs/generated/pkgdocs/docs.go, which
still omitted copy-merge. Regenerated it (make generate) so the CLI
--help text is no longer stale.

Motivation

The 3-way-merge guide's conflict section contradicted both the CLI reference and
the actual code, which could lead users to expect an interactive conflict
resolution that never happens — risking silent loss of local edits. The missing
copy-merge strategy left a valid, user-facing option undocumented.

Verified against the update code and by reproducing all four strategies'
behavior (including the field-level conflict and the "deleted upstream but
modified locally" case) with kpt pkg update.

@kushnaidu
kushnaidu requested review from a team and a balanced review from Copilot October 1, 2026 13:33
@netlify

netlify Bot commented Oct 1, 2026 •

Copy link
Copy Markdown

✅ Deploy Preview for kptdocs ready!

Name Link
🔨 Latest commit 3cd5fb9
🔍 Latest deploy log https://app.netlify.com/projects/kptdocs/deploys/6abe70385330d30008e19068
😎 Deploy Preview https://deploy-preview-4783--kptdocs.netlify.app
📱 Preview on mobile
Toggle QR Code...

QR Code

Use your smartphone camera to open QR code link.
🤖 Make changes Run an agent on this branch

To edit notification comments on pull requests, go to your Netlify project configuration.

@dosubot

dosubot Bot commented Oct 1, 2026

Copy link
Copy Markdown
Contributor

📄 Knowledge review

✏️ Suggested updates

1 page suggestion needs review.

Page Library Status
_index /kpt/blob/main/documentation/content/en/book/07-effective-customizations/_index.md kpt ⬆️ Pushed to this PR

Leave Feedback Ask Dosu about kpt Add Dosu to your team

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Copilot review overview

🟡 Changes recommended

Generated CLI help remains stale, related get documentation is incomplete, and copy-merge’s root Kptfile exception is undocumented.

Review effort: Balanced
Findings: 1 Medium severity · 2 Low severity

Open (3)
What changed in this PR

Documents all four package-update strategies and corrects resource-merge conflict behavior.

Changes:

  • Adds copy-merge documentation.
  • Clarifies that resource-merge conflicts favor upstream values.
  • Updates related guidance and examples.
File Description
documentation/​content/​en/​reference/​cli/​pkg/​update/​_index.md Expands strategy reference and conflict semantics.
documentation/​content/​en/​guides/​3-way-merge.md Updates strategy guide, examples, and best practices.

💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.

Comment thread documentation/content/en/reference/cli/pkg/update/_index.md
Comment thread documentation/content/en/guides/3-way-merge.md
Comment thread documentation/content/en/guides/3-way-merge.md Outdated
@kushnaidu
kushnaidu force-pushed the merge-strategy-docs branch from 07cd018 to f7c9390 Compare October 1, 2026 13:42
Corrects and completes the kpt package update-strategy documentation to
match the implementation in pkg/lib/update.

- Add the copy-merge strategy, which was missing from both the
  `kpt pkg update` and `kpt pkg get` --strategy references and from the
  3-way-merge guide, even though it is a registered strategy
  (UpdateStrategiesAsStrings) accepted by both commands.
- Fix the 3-way-merge guide's conflict description: resource-merge does
  not fail on a field changed in both upstream and local. It auto-resolves
  by taking the upstream value and succeeds, with no conflict markers.
- Clarify that copy-merge 3-way merges the root Kptfile (via UpdateKptfile)
  instead of overwriting it, so "any file" no longer misleads users about
  local root-Kptfile customizations.
- Regenerate internal/docs/generated/pkgdocs/docs.go so the CLI long help
  for `kpt pkg get` and `kpt pkg update` is no longer stale.

Signed-off-by: Kushal Harish Naidu <kushal.harish.naidu@ericsson.com>
@kushnaidu
kushnaidu force-pushed the merge-strategy-docs branch from f7c9390 to 7eddc34 Compare October 1, 2026 14:03
Signed-off-by: Kushal Harish Naidu <kushal.harish.naidu@ericsson.com>

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Copilot review overview

🟡 Changes recommended

Several statements overgeneralize upstream-wins behavior and local-file preservation beyond the implementation.

Review effort: Balanced
Findings: 6 Medium severity

Open (6)
Resolved since last review (3)

Comment thread documentation/content/en/book/07-effective-customizations/_index.md Outdated
Comment thread documentation/content/en/guides/3-way-merge.md Outdated
Comment thread documentation/content/en/guides/3-way-merge.md Outdated
Comment thread documentation/content/en/reference/cli/pkg/update/_index.md Outdated
Comment thread documentation/content/en/reference/cli/pkg/update/_index.md Outdated
Comment thread documentation/content/en/reference/cli/pkg/update/_index.md Outdated
Make the resource-merge conflict description more precise: the upstream value
wins only for different non-null scalar / non-associative-list values; local
field removals and nulls follow separate deletion semantics (and honor
--preserve-explicit-null). Clarify the copy-merge root-Kptfile exception
(local-only non-conflicting edits preserved; conflicting values follow the
Kptfile merge rules; upstream metadata refreshed) and the local-vs-upstream
same-path file behavior.

Signed-off-by: Kushal Harish Naidu <kushal.harish.naidu@ericsson.com>
@sonarqubecloud

sonarqubecloud Bot commented Oct 1, 2026

Copy link
Copy Markdown

This branch has not been deployed

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants