knative / knative/client

Improve "kn service apply" to use a strategic patch strategy for perfoming the 3-way merge

Open
#1,073 4 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

kind/enhancement kind/feature size/L triage/accepted
Dominant language
Go
Stars
388
Forks
274
Avg merge
1d 6h
Merged PRs (30d)
8

Description

Feature request

As described in https://github.com/knative/client/pull/964#issuecomment-707184807 the way we are performing the 3way merge for a kn service apply is limited and can be improved.

Use case

Instead of doing a jsonmergepatch.CreateThreeWayJSONMergePatch, ideally a strategicpatch.CreateThreeWayMergePatch should be used but this fails because of lack of support for CRDs like the Knative Service.

// Compute a three way strategic merge patch to send to server.
lookupPatchMeta, err := strategicpatch.NewPatchMetaFromStruct(servingv1.Service{})
if err != nil {
	return false, err
}
patch, _ = strategicpatch.CreateThreeWayMergePatch(uOriginalService, uModifiedService, uCurrentService, lookupPatchMeta, false)

Also, an "overwrite" mode should be configurable to allow a forced overwrite in case of a conflict.

It is not clear now, whether the Kubernetes provided utility methods can be used or whether we need to implement our own merge algorithm (based on the knowledge of the supported CRD) instead.

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start at the kn service apply implementation and review the three-way merge discussion in PR #964. Determine whether Kubernetes strategic-patch utilities support the Knative Service CRD; done means apply uses the supported merge strategy and exposes a configurable overwrite mode.

Written by the indexing model from the issue text.

Assessment

Tech stack
go, kubernetes
Domain
cli
Issue type
Feature
Difficulty
5/5
Estimated time
Over a week
Activity status
Stale
Clarity
Needs clarification
Newbie friendliness
25/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.