Skip to content

Commit 43a1f6b

Browse files
authored
check if app spec is updated on re-deploy (#642)
This PR changes the behavior of re-deploying an app where no changes have been made. Instead of erroring out, it will pass through gracefully. Signed-off-by: Niels Bantilan <niels.bantilan@gmail.com>
1 parent 86d55e9 commit 43a1f6b

File tree

2 files changed

+529
-0
lines changed

2 files changed

+529
-0
lines changed

src/flyte/remote/_app.py

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@
33
from contextlib import asynccontextmanager, contextmanager
44
from typing import AsyncGenerator, AsyncIterator, Generator, Literal, Mapping, Tuple, cast
55

6+
import google.protobuf.json_format
67
import grpc
78
import rich.repr
89
from flyteidl2.app import app_definition_pb2, app_payload_pb2
@@ -268,6 +269,23 @@ async def delete(
268269
return
269270
raise
270271

272+
@staticmethod
273+
async def _app_specs_are_equal(
274+
old_app_spec: app_definition_pb2.Spec, updated_app_spec: app_definition_pb2.Spec
275+
) -> bool:
276+
"""
277+
Compare two app specs and return True if they are the same.
278+
279+
If the updated_app_spec doesn't have any ingress defined, use the old app spec's ingress.
280+
"""
281+
old_app_spec_json = google.protobuf.json_format.MessageToDict(old_app_spec)
282+
updated_app_spec_json = google.protobuf.json_format.MessageToDict(updated_app_spec)
283+
old_ingress = old_app_spec_json.get("ingress")
284+
assert old_ingress is not None
285+
if not updated_app_spec_json.get("ingress"):
286+
updated_app_spec_json["ingress"] = old_ingress
287+
return old_app_spec_json == updated_app_spec_json
288+
271289
@syncify
272290
@classmethod
273291
async def replace(
@@ -290,7 +308,13 @@ async def replace(
290308
"""
291309
ensure_client()
292310
app = await cls.get.aio(name=name, project=project, domain=domain)
311+
293312
updated_app_spec.creator.CopyFrom(app.pb2.spec.creator)
313+
314+
if await cls._app_specs_are_equal(app.pb2.spec, updated_app_spec):
315+
logger.warning(f"No changes in the App spec for '{name}', skipping update")
316+
return app
317+
294318
new_app = app_definition_pb2.App(
295319
metadata=app_definition_pb2.Meta(
296320
id=app.pb2.metadata.id,

0 commit comments

Comments
 (0)