carvel-dev / kapp

kapp is a simple deployment tool focused on the concept of "Kubernetes application" — a set of resources with the same label
https://carvel.dev/kapp
Apache License 2.0
921 stars 110 forks source link

Conflicts should show some diff #471

Closed dprotaso closed 2 years ago

dprotaso commented 2 years ago

Describe the problem/challenge you have When a conflict occurs it's not actionable

kapp: Error: Applying update deployment/activator (apps/v1) namespace: 24f0bc17-06dc-424b-a9db-8d4e744d7790:
  Failed to update due to resource conflict  (approved diff no longer matches):
  Updating resource deployment/activator (apps/v1) namespace: 24f0bc17-06dc-424b-a9db-8d4e744d7790:
  API server says:
    Operation cannot be fulfilled on deployments.apps "activator": the object has been modified; please apply your changes to the latest version and try again (reason: Conflict)

Describe the solution you'd like It would good to show what the diff is so I could potentially write a rebase rule

Anything else you would like to add: N/A


Vote on this request

This is an invitation to the community to vote on issues, to help us prioritize our backlog. Use the "smiley face" up to the right of this comment to vote.

👍 "I would like to see this addressed as soon as possible" 👎 "There are other more important things to focus on right now"

We are also happy to receive and review Pull Requests if you want to help working on this issue.

rohitagg2020 commented 2 years ago

@dprotaso , Can you share the steps to reproduce the issue?

dprotaso commented 2 years ago

Have a deployment with an HPA and no rebaseRules

rohitagg2020 commented 2 years ago

We can improve the error to show what is causing the conflict:

  Failed to update due to resource conflict  (approved diff no longer matches):
  Updating resource deployment/activator (apps/v1) namespace: 24f0bc17-06dc-424b-a9db-8d4e744d7790:
  API server says:
    Operation cannot be fulfilled on deployments.apps "activator": the object has been modified; please apply your changes to the latest version and try again (reason: Conflict)
    Conflict occured because of the following: {[spec.replicas]}
rohitagg2020 commented 2 years ago

Note to Self: Error originates from https://github.com/vmware-tanzu/carvel-kapp/blob/a1a44c0d7f0fea302f77e091cf5bc4d9e3a3779e/pkg/kapp/clusterapply/add_or_update_change.go#L120

OpsDiff doesn't have any compare method to compare two OpsDiff and get output in a readable manner. Most probably, we have to enhance the code.