Skip to content

Commit

Permalink
chore(enhanc): Make socket path tunable from ENV and refactor Makefile (
Browse files Browse the repository at this point in the history
#242) (#243)

Signed-off-by: Udit Gaurav <[email protected]>
  • Loading branch information
uditgaurav authored Dec 17, 2020
1 parent 59cefce commit 42f9ccc
Show file tree
Hide file tree
Showing 10 changed files with 23 additions and 12 deletions.
17 changes: 11 additions & 6 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,11 @@
#
IS_DOCKER_INSTALLED = $(shell which docker >> /dev/null 2>&1; echo $$?)

# Docker info
DOCKER_REPO ?= litmuschaos
DOCKER_IMAGE ?= go-runner
DOCKER_TAG ?= ci

PACKAGES = $(shell go list ./... | grep -v '/vendor/')

.PHONY: all
Expand Down Expand Up @@ -75,7 +80,7 @@ build:
@echo "-------------------------"
@echo "--> Build go-runner image"
@echo "-------------------------"
@sudo docker buildx build --file build/litmus-go/Dockerfile --progress plane --platform linux/arm64,linux/amd64 --no-cache --tag litmuschaos/go-runner:ci .
@sudo docker buildx build --file build/litmus-go/Dockerfile --progress plane --platform linux/arm64,linux/amd64 --no-cache --tag $(DOCKER_REPO)/$(DOCKER_IMAGE):$(DOCKER_TAG) .

.PHONY: build-amd64
build-amd64:
Expand All @@ -87,15 +92,15 @@ build-amd64:
@echo "-------------------------"
@echo "--> Build go-runner image"
@echo "-------------------------"
@sudo docker build --file build/litmus-go/Dockerfile --tag litmuschaos/go-runner:ci . --build-arg TARGETARCH=amd64
@sudo docker build --file build/litmus-go/Dockerfile --tag $(DOCKER_REPO)/$(DOCKER_IMAGE):$(DOCKER_TAG) . --build-arg TARGETARCH=amd64

.PHONY: push-amd64
push-amd64:

@echo "------------------------------"
@echo "--> Pushing image"
@echo "------------------------------"
@sudo docker push litmuschaos/go-runner:ci
@sudo docker push $(DOCKER_REPO)/$(DOCKER_IMAGE):$(DOCKER_TAG)

.PHONY: push
push: litmus-go-push
Expand All @@ -104,14 +109,14 @@ litmus-go-push:
@echo "-------------------"
@echo "--> go-runner image"
@echo "-------------------"
REPONAME="litmuschaos" IMGNAME="go-runner" IMGTAG="ci" ./build/push
REPONAME="$(DOCKER_REPO)" IMGNAME="$(DOCKER_IMAGE)" IMGTAG="$(DOCKER_TAG)" ./build/push

.PHONY: trivy-check
trivy-check:

@echo "------------------------"
@echo "---> Running Trivy Check"
@echo "------------------------"
@./trivy --exit-code 0 --severity HIGH --no-progress litmuschaos/go-runner:ci
@./trivy --exit-code 0 --severity CRITICAL --no-progress litmuschaos/go-runner:ci
@./trivy --exit-code 0 --severity HIGH --no-progress $(DOCKER_REPO)/$(DOCKER_IMAGE):$(DOCKER_TAG)
@./trivy --exit-code 0 --severity CRITICAL --no-progress $(DOCKER_REPO)/$(DOCKER_IMAGE):$(DOCKER_TAG)

4 changes: 2 additions & 2 deletions chaoslib/pumba/cpu-chaos/lib/cpu-chaos.go
Original file line number Diff line number Diff line change
Expand Up @@ -190,7 +190,7 @@ func CreateHelperPod(experimentsDetails *experimentTypes.ExperimentDetails, clie
Name: "dockersocket",
VolumeSource: apiv1.VolumeSource{
HostPath: &apiv1.HostPathVolumeSource{
Path: "/var/run/docker.sock",
Path: experimentsDetails.SocketPath,
},
},
},
Expand All @@ -204,7 +204,7 @@ func CreateHelperPod(experimentsDetails *experimentTypes.ExperimentDetails, clie
VolumeMounts: []apiv1.VolumeMount{
{
Name: "dockersocket",
MountPath: "/var/run/docker.sock",
MountPath: experimentsDetails.SocketPath,
},
},
ImagePullPolicy: apiv1.PullPolicy(experimentsDetails.LIBImagePullPolicy),
Expand Down
4 changes: 2 additions & 2 deletions chaoslib/pumba/memory-chaos/lib/memory-chaos.go
Original file line number Diff line number Diff line change
Expand Up @@ -190,7 +190,7 @@ func CreateHelperPod(experimentsDetails *experimentTypes.ExperimentDetails, clie
Name: "dockersocket",
VolumeSource: apiv1.VolumeSource{
HostPath: &apiv1.HostPathVolumeSource{
Path: "/var/run/docker.sock",
Path: experimentsDetails.SocketPath,
},
},
},
Expand All @@ -204,7 +204,7 @@ func CreateHelperPod(experimentsDetails *experimentTypes.ExperimentDetails, clie
VolumeMounts: []apiv1.VolumeMount{
{
Name: "dockersocket",
MountPath: "/var/run/docker.sock",
MountPath: experimentsDetails.SocketPath,
},
},
ImagePullPolicy: apiv1.PullPolicy(experimentsDetails.LIBImagePullPolicy),
Expand Down
4 changes: 2 additions & 2 deletions chaoslib/pumba/pod-io-stress/lib/pod-io-stress.go
Original file line number Diff line number Diff line change
Expand Up @@ -192,7 +192,7 @@ func CreateHelperPod(experimentsDetails *experimentTypes.ExperimentDetails, clie
Name: "dockersocket",
VolumeSource: apiv1.VolumeSource{
HostPath: &apiv1.HostPathVolumeSource{
Path: "/var/run/docker.sock",
Path: experimentsDetails.SocketPath,
},
},
},
Expand All @@ -206,7 +206,7 @@ func CreateHelperPod(experimentsDetails *experimentTypes.ExperimentDetails, clie
VolumeMounts: []apiv1.VolumeMount{
{
Name: "dockersocket",
MountPath: "/var/run/docker.sock",
MountPath: experimentsDetails.SocketPath,
},
},
ImagePullPolicy: apiv1.PullPolicy(experimentsDetails.LIBImagePullPolicy),
Expand Down
1 change: 1 addition & 0 deletions pkg/generic/pod-cpu-hog/environment/environment.go
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,7 @@ func GetENV(experimentDetails *experimentTypes.ExperimentDetails) {
experimentDetails.LIBImagePullPolicy = Getenv("LIB_IMAGE_PULL_POLICY", "Always")
experimentDetails.TargetContainer = Getenv("TARGET_CONTAINER", "")
experimentDetails.Sequence = Getenv("SEQUENCE", "parallel")
experimentDetails.SocketPath = Getenv("SOCKET_PATH", "/var/run/docker.sock")

}

Expand Down
1 change: 1 addition & 0 deletions pkg/generic/pod-cpu-hog/types/types.go
Original file line number Diff line number Diff line change
Expand Up @@ -32,5 +32,6 @@ type ExperimentDetails struct {
Annotations map[string]string
TargetContainer string
Sequence string
SocketPath string
Resources corev1.ResourceRequirements
}
1 change: 1 addition & 0 deletions pkg/generic/pod-io-stress/environment/environment.go
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,7 @@ func GetENV(experimentDetails *experimentTypes.ExperimentDetails) {
experimentDetails.PodsAffectedPerc, _ = strconv.Atoi(Getenv("PODS_AFFECTED_PERC", "0"))
experimentDetails.Sequence = Getenv("SEQUENCE", "parallel")
experimentDetails.VolumeMountPath = Getenv("VOLUME_MOUNT_PATH", "")
experimentDetails.SocketPath = Getenv("SOCKET_PATH", "/var/run/docker.sock")

}

Expand Down
1 change: 1 addition & 0 deletions pkg/generic/pod-io-stress/types/types.go
Original file line number Diff line number Diff line change
Expand Up @@ -31,5 +31,6 @@ type ExperimentDetails struct {
PodsAffectedPerc int
Sequence string
VolumeMountPath string
SocketPath string
Resources corev1.ResourceRequirements
}
1 change: 1 addition & 0 deletions pkg/generic/pod-memory-hog/environment/environment.go
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,7 @@ func GetENV(experimentDetails *experimentTypes.ExperimentDetails) {
experimentDetails.LIBImagePullPolicy = Getenv("LIB_IMAGE_PULL_POLICY", "Always")
experimentDetails.TargetContainer = Getenv("TARGET_CONTAINER", "")
experimentDetails.Sequence = Getenv("SEQUENCE", "parallel")
experimentDetails.SocketPath = Getenv("SOCKET_PATH", "/var/run/docker.sock")
}

// Getenv fetch the env and set the default value, if any
Expand Down
1 change: 1 addition & 0 deletions pkg/generic/pod-memory-hog/types/types.go
Original file line number Diff line number Diff line change
Expand Up @@ -31,5 +31,6 @@ type ExperimentDetails struct {
Annotations map[string]string
TargetContainer string
Sequence string
SocketPath string
Resources corev1.ResourceRequirements
}

0 comments on commit 42f9ccc

Please sign in to comment.