Skip to content

Commit

Permalink
[cherry-pick for 1.13.8] (#375)
Browse files Browse the repository at this point in the history
* feat(analytics): using same user-id for anaytics even if operator pod restarts (#372)

Signed-off-by: shubhamchaudhary <shubham@chaosnative.com>

* fix(target-details): overriding the target details, fix the github actions and bdd (#374)

* fix(target-details): overriding target details

Signed-off-by: shubhamchaudhary <shubham@chaosnative.com>

* fix(actions): fixing github actions

Signed-off-by: shubhamchaudhary <shubham@chaosnative.com>

* feat(crds): fixing chaosresult deletion and finalizer logging (#371)

* update(unit-test): updating unit test for operator

Signed-off-by: shubhamchaudhary <shubham@chaosnative.com>

* feat(crds): fixing chaosresult deletion and finalizer logging

Signed-off-by: shubhamchaudhary <shubham@chaosnative.com>

* resolving the conflicts

Signed-off-by: shubham chaudhary <shubham@chaosnative.com>
  • Loading branch information
Shubham Chaudhary committed Jul 15, 2021
1 parent 2f8c3c0 commit dc559cf
Show file tree
Hide file tree
Showing 15 changed files with 452 additions and 245 deletions.
45 changes: 29 additions & 16 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -36,23 +36,26 @@ jobs:
- name: Checkout
uses: actions/checkout@v2

- name: Set up Docker Buildx
id: buildx
uses: docker/setup-buildx-action@v1
with:
version: latest

- name: Build Docker Image
env:
DOCKER_REPO: litmuschaos
DOCKER_IMAGE: chaos-operator
DOCKER_TAG: ci
run: |
make build-chaos-operator
make build-amd64
docker save -o ${{ github.workspace }}/image.tar litmuschaos/chaos-operator:ci
chmod +x ${{ github.workspace }}/image.tar
- name: Upload artifact
uses: actions/upload-artifact@v2
with:
name: myimage
path: |
${{ github.workspace }}/image.tar
tests:
runs-on: ubuntu-latest
needs: pre-checks
needs: image-build
steps:
# Install golang
- uses: actions/setup-go@v2
Expand All @@ -65,21 +68,31 @@ jobs:
uses: actions/checkout@v2

#Install and configure a kind cluster
- name: Installing Prerequisites (KinD Cluster)
uses: engineerd/setup-kind@v0.5.0
with:
version: "v0.7.0"

- name: Configuring and testing the Installation
- name: Installing Prerequisites (K3S Cluster)
env:
KUBECONFIG: /etc/rancher/k3s/k3s.yaml
run: |
kubectl cluster-info --context kind-kind
kind get kubeconfig --internal >$HOME/.kube/config
curl -sfL https://get.k3s.io | sh -s - --docker --write-kubeconfig-mode 664
kubectl wait node --all --for condition=ready --timeout=90s
mkdir -p $HOME/.kube
cp /etc/rancher/k3s/k3s.yaml $HOME/.kube/config
kubectl get nodes
- name: Dependency checks
run: |
make deps
- name: Download artifact
uses: actions/download-artifact@v2
with:
name: myimage
path: ${{ github.workspace }}

- name: Load Docker image
run: |
docker load --input ${{ github.workspace }}/image.tar
shell: bash

- name: Running Go BDD Test
run: |
make test
25 changes: 16 additions & 9 deletions .github/workflows/push.yml
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ jobs:

image-build:
runs-on: ubuntu-latest
needs: pre-checks
needs: tests
steps:
# Checkout to the latest commit
# On specific directory/path
Expand Down Expand Up @@ -76,21 +76,28 @@ jobs:
go-version: 1.14

#Install and configure a kind cluster
- name: Installing Prerequisites (KinD Cluster)
uses: engineerd/setup-kind@v0.5.0
with:
version: "v0.7.0"

- name: Configuring and testing the Installation
- name: Installing Prerequisites (K3S Cluster)
env:
KUBECONFIG: /etc/rancher/k3s/k3s.yaml
run: |
kubectl cluster-info --context kind-kind
kind get kubeconfig --internal >$HOME/.kube/config
curl -sfL https://get.k3s.io | sh -s - --docker --write-kubeconfig-mode 664
kubectl wait node --all --for condition=ready --timeout=90s
mkdir -p $HOME/.kube
cp /etc/rancher/k3s/k3s.yaml $HOME/.kube/config
kubectl get nodes
- name: Dependency checks
run: |
make deps
- name: Build Docker Image
env:
DOCKER_REPO: litmuschaos
DOCKER_IMAGE: chaos-operator
DOCKER_TAG: ci
run: |
make build-amd64
- name: Running Go BDD Test
run: |
make test
25 changes: 16 additions & 9 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ jobs:

image-build:
runs-on: ubuntu-latest
needs: pre-checks
needs: tests
steps:
# Checkout to the latest commit
# On specific directory/path
Expand Down Expand Up @@ -89,21 +89,28 @@ jobs:
go-version: 1.14

#Install and configure a kind cluster
- name: Installing Prerequisites (KinD Cluster)
uses: engineerd/setup-kind@v0.5.0
with:
version: "v0.7.0"

- name: Configuring and testing the Installation
- name: Installing Prerequisites (K3S Cluster)
env:
KUBECONFIG: /etc/rancher/k3s/k3s.yaml
run: |
kubectl cluster-info --context kind-kind
kind get kubeconfig --internal >$HOME/.kube/config
curl -sfL https://get.k3s.io | sh -s - --docker --write-kubeconfig-mode 664
kubectl wait node --all --for condition=ready --timeout=90s
mkdir -p $HOME/.kube
cp /etc/rancher/k3s/k3s.yaml $HOME/.kube/config
kubectl get nodes
- name: Dependency checks
run: |
make deps
- name: Build Docker Image
env:
DOCKER_REPO: litmuschaos
DOCKER_IMAGE: chaos-operator
DOCKER_TAG: ci
run: |
make build-amd64
- name: Running Go BDD Test
run: |
make test
34 changes: 24 additions & 10 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -6,22 +6,24 @@ IS_DOCKER_INSTALLED = $(shell which docker >> /dev/null 2>&1; echo $$?)
# docker info
DOCKER_REPO ?= litmuschaos
DOCKER_IMAGE ?= chaos-operator
DOCKER_TAG ?= latest

.PHONY: all
all: deps unused-package-check build-chaos-operator test
DOCKER_TAG ?= ci

.PHONY: help
help:
@echo ""
@echo "Usage:-"
@echo "\tmake deps -- sets up dependencies for image build"
@echo "\tmake deps -- sets up dependencies for image build"
@echo "\tmake build-chaos-operator -- builds multi-arch image"
@echo "\tmake push-chaos-operator -- pushes the multi-arch image"
@echo "\tmake build-amd64 -- builds the amd64 image"
@echo ""

.PHONY: all
all: deps unused-package-check build-chaos-operator test

.PHONY: deps
deps: _build_check_docker godeps

.PHONY: _build_check_docker
_build_check_docker:
@if [ $(IS_DOCKER_INSTALLED) -eq 1 ]; \
then echo "" \
Expand All @@ -44,6 +46,7 @@ test:
@echo "------------------"
@go test ./... -coverprofile=coverage.txt -covermode=atomic -v

.PHONY: unused-package-check
unused-package-check:
@echo "------------------"
@echo "--> Check unused packages for the chaos-operator"
Expand All @@ -64,13 +67,24 @@ gofmt-check:
exit 1; \
fi

.PHONY: build-chaos-operator build-chaos-operator-amd64 push-chaos-operator

.PHONY: build-chaos-operator
build-chaos-operator:
@echo "-------------------------"
@echo "--> Build go-runner image"
@echo "-------------------------"
@docker buildx build --file build/Dockerfile --progress plane --no-cache --platform linux/arm64,linux/amd64 --tag $(DOCKER_REPO)/$(DOCKER_IMAGE):$(DOCKER_TAG) .

build-for-amd64:
@docker build -f build/Dockerfile --no-cache -t $(DOCKER_REPO)/$(DOCKER_IMAGE):$(DOCKER_TAG) . --build-arg TARGETPLATFORM="linux/amd64"

.PHONY: push-chaos-operator
push-chaos-operator:
@echo "------------------------------"
@echo "--> Pushing image"
@echo "------------------------------"
@docker buildx build --file build/Dockerfile --progress plane --no-cache --push --platform linux/arm64,linux/amd64 --tag $(DOCKER_REPO)/$(DOCKER_IMAGE):$(DOCKER_TAG) .

.PHONY: build-amd64
build-amd64:
@echo "-------------------------"
@echo "--> Build go-runner image"
@echo "-------------------------"
@docker build -f build/Dockerfile --no-cache -t $(DOCKER_REPO)/$(DOCKER_IMAGE):$(DOCKER_TAG) . --build-arg TARGETPLATFORM="linux/amd64"
3 changes: 3 additions & 0 deletions deploy/rbac.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,9 @@ rules:
- apiGroups: ["","litmuschaos.io"]
resources: ["pods","configmaps","events","services","chaosengines","chaosexperiments","chaosresults"]
verbs: ["get","create","update","patch","delete","list","watch","deletecollection"]
- apiGroups: ["apiextensions.k8s.io"]
resources: ["customresourcedefinitions"]
verbs: ["list","get"]
---
apiVersion: rbac.authorization.k8s.io/v1beta1
kind: ClusterRoleBinding
Expand Down
9 changes: 5 additions & 4 deletions go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -4,22 +4,23 @@ go 1.13

require (
github.com/go-logr/logr v0.1.0
github.com/go-openapi/spec v0.19.4
github.com/go-openapi/spec v0.19.7
github.com/google/martian v2.1.0+incompatible
github.com/jpillora/go-ogle-analytics v0.0.0-20161213085824-14b04e0594ef
github.com/litmuschaos/elves v0.0.0-20201107015738-552d74669e3c
github.com/litmuschaos/litmus-go v0.0.0-20210705063441-babf0c4aa57d
github.com/onsi/ginkgo v1.12.0
github.com/onsi/gomega v1.9.0
github.com/openebs/maya v1.12.1
github.com/operator-framework/operator-sdk v0.15.2
github.com/pkg/errors v0.9.1
github.com/spf13/pflag v1.0.5
golang.org/x/net v0.0.0-20201021035429-f5854403a974 // indirect
golang.org/x/xerrors v0.0.0-20200804184101-5ec99f83aff1 // indirect
golang.org/x/tools v0.1.0 // indirect
k8s.io/api v0.17.3
k8s.io/apimachinery v0.17.3
k8s.io/client-go v12.0.0+incompatible
k8s.io/klog v1.0.0
k8s.io/kube-openapi v0.0.0-20191107075043-30be4d16710a
k8s.io/kube-openapi v0.0.0-20200121204235-bf4fb3bd569c
sigs.k8s.io/controller-runtime v0.4.0
)

Expand Down
Loading

0 comments on commit dc559cf

Please sign in to comment.