Skip to content

Commit

Permalink
(enhancement)experiment: add experiment imagePullPolicy attribute (#67)
Browse files Browse the repository at this point in the history
* (enhancement)experiment: add imagepullpolicy attribute

Signed-off-by: ksatchit <[email protected]>

* (chore)dependencies: update the go mod to work with latest operator changes

Signed-off-by: ksatchit <[email protected]>

* (fix)runner: add default value for pull policy

Signed-off-by: ksatchit <[email protected]>
  • Loading branch information
Karthik Satchitanand authored Jun 11, 2020
1 parent 6c5632d commit 7c5ff86
Show file tree
Hide file tree
Showing 588 changed files with 147,981 additions and 46,484 deletions.
8 changes: 4 additions & 4 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -16,16 +16,16 @@ all: godeps format lint build dockerops test
help:
@echo ""
@echo "Usage:-"
@echo "\tmake all -- [default] builds the chaos exporter container"
@echo "\tmake all -- [default] builds the chaos runner container"
@echo ""

.PHONY: godeps
godeps:
@echo ""
@echo "INFO:\tverifying dependencies for chaos exporter build ..."
@echo "INFO:\tverifying dependencies for chaos runner build ..."
@go get -u -v golang.org/x/lint/golint
@go get -u -v golang.org/x/tools/cmd/goimports
@go get -u -v github.com/golang/dep/cmd/dep
#@go get -u -v github.com/golang/dep/cmd/dep

_build_check_docker:
@if [ $(IS_DOCKER_INSTALLED) -eq 1 ]; \
Expand Down Expand Up @@ -86,4 +86,4 @@ dockerops:

.PHONY: push
push:
sudo docker push $(REGISTRY)/$(IMG_NAME):$(PACKAGE_VERSION)
sudo docker push $(REGISTRY)/$(IMG_NAME):$(PACKAGE_VERSION)
39 changes: 32 additions & 7 deletions go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -5,19 +5,44 @@ go 1.13
require (
github.com/imdario/mergo v0.3.9 // indirect
github.com/jpillora/go-ogle-analytics v0.0.0-20161213085824-14b04e0594ef
github.com/litmuschaos/chaos-operator v0.0.0-20200502085045-ae0a262d3baa
//github.com/litmuschaos/chaos-operator v0.0.0-20200610171242-8c0c626224c4
github.com/litmuschaos/chaos-operator v0.0.0-20200610171242-8c0c626224c4
github.com/litmuschaos/elves v0.0.0-20200502084504-13be0e6937ee
github.com/onsi/ginkgo v1.11.0
github.com/onsi/gomega v1.8.1
github.com/pkg/errors v0.9.1
golang.org/x/oauth2 v0.0.0-20200107190931-bf48bf16ab8d // indirect
golang.org/x/time v0.0.0-20200416051211-89c76fbcd5d1 // indirect
// k8s component set to kubernetes-1.15.4
k8s.io/api v0.0.0-20190918195907-bd6ac527cfd2
k8s.io/apimachinery v0.0.0-20190817020851-f2f3a405f61d
k8s.io/client-go v0.0.0-20190918200256-06eb1244587a

k8s.io/api v0.0.0
k8s.io/apimachinery v0.0.0
k8s.io/client-go v12.0.0+incompatible
k8s.io/klog v1.0.0
k8s.io/utils v0.0.0-20200414100711-2df71ebbae66 // indirect
sigs.k8s.io/controller-runtime v0.3.0 // indirect
)

// Pinned to kubernetes-1.16.2
replace (
k8s.io/api => k8s.io/api v0.0.0-20191016110408-35e52d86657a
k8s.io/apiextensions-apiserver => k8s.io/apiextensions-apiserver v0.0.0-20191016113550-5357c4baaf65
k8s.io/apimachinery => k8s.io/apimachinery v0.0.0-20191004115801-a2eda9f80ab8
k8s.io/apiserver => k8s.io/apiserver v0.0.0-20191016112112-5190913f932d
k8s.io/cli-runtime => k8s.io/cli-runtime v0.0.0-20191016114015-74ad18325ed5
k8s.io/client-go => k8s.io/client-go v0.0.0-20191016111102-bec269661e48
k8s.io/cloud-provider => k8s.io/cloud-provider v0.0.0-20191016115326-20453efc2458
k8s.io/cluster-bootstrap => k8s.io/cluster-bootstrap v0.0.0-20191016115129-c07a134afb42
k8s.io/code-generator => k8s.io/code-generator v0.0.0-20191004115455-8e001e5d1894
k8s.io/component-base => k8s.io/component-base v0.0.0-20191016111319-039242c015a9
k8s.io/cri-api => k8s.io/cri-api v0.0.0-20190828162817-608eb1dad4ac
k8s.io/csi-translation-lib => k8s.io/csi-translation-lib v0.0.0-20191016115521-756ffa5af0bd
k8s.io/kube-aggregator => k8s.io/kube-aggregator v0.0.0-20191016112429-9587704a8ad4
k8s.io/kube-controller-manager => k8s.io/kube-controller-manager v0.0.0-20191016114939-2b2b218dc1df
k8s.io/kube-proxy => k8s.io/kube-proxy v0.0.0-20191016114407-2e83b6f20229
k8s.io/kube-scheduler => k8s.io/kube-scheduler v0.0.0-20191016114748-65049c67a58b
k8s.io/kubectl => k8s.io/kubectl v0.0.0-20191016120415-2ed914427d51
k8s.io/kubelet => k8s.io/kubelet v0.0.0-20191016114556-7841ed97f1b2
k8s.io/legacy-cloud-providers => k8s.io/legacy-cloud-providers v0.0.0-20191016115753-cf0698c3a16b
k8s.io/metrics => k8s.io/metrics v0.0.0-20191016113814-3b1a734dba6e
k8s.io/sample-apiserver => k8s.io/sample-apiserver v0.0.0-20191016112829-06bb3c9d77c9
)

replace github.com/docker/docker => github.com/moby/moby v0.7.3-0.20190826074503-38ab9da00309 // Required by Helm
715 changes: 715 additions & 0 deletions go.sum

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion pkg/utils/builders.go
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ func buildContainerSpec(experiment *ExperimentDetails, envVar []corev1.EnvVar) (
WithImage(experiment.ExpImage).
WithCommandNew([]string{"/bin/bash"}).
WithArgumentsNew(experiment.ExpArgs).
WithImagePullPolicy("Always").
WithImagePullPolicy(experiment.ExpImagePullPolicy).
WithEnvsNew(envVar)

if experiment.VolumeOpts.VolumeMounts != nil {
Expand Down
20 changes: 19 additions & 1 deletion pkg/utils/experimentHelpers.go
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,9 @@ func (expDetails *ExperimentDetails) SetValueFromChaosExperiment(clients ClientS
if err := expDetails.SetImage(clients); err != nil {
return err
}
if err := expDetails.SetImagePullPolicy(clients); err != nil {
return err
}
if err := expDetails.SetArgs(clients); err != nil {
return err
}
Expand Down Expand Up @@ -140,6 +143,21 @@ func (expDetails *ExperimentDetails) SetImage(clients ClientSets) error {
return nil
}

// SetImagePullPolicy sets the Experiment ImagePullPolicy, in Experiment Structure
func (expDetails *ExperimentDetails) SetImagePullPolicy(clients ClientSets) error {
expirementSpec, err := clients.LitmusClient.LitmuschaosV1alpha1().ChaosExperiments(expDetails.Namespace).Get(expDetails.Name, metav1.GetOptions{})
if err != nil {
return errors.Wrapf(err, "Unable to get ChaosExperiment instance in namespace: %v", expDetails.Namespace)
}
//TODO: additional checks
if expirementSpec.Spec.Definition.ImagePullPolicy == "" {
expDetails.ExpImagePullPolicy = DefaultExpImagePullPolicy
} else {
expDetails.ExpImagePullPolicy = expirementSpec.Spec.Definition.ImagePullPolicy
}
return nil
}

// SetArgs sets the Experiment Image, in Experiment Structure
func (expDetails *ExperimentDetails) SetArgs(clients ClientSets) error {
expirementSpec, err := clients.LitmusClient.LitmuschaosV1alpha1().ChaosExperiments(expDetails.Namespace).Get(expDetails.Name, metav1.GetOptions{})
Expand All @@ -150,7 +168,7 @@ func (expDetails *ExperimentDetails) SetArgs(clients ClientSets) error {
return nil
}

// SetValueFromChaosResources fetchs required values from various Chaos Resources
// SetValueFromChaosResources fetches required values from various Chaos Resources
func (expDetails *ExperimentDetails) SetValueFromChaosResources(engineDetails *EngineDetails, clients ClientSets) error {
if err := expDetails.SetValueFromChaosEngine(engineDetails, clients); err != nil {
return errors.Wrapf(err, "Unable to set value from Chaos Engine due to error: %v", err)
Expand Down
30 changes: 18 additions & 12 deletions pkg/utils/types.go
Original file line number Diff line number Diff line change
Expand Up @@ -32,18 +32,19 @@ type EngineDetails struct {

// ExperimentDetails is for collecting all the experiment-related details
type ExperimentDetails struct {
Name string
Env map[string]string
ExpLabels map[string]string
ExpImage string
ExpArgs []string
JobName string
Namespace string
ConfigMaps []v1alpha1.ConfigMap
Secrets []v1alpha1.Secret
VolumeOpts VolumeOpts
SvcAccount string
Annotations map[string]string
Name string
Env map[string]string
ExpLabels map[string]string
ExpImage string
ExpImagePullPolicy corev1.PullPolicy
ExpArgs []string
JobName string
Namespace string
ConfigMaps []v1alpha1.ConfigMap
Secrets []v1alpha1.Secret
VolumeOpts VolumeOpts
SvcAccount string
Annotations map[string]string
}

//VolumeOpts is a strcuture for all volume related operations
Expand All @@ -64,6 +65,11 @@ type Recorder struct {
EventResource runtime.Object
}

var (
// DefaultExpImagePullPolicy contains the defaults value (Always) of imagePullPolicy for exp container
DefaultExpImagePullPolicy corev1.PullPolicy = "Always"
)

const (
ExperimentDependencyCheckReason string = "ExperimentDependencyCheck"
ExperimentJobCreateReason string = "ExperimentJobCreate"
Expand Down
15 changes: 0 additions & 15 deletions vendor/cloud.google.com/go/AUTHORS

This file was deleted.

40 changes: 0 additions & 40 deletions vendor/cloud.google.com/go/CONTRIBUTORS

This file was deleted.

24 changes: 18 additions & 6 deletions vendor/cloud.google.com/go/compute/metadata/metadata.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

11 changes: 8 additions & 3 deletions vendor/github.com/PuerkitoBio/purell/.travis.yml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

3 changes: 2 additions & 1 deletion vendor/github.com/PuerkitoBio/purell/README.md

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion vendor/github.com/PuerkitoBio/purell/purell.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions vendor/github.com/emicklei/go-restful/.gitignore

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Loading

0 comments on commit 7c5ff86

Please sign in to comment.