Skip to content

fix(app): make app push idempotent using server-side apply#2904

Open
kwiatekus wants to merge 7 commits intokyma-project:mainfrom
kwiatekus:patch-apply-kyma-app-push
Open

fix(app): make app push idempotent using server-side apply#2904
kwiatekus wants to merge 7 commits intokyma-project:mainfrom
kwiatekus:patch-apply-kyma-app-push

Conversation

@kwiatekus
Copy link
Copy Markdown
Contributor

@kwiatekus kwiatekus commented May 6, 2026

Summary

  • kyma app push previously failed on rerun with "already exists" errors for Deployment and Service
  • Adds ApplyDeployment and ApplyService functions using Server-Side Apply (SSA) via the existing rootlessdynamic.Apply() infrastructure — the same pattern already used by CreateAPIRule
  • push.go now calls the new Apply* functions; existing Create* functions are preserved for backward compatibility

Changes

  • internal/kube/resources/deployment.go — add ApplyDeployment
  • internal/kube/resources/service.go — add ApplyService
  • internal/cmd/app/push.go — switch to ApplyDeployment/ApplyService; update output messages from "Creating" to "Applying"
  • Tests cover create (first run) and upsert (rerun) paths for both new functions

Test plan

  • go test ./internal/kube/resources/... ./internal/cmd/app/... passes
  • Run kyma app push --name my-app --image <image> twice against a cluster — second run should succeed without errors

Related to

Fixes #2905
#2899
#2410

kwiatekus added 6 commits May 6, 2026 15:22
…e test coverage

- Fix 1: Set Namespace field in buildDeployment's ObjectMeta so ApplyDeployment
  can correctly pass namespace to rootlessdynamic.Apply()
- Fix 2: Set TypeMeta on deployment before ToUnstructured for consistency with
  CreateAPIRule pattern, instead of setting it after conversion
- Fix 3: Enhance Test_ApplyDeployment to verify namespace propagation and image
  updates are correctly captured in applied objects
@kwiatekus kwiatekus requested a review from a team as a code owner May 6, 2026 14:16
@github-actions
Copy link
Copy Markdown

github-actions Bot commented May 6, 2026

✅ Proposed changes verification passed

This pull request comes with up-to-date documentation and no illegal standard output usages.

Find more detailed information in the verify / standards (pull_request_target) action.

@kwiatekus kwiatekus enabled auto-merge (squash) May 6, 2026 14:49
@kwiatekus kwiatekus changed the title feat(app): make app push idempotent using server-side apply fix(app): make app push idempotent using server-side apply May 6, 2026
deployment := buildDeployment(&opts)
_, err := client.Static().AppsV1().Deployments(opts.Namespace).Create(ctx, deployment, metav1.CreateOptions{})
return err
deployment.TypeMeta = metav1.TypeMeta{
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.

We have the deployment definition built in the buildDeployment function starting from line 87, maybe let's move this TypeMeta there

service := buildService(name, namespace, port)
_, err := client.Static().CoreV1().Services(namespace).Create(ctx, service, metav1.CreateOptions{})
return err
service.TypeMeta = metav1.TypeMeta{
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.

same thing here

Copy link
Copy Markdown
Contributor

@musztardem musztardem left a comment

Choose a reason for hiding this comment

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

I'd adjust the deployment/service building functions, otherwise LGTM

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.

kyma app push fails on rerun with "already exists" error for Deployment and Service

3 participants