Skip to content

Commit 8e99505

Browse files
committed
Merge branch 'master' of https://github.com/litmuschaos/litmus-go into distributed-tracing
Signed-off-by: namkyu1999 <[email protected]>
2 parents 1414368 + fc646d6 commit 8e99505

File tree

15 files changed

+157
-218
lines changed

15 files changed

+157
-218
lines changed

.github/workflows/build.yml

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ jobs:
1212
# Install golang
1313
- uses: actions/setup-go@v2
1414
with:
15-
go-version: 1.18
15+
go-version: '1.20'
1616

1717
- uses: actions/checkout@v2
1818
with:
@@ -56,7 +56,7 @@ jobs:
5656
# Install golang
5757
- uses: actions/setup-go@v2
5858
with:
59-
go-version: 1.18
59+
go-version: '1.20'
6060

6161
- uses: actions/checkout@v2
6262
with:
@@ -80,6 +80,7 @@ jobs:
8080
file: build/Dockerfile
8181
platforms: linux/amd64,linux/arm64
8282
tags: litmuschaos/go-runner:ci
83+
build-args: LITMUS_VERSION=3.10.0
8384

8485
trivy:
8586
needs: pre-checks
@@ -91,7 +92,7 @@ jobs:
9192

9293
- name: Build an image from Dockerfile
9394
run: |
94-
docker build -f build/Dockerfile -t docker.io/litmuschaos/go-runner:${{ github.sha }} . --build-arg TARGETARCH=amd64
95+
docker build -f build/Dockerfile -t docker.io/litmuschaos/go-runner:${{ github.sha }} . --build-arg TARGETARCH=amd64 --build-arg LITMUS_VERSION=3.10.0
9596
9697
- name: Run Trivy vulnerability scanner
9798
uses: aquasecurity/trivy-action@master

.github/workflows/push.yml

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ jobs:
1313
# Install golang
1414
- uses: actions/setup-go@v2
1515
with:
16-
go-version: 1.18
16+
go-version: '1.20'
1717
- uses: actions/checkout@v2
1818

1919
#TODO: Add Dockerfile linting
@@ -43,7 +43,7 @@ jobs:
4343
# Install golang
4444
- uses: actions/setup-go@v2
4545
with:
46-
go-version: 1.18
46+
go-version: '1.20'
4747
- uses: actions/checkout@v2
4848

4949
- name: Set up QEMU
@@ -69,4 +69,5 @@ jobs:
6969
push: true
7070
file: build/Dockerfile
7171
platforms: linux/amd64,linux/arm64
72-
tags: litmuschaos/go-runner:ci
72+
tags: litmuschaos/go-runner:ci
73+
build-args: LITMUS_VERSION=3.10.0

.github/workflows/release.yml

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ jobs:
1212
# Install golang
1313
- uses: actions/setup-go@v2
1414
with:
15-
go-version: 1.18
15+
go-version: '1.20'
1616
- uses: actions/checkout@v2
1717

1818
#TODO: Add Dockerfile linting
@@ -28,7 +28,7 @@ jobs:
2828
# Install golang
2929
- uses: actions/setup-go@v2
3030
with:
31-
go-version: 1.18
31+
go-version: '1.20'
3232
- uses: actions/checkout@v2
3333

3434
- name: Set Tag
@@ -67,4 +67,5 @@ jobs:
6767
push: true
6868
file: build/Dockerfile
6969
platforms: linux/amd64,linux/arm64
70-
tags: litmuschaos/go-runner:${{ env.RELEASE_TAG }},litmuschaos/go-runner:latest
70+
tags: litmuschaos/go-runner:${{ env.RELEASE_TAG }},litmuschaos/go-runner:latest
71+
build-args: LITMUS_VERSION=3.10.0

.github/workflows/run-e2e-on-pr-commits.yml

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ jobs:
1717
# Install golang
1818
- uses: actions/setup-go@v5
1919
with:
20-
go-version: 1.18
20+
go-version: '1.20'
2121

2222
- uses: actions/checkout@v2
2323
with:
@@ -74,7 +74,7 @@ jobs:
7474
# Install golang
7575
- uses: actions/setup-go@v5
7676
with:
77-
go-version: 1.18
77+
go-version: '1.20'
7878

7979
- uses: actions/checkout@v2
8080
with:
@@ -133,7 +133,7 @@ jobs:
133133
# Install golang
134134
- uses: actions/setup-go@v5
135135
with:
136-
go-version: 1.18
136+
go-version: '1.20'
137137

138138
- uses: actions/checkout@v2
139139
with:

.github/workflows/security-scan.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ jobs:
1414

