Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Support tilt hot reload for etcd snapshot restore #921

Merged
merged 1 commit into from
Dec 13, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
19 changes: 17 additions & 2 deletions Tiltfile
Original file line number Diff line number Diff line change
Expand Up @@ -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": {
Expand All @@ -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": ".",
Expand Down
59 changes: 23 additions & 36 deletions tilt/project/Tiltfile
Original file line number Diff line number Diff line change
Expand Up @@ -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():
Expand All @@ -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
Expand All @@ -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")
Expand Down
Loading