You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@airflow.apache.org by as...@apache.org on 2021/05/07 12:24:50 UTC

[airflow-ci-infra] 01/01: Cleanup logs and "build state" from the AMI

This is an automated email from the ASF dual-hosted git repository.

ash pushed a commit to branch cleanup-ami
in repository https://gitbox.apache.org/repos/asf/airflow-ci-infra.git

commit b15f21645e7d10d438fd780be91c09d7e4d5a25b
Author: Ash Berlin-Taylor <as...@firemirror.com>
AuthorDate: Fri May 7 13:22:03 2021 +0100

    Cleanup logs and "build state" from the AMI
    
    Not doing this doesn't cause any harm, but it is cleaner to not have
    this state included in the AMI
---
 github-runner-ami/packer/files/cleanup.sh   | 30 +++++++++++++++++++++++++++++
 github-runner-ami/packer/ubuntu2004.pkr.hcl |  1 +
 2 files changed, 31 insertions(+)

diff --git a/github-runner-ami/packer/files/cleanup.sh b/github-runner-ami/packer/files/cleanup.sh
new file mode 100644
index 0000000..4b6443a
--- /dev/null
+++ b/github-runner-ami/packer/files/cleanup.sh
@@ -0,0 +1,30 @@
+#!/bin/bash
+
+# Licensed to the Apache Software Foundation (ASF) under one
+# or more contributor license agreements.  See the NOTICE file
+# distributed with this work for additional information
+# regarding copyright ownership.  The ASF licenses this file
+# to you under the Apache License, Version 2.0 (the
+# "License"); you may not use this file except in compliance
+# with the License.  You may obtain a copy of the License at
+#
+#   http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing,
+# software distributed under the License is distributed on an
+# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+# KIND, either express or implied.  See the License for the
+# specific language governing permissions and limitations
+# under the License.
+
+set -ex
+
+rm ~ubuntu/.ssh/authorized_keys
+
+journalctl --rotate
+sleep 2
+journalctl --vacuum-time=1s
+
+rm -rf /var/lib/cloud/ /var/log/cloud-init*.log
+
+rm -rf /var/cache/* /var/lib/apt/*
diff --git a/github-runner-ami/packer/ubuntu2004.pkr.hcl b/github-runner-ami/packer/ubuntu2004.pkr.hcl
index 294c6cc..fbc8897 100644
--- a/github-runner-ami/packer/ubuntu2004.pkr.hcl
+++ b/github-runner-ami/packer/ubuntu2004.pkr.hcl
@@ -139,6 +139,7 @@ build {
       "./files/install-dependencies.sh",
       "./files/docker-compose.sh",
       "./files/runner_bootstrap.sh",
+      "./files/cleanup.sh",
     ]
     execute_command = "chmod +x '{{ .Path }}'; sudo sh -c '{{ .Vars }} {{ .Path }}'"
     environment_vars = [