1515
- name: Build an image from Dockerfile
1616
run: |
17-
docker build -f build/Dockerfile -t docker.io/litmuschaos/go-runner:${{ github.sha }} . --build-arg TARGETARCH=amd64
17+
docker build -f build/Dockerfile -t docker.io/litmuschaos/go-runner:${{ github.sha }} . --build-arg TARGETARCH=amd64 --build-arg LITMUS_VERSION=3.9.0
1818
1919
- name: Run Trivy vulnerability scanner
2020
uses: aquasecurity/trivy-action@master

Makefile

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -72,15 +72,15 @@ image-push:
7272
@echo "--> Push go-runner image"
7373
@echo "------------------------"
7474
@echo "Pushing $(DOCKER_REPO)/$(DOCKER_IMAGE):$(DOCKER_TAG)"
75-
@docker buildx build . --push --file build/Dockerfile --progress plane --platform linux/arm64,linux/amd64 --no-cache --tag $(DOCKER_REGISTRY)/$(DOCKER_REPO)/$(DOCKER_IMAGE):$(DOCKER_TAG)
75+
@docker buildx build . --push --file build/Dockerfile --progress plain --platform linux/arm64,linux/amd64 --no-cache --tag $(DOCKER_REGISTRY)/$(DOCKER_REPO)/$(DOCKER_IMAGE):$(DOCKER_TAG)
7676

7777

7878
.PHONY: build-amd64
7979
build-amd64:
8080
@echo "-------------------------"
8181
@echo "--> Build go-runner image"
8282
@echo "-------------------------"
83-
@sudo docker build --file build/Dockerfile --tag $(DOCKER_REGISTRY)/$(DOCKER_REPO)/$(DOCKER_IMAGE):$(DOCKER_TAG) . --build-arg TARGETARCH=amd64
83+
@sudo docker build --file build/Dockerfile --tag $(DOCKER_REGISTRY)/$(DOCKER_REPO)/$(DOCKER_IMAGE):$(DOCKER_TAG) . --build-arg TARGETARCH=amd64 --build-arg LITMUS_VERSION=3.9.0
8484

8585
.PHONY: push-amd64
8686
push-amd64:

build/Dockerfile

Lines changed: 87 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -14,27 +14,98 @@ RUN export GOOS=${TARGETOS} && \
1414
RUN CGO_ENABLED=0 go build -o /output/experiments ./bin/experiment
1515
RUN CGO_ENABLED=0 go build -o /output/helpers ./bin/helper
1616

17-
FROM alpine:3.15.0 AS dep
17+
# Packaging stage
18+
FROM registry.access.redhat.com/ubi9/ubi:9.4
19+
20+
LABEL maintainer="LitmusChaos"
21+
22+
ARG TARGETARCH
23+
ARG LITMUS_VERSION
1824

1925
# Install generally useful things
20-
RUN apk --update add \
21-
sudo \
22-
iproute2 \
23-
iptables
26+
RUN yum install -y \
27+
sudo \
28+
sshpass \
29+
procps
30+
31+
# tc binary
32+
RUN yum install -y https://dl.rockylinux.org/pub/rocky/9/devel/$(uname -m)/os/Packages/i/iproute-6.2.0-6.el9_4.$(uname -m).rpm
33+
RUN yum install -y https://dl.rockylinux.org/pub/rocky/9/devel/$(uname -m)/os/Packages/i/iproute-tc-6.2.0-6.el9_4.$(uname -m).rpm
34+
35+
# iptables
36+
RUN yum install -y https://dl.rockylinux.org/pub/rocky/9/devel/$(uname -m)/os/Packages/i/iptables-libs-1.8.10-2.el9.$(uname -m).rpm
37+
RUN yum install -y https://dl.fedoraproject.org/pub/epel/9/Everything/$(uname -m)/Packages/i/iptables-legacy-libs-1.8.10-2.2.el9.$(uname -m).rpm
38+
RUN yum install -y https://dl.fedoraproject.org/pub/epel/9/Everything/$(uname -m)/Packages/i/iptables-legacy-1.8.10-2.2.el9.$(uname -m).rpm
2439

40+
# stress-ng
41+
RUN yum install -y https://yum.oracle.com/repo/OracleLinux/OL9/appstream/$(uname -m)/getPackage/Judy-1.0.5-28.el9.$(uname -m).rpm
42+
RUN yum install -y https://yum.oracle.com/repo/OracleLinux/OL9/appstream/$(uname -m)/getPackage/stress-ng-0.14.00-2.el9.$(uname -m).rpm
2543

