Skip to content

Commit

Permalink
update web-burner plugin (#6)
Browse files Browse the repository at this point in the history
* update web-burner plugin

* Add environment variables

* fix Limitcount calculation

* fix version typo
  • Loading branch information
Harshith-umesh authored Aug 7, 2023
1 parent 78aae5b commit 8b06965
Show file tree
Hide file tree
Showing 4 changed files with 43 additions and 28 deletions.
8 changes: 6 additions & 2 deletions Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -31,14 +31,18 @@ ENV package arcaflow_plugin_kubeburner
RUN dnf -y module install python39 && dnf -y install python39 python39-pip git wget
WORKDIR /app

RUN curl -LO "https://storage.googleapis.com/kubernetes-release/release/$(curl -s https://storage.googleapis.com/kubernetes-release/release/stable.txt)/bin/linux/amd64/kubectl"
RUN chmod +x ./kubectl
RUN mv ./kubectl /usr/local/bin/kubectl

COPY --from=poetry /app/requirements.txt /app/
COPY --from=poetry /htmlcov /htmlcov/
COPY LICENSE /app/
COPY README.md /app/
COPY ${package}/ /app/${package}
RUN git clone https://github.com/redhat-performance/web-burner.git
RUN curl -L https://github.com/cloud-bulldozer/kube-burner/releases/download/v0.14.2/kube-burner-0.14.2-Linux-x86_64.tar.gz | tar xz -C /app/ kube-burner
RUN mv kube-burner kube-burner-0.14.2
RUN curl -L https://github.com/cloud-bulldozer/kube-burner/releases/download/v1.7.2/kube-burner-V1.7.2-Linux-x86_64.tar.gz | tar xz -C /app/ kube-burner
RUN mv kube-burner kube-burner-wb
RUN cp -r /app/web-burner/workload /app/web-burner/objectTemplates /app/
RUN wget https://mirror.openshift.com/pub/openshift-v4/clients/ocp/latest/openshift-client-linux.tar.gz
RUN tar -xzf openshift-client-linux.tar.gz -C /usr/local/bin
Expand Down
35 changes: 15 additions & 20 deletions arcaflow_plugin_kubeburner/helper_functions.py
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ def readkubeconfig(kubeconfig):

def get_prometheus_creds():
cmd = [
"oc", "get", "route", "prometheus-k8s",
"kubectl", "get", "route", "prometheus-k8s",
"-n", "openshift-monitoring",
"-o", 'jsonpath="{.spec.host}"',
]
Expand All @@ -30,44 +30,39 @@ def get_prometheus_creds():

try:
cmd = [
"oc", "create", "token", "prometheus-k8s",
"kubectl", "create", "token", "prometheus-k8s",
"-n", "openshift-monitoring", "--duration=6h",
]
prom_token = subprocess.check_output(cmd, stderr=subprocess.STDOUT)
prom_token = prom_token.decode("utf-8")
except subprocess.CalledProcessError:
try:
cmd = [
"oc", "sa", "new-token", "prometheus-k8s",
"-n", "openshift-monitoring",
]
prom_token = subprocess.check_output(cmd, stderr=subprocess.STDOUT)
prom_token = prom_token.decode("utf-8")
except subprocess.CalledProcessError as error:
return "error", ErrorOutput(
error.returncode,
"{} failed with return code {}:\n{}".format(
error.cmd[0], error.returncode, error.output
),
)
except subprocess.CalledProcessError as error:
return "error", ErrorOutput(
error.returncode,
"{} failed with return code {}:\n{}".format(
error.cmd[0], error.returncode, error.output
),
)

return prom_url, prom_token


def calculate_normal_limit_count(cluster_size):
count = (35 * cluster_size) // 120
if cluster_size >= 4:
count = (35 * cluster_size) // 120
else:
count = 1
return count


def create_kubeconfig_secret():
cmd = [
'oc', 'create', 'secret', 'generic',
'kubectl', 'create', 'secret', 'generic',
'kubeconfig', '--from-file=kubeconfig',
'--dry-run=client', '--output=yaml'
]
secret = subprocess.check_output(cmd, stderr=subprocess.STDOUT)
secret = secret.decode("utf-8")
sys.stdout = open('objectTemplates/secret_kubeconfig.yaml', 'w')
sys.stdout = open('objectTemplates/secret_kubeconfig.yml', 'w')
print(secret)

time.sleep(10)
16 changes: 10 additions & 6 deletions arcaflow_plugin_kubeburner/kubeburner_plugin.py
Original file line number Diff line number Diff line change
Expand Up @@ -102,12 +102,14 @@ def RunWebBurner(
)
os.environ["ES_SERVER"] = str(params.es_server)
os.environ["ES_INDEX"] = str(params.es_index)
os.environ["SRIOV"] = str(params.sriov)
os.environ["BRIDGE"] = str(params.bridge)
prom_url, prom_token = get_prometheus_creds()

try:
print("Creating the SPK pods..")
cmd = [
"./kube-burner-0.14.2", "init",
"./kube-burner-wb", "init",
"-c", "workload/cfg_icni2_serving_resource_init.yml",
"-t", str(prom_token),
"--uuid", "1234",
Expand All @@ -127,12 +129,12 @@ def RunWebBurner(
try:
print("Creating the ICNI2 workload..", params.uuid)
cmd = [
"./kube-burner-0.14.2", "init",
"./kube-burner-wb", "init",
"-c", "workload/" + params.workload_template,
"-t", str(prom_token),
"--uuid", str(params.uuid),
"--prometheus-url", str(prom_url),
"-m", "workload/metrics_full.yaml",
"-m", "workload/metrics_full.yml",
]
process_out = subprocess.check_output(cmd, stderr=subprocess.STDOUT)
except subprocess.CalledProcessError as error:
Expand Down Expand Up @@ -172,17 +174,19 @@ def DeleteWebBurner(
os.environ["LIMITCOUNT"] = str(
calculate_normal_limit_count(params.number_of_nodes)
)
os.environ["SRIOV"] = str(params.sriov)
os.environ["BRIDGE"] = str(params.bridge)
prom_url, prom_token = get_prometheus_creds()

try:
print("Deleting the ICNI2 workload..")
cmd = [
"./kube-burner-0.14.2", "init",
"./kube-burner-wb", "init",
"-c", "workload/" + params.workload_template,
"-t", str(prom_token),
"--uuid", str(params.uuid),
"--prometheus-url", str(prom_url),
"-m", "workload/metrics_full.yaml",
"-m", "workload/metrics_full.yml",
]
process_out = subprocess.check_output(cmd, stderr=subprocess.STDOUT)
except subprocess.CalledProcessError as error:
Expand All @@ -199,7 +203,7 @@ def DeleteWebBurner(
try:
print("Deleting the SPK pods..", params.uuid)
cmd = [
"./kube-burner-0.14.2", "init",
"./kube-burner-wb", "init",
"-c", "workload/cfg_delete_icni2_serving_resource.yml",
"-t", str(prom_token),
"--uuid", "1234",
Expand Down
12 changes: 12 additions & 0 deletions arcaflow_plugin_kubeburner/kubeburner_schema.py
Original file line number Diff line number Diff line change
Expand Up @@ -191,6 +191,18 @@ class WebBurnerInput:
),
] = "false"

sriov: typing.Annotated[
typing.Optional[str],
schema.name("SRIOV"),
schema.description("To enable or disable sriov, disabling it will create macvlan network attachment definitions instead"),
] = "true"

bridge: typing.Annotated[
typing.Optional[str],
schema.name("BRIDGE"),
schema.description("The network bridge to use. breth0 for kind.sh ovn-kubernetes clusters"),
] = "br-ex"


@dataclass
class KubeBurnerInputParams(CommonInputParams, KubeBurnerInput):
Expand Down

0 comments on commit 8b06965

Please sign in to comment.