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

Commit 8563c5e

Browse files
committed
CR changes
1 parent a9e678b commit 8563c5e

File tree

9 files changed

+65
-32
lines changed

9 files changed

+65
-32
lines changed

README.rst

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,6 @@ How to support your specific jdk
1111
| 'java-toolkit jmap PID_HERE'
1212
| 'java-toolkit jstack PID_HERE'
1313
14-
| For building you can either use skaffold or gcloud
15-
| For gcloud run the following command
16-
| 'gcloud builds submit --config ./cloudbuild.yaml .'
14+
| For building you can use skaffold
15+
| For running on Google Cloud we have a faster build with skaffold
16+
| 'skaffold run -p gcloud-build'

cloudbuild.yaml

Lines changed: 0 additions & 6 deletions
This file was deleted.

dockerfile

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -15,10 +15,6 @@ COPY src /app/src
1515

1616
RUN /root/.local/bin/poetry install
1717
RUN cat additional_bash_commands.sh >> ~/.bashrc
18-
#COPY jdk_11_9 /app/openjdk3
1918
COPY --from=openjdk:11.0.14-jdk /usr/local/openjdk-11 /app/openjdk
20-
#COPY --from=adoptopenjdk/openjdk11-openj9:jdk-11.0.14_9_openj9-0.30.0-alpine /opt/java/openjdk /app/openjdk2
2119

22-
CMD exec /bin/bash -c "trap : TERM INT; sleep infinity & wait"
23-
24-
#run on jenkens
20+
CMD exec /bin/bash -c "trap : TERM INT; sleep infinity & wait"

java_test_pod/Dockerfile

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,6 @@ RUN ["jar", "-cvfm", "HelloWorld.jar", "/java_files/manifest.MF", "/hello_world/
77

88
FROM openjdk:11.0.14-jre
99
COPY --from=0 /HelloWorld.jar ./
10-
RUN apt-get update && apt-get install -y procps inotify-tools
10+
RUN apt-get update
1111
ENTRYPOINT ["java", "-jar", "HelloWorld.jar", "1111"]
1212

java_test_pod/build_on_apple_m1.sh

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
docker buildx build \
2+
--platform linux/amd64 \
3+
--tag $IMAGE \
4+
--push \
5+
$BUILD_CONTEXT

java_test_pod/skaffold.yaml

Lines changed: 38 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,38 @@
1+
apiVersion: skaffold/v2beta1
2+
kind: Config
3+
metadata:
4+
name: java-test-pod
5+
build:
6+
artifacts:
7+
- image: gcr.io/genuine-flight-317411/java-toolkit/test_java_pod
8+
docker:
9+
dockerfile: dockerfile
10+
local:
11+
push: true
12+
concurrency: 0
13+
deploy:
14+
kubectl:
15+
manifests:
16+
- test_pod_config.yaml
17+
18+
19+
profiles:
20+
- name: apple-m1-dev
21+
build:
22+
artifacts:
23+
- image: gcr.io/genuine-flight-317411/java-toolkit/test_java_pod
24+
context: .
25+
custom:
26+
buildCommand: ./build_on_apple_m1.sh
27+
local:
28+
push: true
29+
concurrency: 0
30+
- name: gcloud-build
31+
build:
32+
googleCloudBuild:
33+
projectId: genuine-flight-317411
34+
artifacts:
35+
- image: gcr.io/genuine-flight-317411/java-toolkit/test_java_pod
36+
context: .
37+
docker:
38+
dockerfile: Dockerfile

skaffold.yaml

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -27,3 +27,12 @@ profiles:
2727
local:
2828
push: true
2929
concurrency: 0
30+
- name: gcloud-build
31+
build:
32+
googleCloudBuild:
33+
projectId: genuine-flight-317411
34+
artifacts:
35+
- image: us-central1-docker.pkg.dev/genuine-flight-317411/java-toolkit/jtk-11
36+
context: .
37+
docker:
38+
dockerfile: dockerfile

src/java_toolkit/common/utils/remote_ns_cmd.py

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,6 @@ def run_command(cmd: str, verbose: bool):
1111
typer.echo(f"output recieved: \n{output.decode()}")
1212
return output.decode()
1313

14-
def run_cmd_in_proc_namespace(pid, command_to_run, verbose):
15-
NSENTER_CMD = "nsenter -t {} -p -m {}"
16-
nsenter_cmd_formatted = NSENTER_CMD.format(pid, command_to_run)
17-
return run_command(nsenter_cmd_formatted, verbose)
14+
def run_cmd_in_proc_namespace(pid: int, command_to_run: str, verbose: bool):
15+
nsenter_cmd = f"nsenter -t {pid} -a {command_to_run}"
16+
return run_command(nsenter_cmd, verbose)

src/java_toolkit/common/utils/tmp_mount.py

Lines changed: 5 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -2,31 +2,23 @@
22
from os import path
33

44
class TmpRemotePodMounter(object):
5-
remote_mnt_path =""
6-
local_mnt_path =""
7-
src_dir =""
8-
verbose = False
9-
MKDIR_POD_CMD="mkdir -p {}"
10-
RMDIR_POD_CMD="rm -R {}"
11-
COPY_CMD="cp -R {} {}"
12-
ROOT_PROC_NS="/proc/{}/cwd{}"
135

146
def __init__(self, pid: str, src_dir: str, local_mnt_path: str, verbose: bool):
157
self.verbose = verbose
168
self.src_dir = src_dir
179
self.local_mnt_path = local_mnt_path
18-
self.remote_mnt_path = self.ROOT_PROC_NS.format(pid,local_mnt_path)
10+
self.remote_mnt_path = f"/proc/{pid}/cwd{local_mnt_path}"
1911

2012
def __enter__(self):
21-
mkdir_cmd = self.MKDIR_POD_CMD.format(self.remote_mnt_path)
13+
mkdir_cmd = f"mkdir -p {self.remote_mnt_path}"
2214
run_command(mkdir_cmd, self.verbose)
23-
cp_cmd=self.COPY_CMD.format(self.src_dir, self.remote_mnt_path)
15+
cp_cmd= f"cp -R {self.src_dir} {self.remote_mnt_path}"
2416
run_command(cp_cmd, self.verbose)
2517
return self
2618

2719
def get_mounted_jdk_dir(self):
28-
return path.join(self.local_mnt_path, path.basename(self.src_dir) )
20+
return path.join(self.local_mnt_path, path.basename(self.src_dir) )
2921

3022
def __exit__(self, exc_type, exc_val, exc_tb):
31-
rm_dir_cmd = self.RMDIR_POD_CMD.format(self.remote_mnt_path)
23+
rm_dir_cmd = f"rm -R {self.remote_mnt_path}"
3224
run_command(rm_dir_cmd, self.verbose)

0 commit comments

Comments
 (0)