26-
# Packaging stage
27-
# Image source: https://github.com/litmuschaos/test-tools/blob/master/custom/hardened-alpine/experiment/Dockerfile
28-
# The base image is non-root (have litmus user) with default litmus directory.
29-
FROM litmuschaos/experiment-alpine
44+
#Installing Kubectl
45+
ENV KUBE_LATEST_VERSION="v1.31.0"
46+
RUN curl -L https://storage.googleapis.com/kubernetes-release/release/${KUBE_LATEST_VERSION}/bin/linux/${TARGETARCH}/kubectl -o /usr/bin/kubectl && \
47+
chmod 755 /usr/bin/kubectl
3048

31-
LABEL maintainer="LitmusChaos"
49+
#Installing crictl binaries
50+
RUN curl -L https://github.com/kubernetes-sigs/cri-tools/releases/download/v1.31.1/crictl-v1.31.1-linux-${TARGETARCH}.tar.gz --output crictl-v1.31.1-linux-${TARGETARCH}.tar.gz && \
51+
tar zxvf crictl-v1.31.1-linux-${TARGETARCH}.tar.gz -C /sbin && \
52+
chmod 755 /sbin/crictl
53+
54+
#Installing promql cli binaries
55+
RUN curl -L https://github.com/chaosnative/promql-cli/releases/download/3.0.0-beta6/promql_linux_${TARGETARCH} --output /usr/bin/promql && chmod 755 /usr/bin/promql
56+
57+
#Installing pause cli binaries
58+
RUN curl -L https://github.com/litmuschaos/test-tools/releases/download/${LITMUS_VERSION}/pause-linux-${TARGETARCH} --output /usr/bin/pause && chmod 755 /usr/bin/pause
59+
60+
#Installing dns_interceptor cli binaries
61+
RUN curl -L https://github.com/litmuschaos/test-tools/releases/download/${LITMUS_VERSION}/dns_interceptor --output /sbin/dns_interceptor && chmod 755 /sbin/dns_interceptor
62+
63+
#Installing nsutil cli binaries
64+
RUN curl -L https://github.com/litmuschaos/test-tools/releases/download/${LITMUS_VERSION}/nsutil-linux-${TARGETARCH} --output /sbin/nsutil && chmod 755 /sbin/nsutil
3265

