Skip to content
This repository was archived by the owner on Feb 6, 2025. It is now read-only.

Commit

Permalink
Update cluster init before upgrade
Browse files Browse the repository at this point in the history
  • Loading branch information
mjura committed May 15, 2020
1 parent ae9b80b commit 97f0128
Showing 1 changed file with 25 additions and 4 deletions.
29 changes: 25 additions & 4 deletions ci/infra/testrunner/skuba/skuba.py
Original file line number Diff line number Diff line change
Expand Up @@ -50,18 +50,20 @@ def cluster_deploy(self, kubernetes_version=None, cloud_provider=None,


@step
def cluster_init(self, kubernetes_version=None, cloud_provider=None):
def cluster_init(self, kubernetes_version=None, cloud_provider=None, path=None):
logger.debug("Cleaning up any previous cluster dir")
self.utils.cleanup_file(self.cluster_dir)

k8s_version_option, cloud_provider_option = "", ""
k8s_version_option, cloud_provider_option, path = "", "", ""
if kubernetes_version:
k8s_version_option = "--kubernetes-version {}".format(kubernetes_version)
if cloud_provider:
cloud_provider_option = "--cloud-provider {}".format(type(self.platform).__name__.lower())
if path:
path_option = "{}/".format(path)

cmd = "cluster init --control-plane {} {} {} test-cluster".format(self.platform.get_lb_ipaddr(),
k8s_version_option, cloud_provider_option)
cmd = "cluster init --control-plane {} {} {} {}test-cluster".format(self.platform.get_lb_ipaddr(),
k8s_version_option, cloud_provider_option, path_option)
# Override work directory, because init must run in the parent directory of the
# cluster directory
self._run_skuba(cmd, cwd=self.workdir)
Expand Down Expand Up @@ -154,6 +156,10 @@ def node_remove(self, role="worker", nr=0):
def node_upgrade(self, action, role, nr, ignore_errors=False):
self._verify_bootstrap_dependency()

self.cluster_init("", "", "/tmp")
cmd = "rsync -a /tmp/test-cluster/addons/ addons/"
_run_os_cmd(cmd)

if role not in ("master", "worker"):
raise ValueError("Invalid role '{}'".format(role))

Expand Down Expand Up @@ -223,3 +229,18 @@ def _run_skuba(self, cmd, cwd=None, verbosity=None, ignore_errors=False):
cwd=cwd,
ignore_errors=ignore_errors,
)

def _run_os_cmd(self, cmd, cwd=None, ignore_errors=False):
"""Running shell command.
The cwd defautls to cluster_dir but can be overrided
for example, for the init command that must run in {workspace}
"""

if cwd is None:
cwd = self.cluster_dir

return self.utils.runshellcommand(
cmd=cmd,
cwd=cwd,
ignore_errors=ignore_errors,
)

0 comments on commit 97f0128

Please sign in to comment.