diff --git a/apps/helloworld-knative/service.yaml b/apps/helloworld-knative/service.yaml index 679c070..990c77a 100644 --- a/apps/helloworld-knative/service.yaml +++ b/apps/helloworld-knative/service.yaml @@ -11,12 +11,12 @@ spec: apps.coco-serverless/name: helloworld-py io.katacontainers.config.pre_attestation.enabled: "false" spec: - runtimeClassName: kata-qemu-sev + runtimeClassName: kata-qemu # coco-knative: need to run user container as root securityContext: runAsUser: 1000 containers: - - image: csegarragonz/coco-helloworld-py:latest + - image: ghcr.io/csegarragonz/coco-helloworld-py:unencrypted ports: - containerPort: 8080 env: diff --git a/eval/plots/startup/breakdown.pdf b/eval/plots/startup/breakdown.pdf index c578076..f70613e 100644 Binary files a/eval/plots/startup/breakdown.pdf and b/eval/plots/startup/breakdown.pdf differ diff --git a/eval/plots/startup/startup.pdf b/eval/plots/startup/startup.pdf index ecde683..a0aeff2 100644 Binary files a/eval/plots/startup/startup.pdf and b/eval/plots/startup/startup.pdf differ diff --git a/eval/plots/startup/startup.png b/eval/plots/startup/startup.png index f4c44ff..74f0db2 100644 Binary files a/eval/plots/startup/startup.png and b/eval/plots/startup/startup.png differ diff --git a/eval/results/startup/docker_cold.csv b/eval/results/startup/docker_cold.csv index 51db007..c98ff71 100644 --- a/eval/results/startup/docker_cold.csv +++ b/eval/results/startup/docker_cold.csv @@ -1,58 +1,58 @@ Run,Event,TimeStampMs -0,Start,1697565418.8096719 -0,Initialized,1697565419.0 -0,PodScheduled,1697565419.0 -0,StartRunPodSandbox,1697565419.883651 -0,EndRunPodSandbox,1697565420.027871 -0,StartImagePull_Service,1697565420.030229 -0,EndImagePull_Service,1697565422.474695 -0,StartCreateContainer_Service,1697565422.477425 -0,EndCreateContainer_Service,1697565422.502194 -0,StartImagePull_Sidecar,1697565422.573553 -0,EndImagePull_Sidecar,1697565424.946484 -0,StartCreateContainer_Sidecar,1697565424.949939 -0,EndCreateContainer_Sidecar,1697565424.957349 -0,StartStartContainer_Service,1697565424.958052 -0,StartStartContainer_Sidecar,1697565424.958052 -0,Ready,1697565425.0 -0,ContainersReady,1697565425.0 -0,EndStartContainer_Service,1697565425.02993 -0,EndStartContainer_Sidecar,1697565425.02993 -1,Start,1697565460.987475 -1,Initialized,1697565461.0 -1,PodScheduled,1697565461.0 -1,StartRunPodSandbox,1697565462.035959 -1,EndRunPodSandbox,1697565462.195915 -1,StartImagePull_Service,1697565462.197971 -1,EndImagePull_Service,1697565464.812385 -1,StartCreateContainer_Service,1697565464.814765 -1,EndCreateContainer_Service,1697565464.830627 -1,StartImagePull_Sidecar,1697565464.891024 -1,Ready,1697565467.0 -1,ContainersReady,1697565467.0 -1,EndImagePull_Sidecar,1697565467.545699 -1,StartCreateContainer_Sidecar,1697565467.549831 -1,EndCreateContainer_Sidecar,1697565467.556076 -1,StartStartContainer_Service,1697565467.556732 -1,StartStartContainer_Sidecar,1697565467.556732 -1,EndStartContainer_Service,1697565467.627619 -1,EndStartContainer_Sidecar,1697565467.627619 -2,Initialized,1697565503.0 -2,PodScheduled,1697565503.0 -2,Start,1697565503.1519074 -2,StartRunPodSandbox,1697565504.199924 -2,EndRunPodSandbox,1697565504.358272 -2,StartImagePull_Service,1697565504.36132 -2,EndImagePull_Service,1697565506.918156 -2,StartCreateContainer_Service,1697565506.9206 -2,EndCreateContainer_Service,1697565506.928476 -2,StartImagePull_Sidecar,1697565506.993785 -2,Ready,1697565509.0 -2,ContainersReady,1697565509.0 -2,EndImagePull_Sidecar,1697565509.41992 -2,StartCreateContainer_Sidecar,1697565509.423365 -2,EndCreateContainer_Sidecar,1697565509.430167 -2,StartStartContainer_Service,1697565509.431209 -2,StartStartContainer_Sidecar,1697565509.431209 -2,EndStartContainer_Service,1697565509.51329 -2,EndStartContainer_Sidecar,1697565509.51329 +0,Initialized,1697651345.0 +0,PodScheduled,1697651345.0 +0,Start,1697651345.052553 +0,StartRunPodSandbox,1697651346.008561 +0,EndRunPodSandbox,1697651346.181397 +0,StartImagePull_Service,1697651346.184028 +0,EndImagePull_Service,1697651348.78394 +0,StartCreateContainer_Service,1697651348.786753 +0,EndCreateContainer_Service,1697651348.801478 +0,StartImagePull_Sidecar,1697651348.860708 +0,Ready,1697651351.0 +0,ContainersReady,1697651351.0 +0,EndImagePull_Sidecar,1697651351.528729 +0,StartCreateContainer_Sidecar,1697651351.532241 +0,EndCreateContainer_Sidecar,1697651351.539909 +0,StartStartContainer_Service,1697651351.540357 +0,StartStartContainer_Sidecar,1697651351.540357 +0,EndStartContainer_Service,1697651351.611144 +0,EndStartContainer_Sidecar,1697651351.611144 +1,Initialized,1697651387.0 +1,PodScheduled,1697651387.0 +1,Start,1697651387.1835673 +1,StartRunPodSandbox,1697651388.132089 +1,EndRunPodSandbox,1697651388.287967 +1,StartImagePull_Service,1697651388.290056 +1,EndImagePull_Service,1697651390.781933 +1,StartCreateContainer_Service,1697651390.784773 +1,EndCreateContainer_Service,1697651390.798972 +1,StartImagePull_Sidecar,1697651390.875708 +1,Ready,1697651393.0 +1,ContainersReady,1697651393.0 +1,EndImagePull_Sidecar,1697651393.223222 +1,StartCreateContainer_Sidecar,1697651393.227201 +1,EndCreateContainer_Sidecar,1697651393.234814 +1,StartStartContainer_Service,1697651393.235485 +1,StartStartContainer_Sidecar,1697651393.235485 +1,EndStartContainer_Service,1697651393.311364 +1,EndStartContainer_Sidecar,1697651393.311364 +2,Initialized,1697651429.0 +2,PodScheduled,1697651429.0 +2,Start,1697651429.34211 +2,StartRunPodSandbox,1697651430.296781 +2,EndRunPodSandbox,1697651430.448964 +2,StartImagePull_Service,1697651430.450505 +2,EndImagePull_Service,1697651433.011846 +2,StartCreateContainer_Service,1697651433.014822 +2,EndCreateContainer_Service,1697651433.031119 +2,StartImagePull_Sidecar,1697651433.122787 +2,EndImagePull_Sidecar,1697651435.628239 +2,StartCreateContainer_Sidecar,1697651435.630954 +2,EndCreateContainer_Sidecar,1697651435.63706 +2,StartStartContainer_Service,1697651435.637606 +2,StartStartContainer_Sidecar,1697651435.637606 +2,EndStartContainer_Service,1697651435.720615 +2,EndStartContainer_Sidecar,1697651435.720615 +2,Ready,1697651436.0 +2,ContainersReady,1697651436.0 diff --git a/eval/results/startup/docker_warm.csv b/eval/results/startup/docker_warm.csv index 3f291e8..117462a 100644 --- a/eval/results/startup/docker_warm.csv +++ b/eval/results/startup/docker_warm.csv @@ -1,58 +1,58 @@ Run,Event,TimeStampMs -0,Initialized,1697565307.0 -0,PodScheduled,1697565307.0 -0,Start,1697565307.217185 -0,StartRunPodSandbox,1697565308.272695 -0,EndRunPodSandbox,1697565308.410176 -0,StartImagePull_Service,1697565308.410176 -0,EndImagePull_Service,1697565308.410176 -0,StartImagePull_Sidecar,1697565308.410176 -0,EndImagePull_Sidecar,1697565308.410176 -0,StartCreateContainer_Service,1697565308.414838 -0,EndCreateContainer_Service,1697565308.423383 -0,StartCreateContainer_Sidecar,1697565308.460902 -0,EndCreateContainer_Sidecar,1697565308.466886 -0,StartStartContainer_Service,1697565308.467395 -0,StartStartContainer_Sidecar,1697565308.467395 -0,EndStartContainer_Service,1697565308.50481 -0,EndStartContainer_Sidecar,1697565308.50481 -0,Ready,1697565309.0 -0,ContainersReady,1697565309.0 -1,Start,1697565344.3489451 -1,Initialized,1697565345.0 -1,PodScheduled,1697565345.0 -1,StartRunPodSandbox,1697565345.483397 -1,EndRunPodSandbox,1697565345.661458 -1,StartImagePull_Service,1697565345.661458 -1,EndImagePull_Service,1697565345.661458 -1,StartImagePull_Sidecar,1697565345.661458 -1,EndImagePull_Sidecar,1697565345.661458 -1,StartCreateContainer_Service,1697565345.665474 -1,EndCreateContainer_Service,1697565345.677681 -1,StartCreateContainer_Sidecar,1697565345.724101 -1,EndCreateContainer_Sidecar,1697565345.728681 -1,StartStartContainer_Service,1697565345.729058 -1,StartStartContainer_Sidecar,1697565345.729058 -1,EndStartContainer_Service,1697565345.764412 -1,EndStartContainer_Sidecar,1697565345.764412 -1,Ready,1697565346.0 -1,ContainersReady,1697565346.0 -2,Start,1697565381.4785688 -2,Initialized,1697565382.0 -2,PodScheduled,1697565382.0 -2,StartRunPodSandbox,1697565382.527941 -2,EndRunPodSandbox,1697565382.700886 -2,StartImagePull_Service,1697565382.700886 -2,EndImagePull_Service,1697565382.700886 -2,StartImagePull_Sidecar,1697565382.700886 -2,EndImagePull_Sidecar,1697565382.700886 -2,StartCreateContainer_Service,1697565382.705174 -2,EndCreateContainer_Service,1697565382.711766 -2,StartCreateContainer_Sidecar,1697565382.753361 -2,EndCreateContainer_Sidecar,1697565382.758577 -2,StartStartContainer_Service,1697565382.759054 -2,StartStartContainer_Sidecar,1697565382.759054 -2,EndStartContainer_Service,1697565382.797824 -2,EndStartContainer_Sidecar,1697565382.797824 -2,Ready,1697565383.0 -2,ContainersReady,1697565383.0 +0,Start,1697651233.4299753 +0,Initialized,1697651234.0 +0,PodScheduled,1697651234.0 +0,StartRunPodSandbox,1697651234.348279 +0,EndRunPodSandbox,1697651234.513383 +0,StartImagePull_Service,1697651234.513383 +0,EndImagePull_Service,1697651234.513383 +0,StartImagePull_Sidecar,1697651234.513383 +0,EndImagePull_Sidecar,1697651234.513383 +0,StartCreateContainer_Service,1697651234.516061 +0,EndCreateContainer_Service,1697651234.523143 +0,StartCreateContainer_Sidecar,1697651234.56023 +0,EndCreateContainer_Sidecar,1697651234.567317 +0,StartStartContainer_Service,1697651234.567778 +0,StartStartContainer_Sidecar,1697651234.567778 +0,EndStartContainer_Service,1697651234.605508 +0,EndStartContainer_Sidecar,1697651234.605508 +0,Ready,1697651235.0 +0,ContainersReady,1697651235.0 +1,Start,1697651270.5520155 +1,Initialized,1697651271.0 +1,PodScheduled,1697651271.0 +1,StartRunPodSandbox,1697651271.48375 +1,EndRunPodSandbox,1697651271.636434 +1,StartImagePull_Service,1697651271.636434 +1,EndImagePull_Service,1697651271.636434 +1,StartImagePull_Sidecar,1697651271.636434 +1,EndImagePull_Sidecar,1697651271.636434 +1,StartCreateContainer_Service,1697651271.639752 +1,EndCreateContainer_Service,1697651271.649893 +1,StartCreateContainer_Sidecar,1697651271.688735 +1,EndCreateContainer_Sidecar,1697651271.695225 +1,StartStartContainer_Service,1697651271.695487 +1,StartStartContainer_Sidecar,1697651271.695487 +1,EndStartContainer_Service,1697651271.726042 +1,EndStartContainer_Sidecar,1697651271.726042 +1,Ready,1697651272.0 +1,ContainersReady,1697651272.0 +2,Start,1697651307.6992502 +2,Initialized,1697651308.0 +2,PodScheduled,1697651308.0 +2,StartRunPodSandbox,1697651308.63565 +2,EndRunPodSandbox,1697651308.798958 +2,StartImagePull_Service,1697651308.798958 +2,EndImagePull_Service,1697651308.798958 +2,StartImagePull_Sidecar,1697651308.798958 +2,EndImagePull_Sidecar,1697651308.798958 +2,StartCreateContainer_Service,1697651308.802762 +2,EndCreateContainer_Service,1697651308.809039 +2,StartCreateContainer_Sidecar,1697651308.848687 +2,EndCreateContainer_Sidecar,1697651308.85518 +2,StartStartContainer_Service,1697651308.855583 +2,StartStartContainer_Sidecar,1697651308.855583 +2,EndStartContainer_Service,1697651308.888498 +2,EndStartContainer_Sidecar,1697651308.888498 +2,Ready,1697651309.0 +2,ContainersReady,1697651309.0 diff --git a/eval/results/startup/kata_cold.csv b/eval/results/startup/kata_cold.csv new file mode 100644 index 0000000..b1eeed3 --- /dev/null +++ b/eval/results/startup/kata_cold.csv @@ -0,0 +1,58 @@ +Run,Event,TimeStampMs +0,Start,1697650963.48791 +0,Initialized,1697650964.0 +0,PodScheduled,1697650964.0 +0,StartRunPodSandbox,1697650964.407945 +0,EndRunPodSandbox,1697650965.875491 +0,StartImagePull_Service,1697650965.878297 +0,EndImagePull_Service,1697650971.535117 +0,StartCreateContainer_Service,1697650971.538068 +0,EndCreateContainer_Service,1697650971.54496 +0,StartImagePull_Sidecar,1697650971.607058 +0,EndImagePull_Sidecar,1697650973.849603 +0,StartCreateContainer_Sidecar,1697650973.85327 +0,EndCreateContainer_Sidecar,1697650973.856947 +0,StartStartContainer_Service,1697650973.857511 +0,StartStartContainer_Sidecar,1697650973.857511 +0,EndStartContainer_Service,1697650973.918397 +0,EndStartContainer_Sidecar,1697650973.918397 +0,Ready,1697650975.0 +0,ContainersReady,1697650975.0 +1,Start,1697650982.5529299 +1,Initialized,1697650983.0 +1,PodScheduled,1697650983.0 +1,StartRunPodSandbox,1697650983.50432 +1,EndRunPodSandbox,1697650984.876993 +1,StartImagePull_Service,1697650984.879697 +1,EndImagePull_Service,1697650990.899228 +1,StartCreateContainer_Service,1697650990.901916 +1,EndCreateContainer_Service,1697650990.905659 +1,StartImagePull_Sidecar,1697650990.967367 +1,Ready,1697650993.0 +1,ContainersReady,1697650993.0 +1,EndImagePull_Sidecar,1697650993.242698 +1,StartCreateContainer_Sidecar,1697650993.246385 +1,EndCreateContainer_Sidecar,1697650993.249963 +1,StartStartContainer_Service,1697650993.251412 +1,StartStartContainer_Sidecar,1697650993.251412 +1,EndStartContainer_Service,1697650993.308953 +1,EndStartContainer_Sidecar,1697650993.308953 +2,Start,1697651000.626488 +2,Initialized,1697651001.0 +2,PodScheduled,1697651001.0 +2,StartRunPodSandbox,1697651001.711692 +2,EndRunPodSandbox,1697651003.059412 +2,StartImagePull_Service,1697651003.061742 +2,EndImagePull_Service,1697651008.729659 +2,StartCreateContainer_Service,1697651008.732298 +2,EndCreateContainer_Service,1697651008.736184 +2,StartImagePull_Sidecar,1697651008.797195 +2,EndImagePull_Sidecar,1697651010.912698 +2,StartCreateContainer_Sidecar,1697651010.915892 +2,EndCreateContainer_Sidecar,1697651010.919255 +2,StartStartContainer_Service,1697651010.920275 +2,StartStartContainer_Sidecar,1697651010.920275 +2,EndStartContainer_Service,1697651010.976685 +2,EndStartContainer_Sidecar,1697651010.976685 +2,Ready,1697651011.0 +2,ContainersReady,1697651011.0 diff --git a/eval/results/startup/kata_warm.csv b/eval/results/startup/kata_warm.csv new file mode 100644 index 0000000..27312fc --- /dev/null +++ b/eval/results/startup/kata_warm.csv @@ -0,0 +1,58 @@ +Run,Event,TimeStampMs +0,Initialized,1697650895.0 +0,PodScheduled,1697650895.0 +0,Start,1697650895.2169847 +0,StartRunPodSandbox,1697650896.187588 +0,EndRunPodSandbox,1697650897.55473 +0,StartImagePull_Service,1697650897.557092 +0,EndImagePull_Service,1697650903.001556 +0,StartCreateContainer_Service,1697650903.004573 +0,EndCreateContainer_Service,1697650903.008505 +0,StartImagePull_Sidecar,1697650903.065245 +0,EndImagePull_Sidecar,1697650905.603725 +0,StartCreateContainer_Sidecar,1697650905.607207 +0,EndCreateContainer_Sidecar,1697650905.611087 +0,StartStartContainer_Service,1697650905.61185 +0,StartStartContainer_Sidecar,1697650905.61185 +0,EndStartContainer_Service,1697650905.662457 +0,EndStartContainer_Sidecar,1697650905.662457 +0,Ready,1697650906.0 +0,ContainersReady,1697650906.0 +1,Initialized,1697650913.0 +1,PodScheduled,1697650913.0 +1,Start,1697650913.2899218 +1,StartRunPodSandbox,1697650914.168255 +1,EndRunPodSandbox,1697650915.522901 +1,StartImagePull_Service,1697650915.525045 +1,EndImagePull_Service,1697650921.298181 +1,StartCreateContainer_Service,1697650921.300978 +1,EndCreateContainer_Service,1697650921.304536 +1,StartImagePull_Sidecar,1697650921.359596 +1,EndImagePull_Sidecar,1697650923.689171 +1,StartCreateContainer_Sidecar,1697650923.692792 +1,EndCreateContainer_Sidecar,1697650923.696781 +1,StartStartContainer_Service,1697650923.697453 +1,StartStartContainer_Sidecar,1697650923.697453 +1,EndStartContainer_Service,1697650923.761691 +1,EndStartContainer_Sidecar,1697650923.761691 +1,Ready,1697650924.0 +1,ContainersReady,1697650924.0 +2,Start,1697650931.3649948 +2,Initialized,1697650932.0 +2,PodScheduled,1697650932.0 +2,StartRunPodSandbox,1697650932.499513 +2,EndRunPodSandbox,1697650933.874433 +2,StartImagePull_Service,1697650933.876964 +2,EndImagePull_Service,1697650939.542831 +2,StartCreateContainer_Service,1697650939.545308 +2,EndCreateContainer_Service,1697650939.548812 +2,StartImagePull_Sidecar,1697650954.48037 +2,EndImagePull_Sidecar,1697650956.656542 +2,StartCreateContainer_Sidecar,1697650956.66024 +2,EndCreateContainer_Sidecar,1697650956.667226 +2,StartStartContainer_Service,1697650956.667863 +2,StartStartContainer_Sidecar,1697650956.667863 +2,EndStartContainer_Service,1697650956.719424 +2,EndStartContainer_Sidecar,1697650956.719424 +2,Ready,1697650957.0 +2,ContainersReady,1697650957.0 diff --git a/setup.cfg b/setup.cfg index ee07cfa..e209871 100644 --- a/setup.cfg +++ b/setup.cfg @@ -4,3 +4,5 @@ [flake8] max-line-length = 88 extend-ignore = E203 +[pycodestyle] +max-line-length = 88 diff --git a/tasks/eval/startup.py b/tasks/eval/startup.py index 7427659..35019aa 100644 --- a/tasks/eval/startup.py +++ b/tasks/eval/startup.py @@ -92,7 +92,8 @@ def cleanup_after_run(baseline, used_ctr_images): """ This method is called after each experiment run """ - if baseline in ["docker", "kata"]: + # The Kata baseline we use also pulls iamges directly on the host + if baseline in ["docker"]: clean_container_images(used_ctr_images) @@ -299,9 +300,6 @@ def plot(ctx): for csv in glob(glob_str): baseline = basename(csv).split(".")[0].split("_")[0] flavour = basename(csv).split(".")[0].split("_")[1] - if baseline == "kata": - # TODO: kata baseline does not work - continue if baseline not in results_dict: results_dict[baseline] = {} @@ -430,7 +428,7 @@ def plot(ctx): acc_ys[i] += ys[i] # Misc - ax.set_xticks(xs, xlabels) + ax.set_xticks(xs, xlabels, rotation=45) ax.set_xlabel("Baseline") ax.set_ylabel("Time [s]") ax.set_title("End-to-end latency to start a pod\n(cold start='/' - warm start='.')") diff --git a/tasks/eval/util/env.py b/tasks/eval/util/env.py index f46739b..e984c5c 100644 --- a/tasks/eval/util/env.py +++ b/tasks/eval/util/env.py @@ -17,18 +17,15 @@ "signature_verification": "", "signature_policy": "", }, - # This baseline uses plain Knative on Kata containers (i.e. VMs) - # Unfortunately, we can't run baseline kata as we need to use the CCv0 - # fork with CoCo, and we had to patch the agent in that version to run wiht - # image revisions - # TODO: consider fixing - # "kata": { - # "runtime_class": "kata", - # "image_tag": "unencrypted", - # "guest_attestation": "", - # "signature_verification": "", - # "signature_policy": "", - # }, + # This baseline uses plain Knative on CoCo, but without SEV-enabled VMs + # (so all CoCo machinery, but no runtime memory encryption) + "kata": { + "runtime_class": "kata-qemu", + "image_tag": "unencrypted", + "guest_attestation": "", + "signature_verification": "", + "signature_policy": "", + }, # This baseline uses Knative on confidential VMs with Kata, but does not # have any kind of attestation feature. This is an _insecure_ baseline, # and only included for demonstration purposes diff --git a/tasks/kata.py b/tasks/kata.py index e5b3a25..273972c 100644 --- a/tasks/kata.py +++ b/tasks/kata.py @@ -3,7 +3,7 @@ from os.path import dirname, join from subprocess import run from tasks.util.env import KATA_CONFIG_DIR, KATA_IMG_DIR, PROJ_ROOT -from tasks.util.toml import update_toml +from tasks.util.toml import remove_entry_from_toml, update_toml KATA_RUNTIMES = ["qemu", "qemu-sev"] KATA_SOURCE_DIR = join(PROJ_ROOT, "..", "kata-containers") @@ -58,7 +58,6 @@ def replace_agent(ctx, agent_source_dir=KATA_AGENT_SOURCE_DIR): 4. Re-build the initrd 5. Update the kata config to point to the new initrd """ - conf_file_path = join(KATA_CONFIG_DIR, "configuration-qemu-sev.toml") # Use a hardcoded path, as we want to always start from a _clean_ initrd initrd_path = join(KATA_IMG_DIR, "kata-containers-initrd-sev.img") @@ -105,10 +104,15 @@ def replace_agent(ctx, agent_source_dir=KATA_AGENT_SOURCE_DIR): run(initrd_pack_cmd, shell=True, check=True, env=work_env) # Lastly, update the Kata config to point to the new initrd - updated_toml_str = """ - [hypervisor.qemu] - initrd = "{new_initrd_path}" - """.format( - new_initrd_path=new_initrd_path - ) - update_toml(conf_file_path, updated_toml_str) + for runtime in KATA_RUNTIMES: + conf_file_path = join(KATA_CONFIG_DIR, "configuration-{}.toml".format(runtime)) + updated_toml_str = """ + [hypervisor.qemu] + initrd = "{new_initrd_path}" + """.format( + new_initrd_path=new_initrd_path + ) + update_toml(conf_file_path, updated_toml_str) + + if runtime == "qemu": + remove_entry_from_toml(conf_file_path, "hypervisor.qemu.image") diff --git a/tasks/knative.py b/tasks/knative.py index 50caa8f..17366c8 100644 --- a/tasks/knative.py +++ b/tasks/knative.py @@ -146,6 +146,9 @@ def install(ctx): run_kubectl_command(kube_cmd) wait_for_pods_in_ns(KNATIVE_NAMESPACE, label="app=default-domain") + # Replace the sidecar to use an image we control + replace_sidecar(ctx) + print("Succesfully deployed Knative! The external IP is: {}".format(actual_ip)) diff --git a/tasks/util/containerd.py b/tasks/util/containerd.py index d6849e7..5e6ecff 100644 --- a/tasks/util/containerd.py +++ b/tasks/util/containerd.py @@ -4,7 +4,7 @@ def get_journalctl_containerd_logs(): - journalctl_cmd = 'sudo journalctl -xeu containerd --since "10 min ago" -o json' + journalctl_cmd = 'sudo journalctl -xeu containerd --since "1 min ago" -o json' out = ( run(journalctl_cmd, shell=True, capture_output=True) .stdout.decode("utf-8") @@ -14,27 +14,6 @@ def get_journalctl_containerd_logs(): return out -def get_time_pulling_image(image_name): - """ - Retrieve the start and end timestamp (in epoch floating seconds) for the - PullImage event from containerd - """ - out = get_journalctl_containerd_logs() - - pull_image_json = [] - for o in out: - o_json = json_loads(o) - if "PullImage" in o_json["MESSAGE"] and image_name in o_json["MESSAGE"]: - pull_image_json.append(o_json) - - assert len(pull_image_json) >= 2 - - start_ts = int(pull_image_json[-2]["__REALTIME_TIMESTAMP"]) / 1e6 - end_ts = int(pull_image_json[-1]["__REALTIME_TIMESTAMP"]) / 1e6 - - return start_ts, end_ts - - def get_start_end_ts_for_containerd_event(event_name, event_id, lower_bound=None): """ Get the start and end timestamps (in epoch floating seconds) for a given @@ -52,24 +31,51 @@ def get_start_end_ts_for_containerd_event(event_name, event_id, lower_bound=None event_json = [] for o in out: o_json = json_loads(o) - if event_name in o_json["MESSAGE"] and event_id in o_json["MESSAGE"]: - event_json.append(o_json) - - assert len(event_json) >= 2 + if ( + o_json is None + or "MESSAGE" not in o_json + or o_json["MESSAGE"] is None + ): + # Sometimes, after resetting containerd, some of the + # journal messages won't have a "MESSAGE" in it, so we skip + # them + continue + try: + if ( + event_name in o_json["MESSAGE"] + and event_id in o_json["MESSAGE"] + ): + event_json.append(o_json) + except TypeError as e: + print(o_json) + print(e) + raise e + + assert len(event_json) >= 2, "Not enough events in log: {} !>= 2".format( + len(event_json) + ) start_ts = int(event_json[-2]["__REALTIME_TIMESTAMP"]) / 1e6 end_ts = int(event_json[-1]["__REALTIME_TIMESTAMP"]) / 1e6 - assert end_ts > start_ts + assert ( + end_ts > start_ts + ), "End and start timestamp not in order: {} !> {}".format(end_ts, start_ts) if lower_bound is not None: - assert start_ts > lower_bound + assert ( + start_ts > lower_bound + ), "Provided timestamp smaller than lower bound: {} !> {}".format( + start_ts, lower_bound + ) return start_ts, end_ts - except AssertionError: + except AssertionError as e: + print(e) print( - "WARNING: Failed getting event {} (attempt {}/{})".format( + "WARNING: Failed getting event {} (id: {}) (attempt {}/{})".format( event_name, + event_id, i + 1, num_repeats, ) diff --git a/tasks/util/toml.py b/tasks/util/toml.py index afebde1..f539f04 100644 --- a/tasks/util/toml.py +++ b/tasks/util/toml.py @@ -82,3 +82,35 @@ def read_value_from_toml(toml_file_path, toml_path): raise RuntimeError("Haven't reached TOML leaf!") return toml_file + + +def do_remove_entry_from_toml(toml_dict, toml_path): + toml_levels = toml_path.split(".") + dict_key = toml_levels[0] + + if dict_key not in toml_dict: + return toml_dict + + if not isinstance(toml_dict[dict_key], dict): + del toml_dict[dict_key] + return toml_dict + + toml_dict[dict_key] = do_remove_entry_from_toml( + toml_dict[dict_key], + ".".join(toml_levels[1:]), + ) + + return toml_dict + + +def remove_entry_from_toml(toml_file_path, toml_path): + """ + Remove an entry (and all its descendants) from a TOML specified by a path. + This method returns silently if the specified path does not exist. + """ + toml_file = toml_load(toml_file_path) + + toml_file = do_remove_entry_from_toml(toml_file, toml_path) + + with open(toml_file_path, "w") as fh: + toml_dump(toml_file, fh)