33-
COPY --from=builder /output/ /litmus
34-
COPY --from=dep /usr/bin/sudo /usr/bin/sudo
35-
COPY --from=dep /usr/lib/sudo /usr/lib/sudo
36-
COPY --from=dep /sbin/tc /sbin/
37-
COPY --from=dep /sbin/iptables /sbin/
66+
#Installing nsutil shared lib
67+
RUN curl -L https://github.com/litmuschaos/test-tools/releases/download/${LITMUS_VERSION}/nsutil_${TARGETARCH}.so --output /usr/local/lib/nsutil.so && chmod 755 /usr/local/lib/nsutil.so
68+
69+
# Installing toxiproxy binaries
70+
RUN curl -L https://litmus-http-proxy.s3.amazonaws.com/cli/cli/toxiproxy-cli-linux-${TARGETARCH}.tar.gz --output toxiproxy-cli-linux-${TARGETARCH}.tar.gz && \
71+
tar zxvf toxiproxy-cli-linux-${TARGETARCH}.tar.gz -C /sbin/ && \
72+
chmod 755 /sbin/toxiproxy-cli
73+
RUN curl -L https://litmus-http-proxy.s3.amazonaws.com/server/server/toxiproxy-server-linux-${TARGETARCH}.tar.gz --output toxiproxy-server-linux-${TARGETARCH}.tar.gz && \
74+
tar zxvf toxiproxy-server-linux-${TARGETARCH}.tar.gz -C /sbin/ && \
75+
chmod 755 /sbin/toxiproxy-server
76+
77+
ENV APP_USER=litmus
78+
ENV APP_DIR="/$APP_USER"
79+
ENV DATA_DIR="$APP_DIR/data"
80+
81+
# The USERD_ID of user
82+
ENV APP_USER_ID=2000
83+
RUN useradd -s /bin/true -u $APP_USER_ID -m -d $APP_DIR $APP_USER
84+
85+
# change to 0(root) group because openshift will run container with arbitrary uid as a member of root group
86+
RUN chgrp -R 0 "$APP_DIR" && chmod -R g=u "$APP_DIR"
87+
88+
# Giving sudo to all users (required for almost all experiments)
89+
RUN echo 'ALL ALL=(ALL:ALL) NOPASSWD: ALL' >> /etc/sudoers
90+
91+
WORKDIR $APP_DIR
92+
93+
COPY --from=builder /output/ .
94+
95+
COPY --from=docker:27.0.3 /usr/local/bin/docker /sbin/docker
96+
RUN chmod 755 /sbin/docker
97+
98+
# Set permissions and ownership for the copied binaries
99+
RUN chmod 755 ./experiments ./helpers && \
100+
chown ${APP_USER}:0 ./experiments ./helpers
101+
102+
# Set ownership for binaries in /sbin and /usr/bin
103+
RUN chown ${APP_USER}:0 /sbin/* /usr/bin/* && \
104+
chown root:root /usr/bin/sudo && \
105+
chmod 4755 /usr/bin/sudo
38106

39107
# Copying Necessary Files
40-
COPY ./pkg/cloud/aws/common/ssm-docs/LitmusChaos-AWS-SSM-Docs.yml .
108+
COPY ./pkg/cloud/aws/common/ssm-docs/LitmusChaos-AWS-SSM-Docs.yml ./LitmusChaos-AWS-SSM-Docs.yml
109+
RUN chown ${APP_USER}:0 ./LitmusChaos-AWS-SSM-Docs.yml && chmod 755 ./LitmusChaos-AWS-SSM-Docs.yml
110+
111+
USER ${APP_USER}

chaoslib/litmus/ec2-terminate-by-tag/lib/ec2-terminate-by-tag.go

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -224,14 +224,14 @@ func injectChaosInParallelMode(experimentsDetails *experimentTypes.ExperimentDet
224224
// SetTargetInstance will select the target instance which are in running state and filtered from the given instance tag
225225
func SetTargetInstance(experimentsDetails *experimentTypes.ExperimentDetails) error {
226226

227-
instanceIDList, err := awslib.GetInstanceList(experimentsDetails.InstanceTag, experimentsDetails.Region)
227+
instanceIDList, err := awslib.GetInstanceList(experimentsDetails.Ec2InstanceTag, experimentsDetails.Region)
228228
if err != nil {
229229
return stacktrace.Propagate(err, "failed to get the instance id list")
230230
}
231231
if len(instanceIDList) == 0 {
232232
return cerrors.Error{
233233
ErrorCode: cerrors.ErrorTypeTargetSelection,
234-
Reason: fmt.Sprintf("no instance found with the given tag %v, in region %v", experimentsDetails.InstanceTag, experimentsDetails.Region),
234+
Reason: fmt.Sprintf("no instance found with the given tag %v, in region %v", experimentsDetails.Ec2InstanceTag, experimentsDetails.Region),
235235
}
236236
}
237237

@@ -249,7 +249,7 @@ func SetTargetInstance(experimentsDetails *experimentTypes.ExperimentDetails) er
249249
return cerrors.Error{
250250
ErrorCode: cerrors.ErrorTypeChaosInject,
251251
Reason: "failed to get any running instance",
252-
Target: fmt.Sprintf("EC2 Instance Tag: %v", experimentsDetails.InstanceTag)}
252+
Target: fmt.Sprintf("EC2 Instance Tag: %v", experimentsDetails.Ec2InstanceTag)}
253253
}
254254

255255
log.InfoWithValues("[Info]: Targeting the running instances filtered from instance tag", logrus.Fields{

chaoslib/litmus/http-chaos/helper/http-helper.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -225,7 +225,7 @@ const NoProxyToKill = "you need to specify whom to kill"
225225
// it is using nsenter command to enter into network namespace of target container
226226
// and execute the proxy related command inside it.
227227
func killProxy(pid int, source string) error {
228-
stopProxyServerCommand := fmt.Sprintf("sudo nsenter -t %d -n sudo kill -9 $(ps aux | grep [t]oxiproxy | awk 'FNR==1{print $1}')", pid)
228+
stopProxyServerCommand := fmt.Sprintf("sudo nsenter -t %d -n sudo kill -9 $(ps aux | grep [t]oxiproxy | awk 'FNR==2{print $2}')", pid)
229229
log.Infof("[Chaos]: Stopping proxy server")
230230

231231
if err := common.RunBashCommand(stopProxyServerCommand, "failed to stop proxy server", source); err != nil {

experiments/kube-aws/ec2-terminate-by-tag/experiment/ec2-terminate-tag.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -71,7 +71,7 @@ func EC2TerminateByTag(clients clients.ClientSets) {
7171
log.InfoWithValues("The instance information is as follows", logrus.Fields{
7272
"Chaos Duration": experimentsDetails.ChaosDuration,
7373
"Chaos Namespace": experimentsDetails.ChaosNamespace,
74-
"Instance Tag": experimentsDetails.InstanceTag,
74+
"Instance Tag": experimentsDetails.Ec2InstanceTag,
7575
"Instance Affected Percentage": experimentsDetails.InstanceAffectedPerc,
7676
"Sequence": experimentsDetails.Sequence,
7777
})

0 commit comments

Comments
 (0)