From ac6736b92ead4acb798e3f21b47813586495961e Mon Sep 17 00:00:00 2001 From: Alexandr Demicev Date: Wed, 11 Dec 2024 19:40:45 +0100 Subject: [PATCH] Support tilt hot reload for etcd snapshot restore Signed-off-by: Alexandr Demicev --- Tiltfile | 19 ++++++++++++-- tilt/project/Tiltfile | 59 +++++++++++++++++-------------------------- 2 files changed, 40 insertions(+), 38 deletions(-) diff --git a/Tiltfile b/Tiltfile index 4cf4067b..5a3cc029 100644 --- a/Tiltfile +++ b/Tiltfile @@ -35,7 +35,7 @@ if settings.get("trigger_mode") == "manual": if settings.get("default_registry") != "": default_registry(settings.get("default_registry")) -always_enable_projects = ["turtles", "turtles-capiproviders"] +always_enable_projects = ["turtles", "turtles-capiproviders", "turtles-etcdsnapshotrestore"] projects = { "turtles": { @@ -49,7 +49,22 @@ projects = { "features", ], "kustomize_dir": "config/default", - "label": "turtles" + "label": "turtles", + "binary_name" : "manager" + }, + "turtles-etcdsnapshotrestore": { + "context": "exp/etcdrestore", + "image": "ghcr.io/rancher/turtles-etcd-restore:dev", + "live_reload_deps": [ + "main.go", + "go.mod", + "go.sum", + "controllers", + "webhooks", + ], + "kustomize_dir": "config/default", + "label": "turtles-etcdsnapshotrestore", + "binary_name" : "etcd-snapshot-restore" }, "turtles-capiproviders": { "context": ".", diff --git a/tilt/project/Tiltfile b/tilt/project/Tiltfile index b9c0d324..b9131e93 100644 --- a/tilt/project/Tiltfile +++ b/tilt/project/Tiltfile @@ -83,7 +83,7 @@ def project_enable(name, project, debug): if kustomize_dir != "": info("doing kustomization") yaml = kustomize(context + '/' + kustomize_dir) - yaml = update_manager(yaml, "manager", debug, env) + yaml = update_manager(yaml, "manager", debug, env, name, project) yaml_path = context + "/.tiltbuild/manifest.yaml" prepare_file(yaml_path) for line in str(yaml).splitlines(): @@ -102,7 +102,7 @@ def project_enable(name, project, debug): ) info("finished adding project") -def update_manager(yaml, containerName, debug, env): +def update_manager(yaml, containerName, debug, env, name, project): """Enable a project in Tilt *****TODO: change this so the deployment is passed in @@ -129,43 +129,30 @@ def update_manager(yaml, containerName, debug, env): for c in containers: if c["name"] != containerName: continue + if name != "turtles": # use custom image for projects except turtles + c["image"] = project.get("image") cmd = ["sh", "/start.sh", "/manager"] if debug != {}: - cmd = ["sh", "/start.sh", "/dlv", "--accept-multiclient", "--api-version=2", "--headless=true", "exec"] - if debug_port != 0: - # The debug port - ports = c.get("ports") - if ports == None: - info("no ports, creating new") - c["ports"] = [] - ports = c["ports"] - ports.append({"containerPort": 30000}) - cmd.append("--listen=:30000") - if debug_continue: - cmd.append("--continue") - cmd.append("--") - cmd.append("/manager") - - debugArgs = [] - containerArgs = c.get("args") - if containerArgs != None: - for arg in c["args"]: - if arg == "--leader-elect" or arg == "--leader-elect=true": - continue - debugArgs.append(arg) - if debug_insecure_skip_verify: - debugArgs.append("--insecure-skip-verify=true") - debugArgs.append("--v=5") - c["command"] = cmd - print(cmd) - if len(debugArgs) == 0: - c.pop("args",{}) - else: - c["args"] = debugArgs - c.pop("readinessProbe",{}) - c.pop("livenessProbe",{}) - c.pop("resources", {}) + debugArgs = [] + containerArgs = c.get("args") + if containerArgs != None: + for arg in c["args"]: + if arg == "--leader-elect" or arg == "--leader-elect=true": + continue + debugArgs.append(arg) + if debug_insecure_skip_verify: + debugArgs.append("--insecure-skip-verify=true") + debugArgs.append("--v=5") + c["command"] = cmd + print(cmd) + if len(debugArgs) == 0: + c.pop("args",{}) + else: + c["args"] = debugArgs + c.pop("readinessProbe",{}) + c.pop("livenessProbe",{}) + c.pop("resources", {}) if env != {}: debugEnv = dict([]) containerEnvVars = c.get("env")