diff --git a/pkg/kapp/clusterapply/add_or_update_change.go b/pkg/kapp/clusterapply/add_or_update_change.go index b68b3f963..63967ab6c 100644 --- a/pkg/kapp/clusterapply/add_or_update_change.go +++ b/pkg/kapp/clusterapply/add_or_update_change.go @@ -235,11 +235,16 @@ func (c AddOrUpdateChange) recordAppliedResource(savedRes ctlres.Resource) error } // Record last applied change on the latest version of a resource - latestResWithHistoryUpdated, err := latestResWithHistory.RecordLastAppliedResource(applyChange) + latestResWithHistoryUpdated, madeAnyModifications, err := latestResWithHistory.RecordLastAppliedResource(applyChange) if err != nil { return true, fmt.Errorf("Recording last applied resource: %s", err) } + // when annotation value max length exceed then don't record the resource hence not making any modification + if !madeAnyModifications { + return true, nil + } + _, err = c.identifiedResources.Update(latestResWithHistoryUpdated) if err != nil { latestResWithHistory = nil // Get again diff --git a/pkg/kapp/diff/resource_with_history.go b/pkg/kapp/diff/resource_with_history.go index 1b1e973e1..aecad018d 100644 --- a/pkg/kapp/diff/resource_with_history.go +++ b/pkg/kapp/diff/resource_with_history.go @@ -69,13 +69,13 @@ func (r ResourceWithHistory) AllowsRecordingLastApplied() bool { return !found } -func (r ResourceWithHistory) RecordLastAppliedResource(appliedChange Change) (ctlres.Resource, error) { +func (r ResourceWithHistory) RecordLastAppliedResource(appliedChange Change) (ctlres.Resource, bool, error) { // Use compact representation to take as little space as possible // because annotation value max length is 262144 characters // (https://github.com/vmware-tanzu/carvel-kapp/issues/48). appliedResBytes, err := appliedChange.AppliedResource().AsCompactBytes() if err != nil { - return nil, err + return nil, true, err } diff := appliedChange.OpsDiff() @@ -100,11 +100,11 @@ func (r ResourceWithHistory) RecordLastAppliedResource(appliedChange Change) (ct const annValMaxLen = 262144 - for annKey, annVal := range annsMod.KVs { + // kapp deploy should work without adding disable annotation when annotation value max length exceed + // (https://github.com/vmware-tanzu/carvel-kapp/issues/410) + for _, annVal := range annsMod.KVs { if len(annVal) > annValMaxLen { - return nil, fmt.Errorf("Expected annotation '%s' value length %d to be <= max length %d "+ - "(hint: consider using annotation '%s')", - annKey, len(annVal), annValMaxLen, disableOriginalAnnKey) + return nil, false, nil } } @@ -112,10 +112,10 @@ func (r ResourceWithHistory) RecordLastAppliedResource(appliedChange Change) (ct err = annsMod.Apply(resultRes) if err != nil { - return nil, err + return nil, true, err } - return resultRes, nil + return resultRes, true, nil } func (r ResourceWithHistory) CalculateChange(appliedRes ctlres.Resource) (Change, error) {