Skip to content

Commit

Permalink
Merge branch 'master' into readme-fix
Browse files Browse the repository at this point in the history
  • Loading branch information
gdsoumya authored Oct 12, 2023
2 parents 8a86169 + d1b19a3 commit 93c4aa5
Show file tree
Hide file tree
Showing 18 changed files with 5,745 additions and 2,045 deletions.
3,970 changes: 2,046 additions & 1,924 deletions chaoscenter/graphql/server/manifests/cluster/2a_litmus_crds.yaml

Large diffs are not rendered by default.

55 changes: 27 additions & 28 deletions chaoscenter/graphql/server/pkg/chaos_experiment/handler/handler.go
Original file line number Diff line number Diff line change
Expand Up @@ -106,18 +106,10 @@ func (c *ChaosExperimentHandler) SaveChaosExperiment(ctx context.Context, reques
if wfDetails.ExperimentID == request.ID {
logrus.WithFields(logFields).Info("request received to update k8s chaos experiment")
if wfDetails.Name != request.Name {
filterQuery := bson.D{
{"project_id", request.ID},
{"name", request.Name},
{"is_removed", false},
}
experimentCount, err := c.chaosExperimentOperator.CountChaosExperiments(ctx, filterQuery)
err = c.validateDuplicateExperimentName(ctx, projectID, request.Name)
if err != nil {
return "", err
}
if experimentCount > 0 {
return "", errors.New("experiment name should be unique, duplicate experiment found with name: " + request.Name)
}
}

err = c.chaosExperimentService.ProcessExperimentUpdate(newRequest, username, wfType, revID, false, projectID, nil)
Expand All @@ -128,10 +120,15 @@ func (c *ChaosExperimentHandler) SaveChaosExperiment(ctx context.Context, reques
return "experiment updated successfully", nil
}

err = c.validateDuplicateExperimentName(ctx, projectID, request.Name)
if err != nil {
return "", err
}

// Saving chaos experiment in the DB
logrus.WithFields(logFields).Info("request received to save k8s chaos experiment")

err = c.chaosExperimentService.ProcessExperimentCreation(context.TODO(), newRequest, username, projectID, wfType, revID, nil)
err = c.chaosExperimentService.ProcessExperimentCreation(ctx, newRequest, username, projectID, wfType, revID, nil)
if err != nil {
return "", err
}
Expand All @@ -144,18 +141,10 @@ func (c *ChaosExperimentHandler) CreateChaosExperiment(ctx context.Context, requ
var revID = uuid.New().String()

// Check if the experiment_name exists under same project
filterQuery := bson.D{
{"project_id", projectID},
{"name", request.ExperimentName},
{"is_removed", false},
}
experimentCount, err := c.chaosExperimentOperator.CountChaosExperiments(ctx, filterQuery)
err := c.validateDuplicateExperimentName(ctx, projectID, request.ExperimentName)
if err != nil {
return nil, err
}
if experimentCount > 0 {
return nil, errors.New("experiment name should be unique, duplicate experiment found with name: " + request.ExperimentName)
}

newRequest, wfType, err := c.chaosExperimentService.ProcessExperiment(request, projectID, revID)
if err != nil {
Expand Down Expand Up @@ -240,18 +229,10 @@ func (c *ChaosExperimentHandler) UpdateChaosExperiment(ctx context.Context, requ
)

// Check if the experiment_name exists under same project
filterQuery := bson.D{
{"project_id", projectID},
{"name", request.ExperimentName},
{"is_removed", false},
}
experimentCount, err := c.chaosExperimentOperator.CountChaosExperiments(ctx, filterQuery)
err := c.validateDuplicateExperimentName(ctx, projectID, request.ExperimentName)
if err != nil {
return nil, err
}
if experimentCount > 0 {
return nil, errors.New("experiment name should be unique, duplicate experiment found with name: " + request.ExperimentName)
}

newRequest, wfType, err := c.chaosExperimentService.ProcessExperiment(request, projectID, revID)
if err != nil {
Expand Down Expand Up @@ -1317,3 +1298,21 @@ func (c *ChaosExperimentHandler) GetProbesInExperimentRun(ctx context.Context, p

return probeDetails, nil
}

// validateDuplicateExperimentName validates if the name of experiment is duplicate
func (c *ChaosExperimentHandler) validateDuplicateExperimentName(ctx context.Context, projectID, name string) error {
filterQuery := bson.D{
{"project_id", projectID},
{"name", name},
{"is_removed", false},
}
experimentCount, err := c.chaosExperimentOperator.CountChaosExperiments(ctx, filterQuery)
if err != nil {
return err
}
if experimentCount > 0 {
return errors.New("experiment name should be unique, duplicate experiment found with name: " + name)
}

return nil
}
26 changes: 11 additions & 15 deletions chaoscenter/graphql/server/pkg/chaos_infrastructure/infra_utils.go
Original file line number Diff line number Diff line change
Expand Up @@ -59,23 +59,19 @@ func GetK8sInfraYaml(infra dbChaosInfra.ChaosInfra) ([]byte, error) {
config.TLSCert = utils.Config.TlsCertB64
}

if !infra.IsRegistered {
var respData []byte
if infra.InfraScope == ClusterScope {
respData, err = ManifestParser(infra, "manifests/cluster", &config)
} else if infra.InfraScope == NamespaceScope {
respData, err = ManifestParser(infra, "manifests/namespace", &config)
} else {
logrus.Error("INFRA_SCOPE env is empty!")
}
if err != nil {
return nil, err
}

return respData, nil
var respData []byte
if infra.InfraScope == ClusterScope {
respData, err = ManifestParser(infra, "manifests/cluster", &config)
} else if infra.InfraScope == NamespaceScope {
respData, err = ManifestParser(infra, "manifests/namespace", &config)
} else {
return []byte("Infra is already registered"), nil
logrus.Error("INFRA_SCOPE env is empty!")
}
if err != nil {
return nil, err
}

return respData, nil
}

// ManifestParser parses manifests yaml and generates dynamic manifest with specified keys
Expand Down
16 changes: 7 additions & 9 deletions chaoscenter/manifests/litmus-cluster-scope.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -440,9 +440,7 @@ metadata:
name: litmus-portal-admin-config
namespace: litmus
data:
DB_SERVER: mongodb://my-release-mongodb-0.my-release-mongodb-headless.litmus.svc.cluster.local:27017,my-release-mongodb-1.my-release-mongodb-headless.litmus.svc.cluster.local:27017,my-release-mongodb-2.my-release-mongodb-headless.litmus.svc.cluster.local:27017/admin
INFRA_SCOPE: cluster
INFRA_NAMESPACE: litmus
DB_SERVER: mongodb://my-release-mongodb-0.my-release-mongodb-headless:27017,my-release-mongodb-1.my-release-mongodb-headless:27017,my-release-mongodb-2.my-release-mongodb-headless:27017/admin
VERSION: "ci"
SKIP_SSL_VERIFY: "false"
# Configurations if you are using dex for OAuth
Expand Down Expand Up @@ -665,11 +663,11 @@ spec:
- name: ARGO_WORKFLOW_EXECUTOR_IMAGE
value: "litmuschaos/argoexec:v3.3.1"
- name: LITMUS_CHAOS_OPERATOR_IMAGE
value: "litmuschaos/chaos-operator:3.0.0-beta11"
value: "litmuschaos/chaos-operator:3.0.0"
- name: LITMUS_CHAOS_RUNNER_IMAGE
value: "litmuschaos/chaos-runner:3.0.0-beta11"
value: "litmuschaos/chaos-runner:3.0.0"
- name: LITMUS_CHAOS_EXPORTER_IMAGE
value: "litmuschaos/chaos-exporter:3.0.0-beta11"
value: "litmuschaos/chaos-exporter:3.0.0"
- name: SERVER_SERVICE_NAME
value: "litmusportal-server-service"
- name: INFRA_DEPLOYMENTS
Expand All @@ -689,11 +687,11 @@ spec:
- name: DEFAULT_HUB_BRANCH_NAME
value: "master"
- name: LITMUS_AUTH_GRPC_ENDPOINT
value: "litmusportal-auth-server-service.litmus.svc.cluster.local"
value: "litmusportal-auth-server-service"
- name: LITMUS_AUTH_GRPC_PORT
value: ":3030"
- name: WORKFLOW_HELPER_IMAGE_VERSION
value: "3.0.0-beta9"
value: "3.0.0"
- name: REMOTE_HUB_MAX_SIZE
value: "5000000"
- name: INFRA_COMPATIBLE_VERSIONS
Expand Down Expand Up @@ -769,7 +767,7 @@ spec:
- name: ADMIN_PASSWORD
value: "litmus"
- name: LITMUS_GQL_GRPC_ENDPOINT
value: "litmusportal-server-service.litmus.svc.cluster.local"
value: "litmusportal-server-service"
- name: LITMUS_GQL_GRPC_PORT
value: ":8000"
resources:
Expand Down
9 changes: 4 additions & 5 deletions chaoscenter/manifests/litmus-namespaced-scope.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -415,7 +415,6 @@ kind: ConfigMap
metadata:
name: litmus-portal-admin-config
data:
INFRA_SCOPE: namespace
DB_SERVER: mongodb://my-release-mongodb-0.my-release-mongodb-headless:27017,my-release-mongodb-1.my-release-mongodb-headless:27017,my-release-mongodb-2.my-release-mongodb-headless:27017/admin
VERSION: "ci"
SKIP_SSL_VERIFY: "false"
Expand Down Expand Up @@ -638,11 +637,11 @@ spec:
- name: ARGO_WORKFLOW_EXECUTOR_IMAGE
value: "litmuschaos/argoexec:v3.3.1"
- name: LITMUS_CHAOS_OPERATOR_IMAGE
value: "litmuschaos/chaos-operator:3.0.0-beta11"
value: "litmuschaos/chaos-operator:3.0.0"
- name: LITMUS_CHAOS_RUNNER_IMAGE
value: "litmuschaos/chaos-runner:3.0.0-beta11"
value: "litmuschaos/chaos-runner:3.0.0"
- name: LITMUS_CHAOS_EXPORTER_IMAGE
value: "litmuschaos/chaos-exporter:3.0.0-beta11"
value: "litmuschaos/chaos-exporter:3.0.0"
- name: CONTAINER_RUNTIME_EXECUTOR
value: "k8sapi"
- name: DEFAULT_HUB_BRANCH_NAME
Expand All @@ -652,7 +651,7 @@ spec:
- name: LITMUS_AUTH_GRPC_PORT
value: ":3030"
- name: WORKFLOW_HELPER_IMAGE_VERSION
value: "3.0.0-beta9"
value: "3.0.0"
- name: REMOTE_HUB_MAX_SIZE
value: "5000000"
- name: INGRESS
Expand Down
34 changes: 14 additions & 20 deletions chaoscenter/manifests/litmus-without-resources.yaml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
### RBAC Manifests
## If SELF_AGENT="true" then these permissions are required to apply
## https://github.com/litmuschaos/litmus/blob/master/litmus-portal/graphql-server/manifests/cluster/1b_argo_rbac.yaml
## https://github.com/litmuschaos/litmus/blob/master/chaoscenter/graphql/server/manifests/cluster/1b_argo_rbac.yaml
---
apiVersion: rbac.authorization.k8s.io/v1
kind: ClusterRole
Expand Down Expand Up @@ -440,9 +440,7 @@ metadata:
name: litmus-portal-admin-config
namespace: litmus
data:
DB_SERVER: mongodb://my-release-mongodb-0.my-release-mongodb-headless.litmus.svc.cluster.local:27017,my-release-mongodb-1.my-release-mongodb-headless.litmus.svc.cluster.local:27017,my-release-mongodb-2.my-release-mongodb-headless.litmus.svc.cluster.local:27017/admin
AGENT_SCOPE: cluster
AGENT_NAMESPACE: litmus
DB_SERVER: mongodb://my-release-mongodb-0.my-release-mongodb-headless:27017,my-release-mongodb-1.my-release-mongodb-headless:27017,my-release-mongodb-2.my-release-mongodb-headless:27017/admin
VERSION: "ci"
SKIP_SSL_VERIFY: "false"
# Configurations if you are using dex for OAuth
Expand All @@ -459,7 +457,7 @@ metadata:
name: litmusportal-frontend-nginx-configuration
namespace: litmus
data:
default.conf: |
nginx.conf: |
pid /tmp/nginx.pid;
events {
Expand Down Expand Up @@ -638,8 +636,6 @@ spec:
- secretRef:
name: litmus-portal-admin-secret
env:
- name: SELF_AGENT
value: "true"
# if self-signed certificate are used pass the k8s tls secret name created in portal ns, to allow agents to use tls for communication
- name: TLS_SECRET_NAME
value: ""
Expand All @@ -658,23 +654,19 @@ spec:
- name: ARGO_WORKFLOW_EXECUTOR_IMAGE
value: "litmuschaos/argoexec:v3.3.1"
- name: LITMUS_CHAOS_OPERATOR_IMAGE
value: "litmuschaos/chaos-operator:3.0.0-beta3"
value: "litmuschaos/chaos-operator:3.0.0"
- name: LITMUS_CHAOS_RUNNER_IMAGE
value: "litmuschaos/chaos-runner:3.0.0-beta3"
value: "litmuschaos/chaos-runner:3.0.0"
- name: LITMUS_CHAOS_EXPORTER_IMAGE
value: "litmuschaos/chaos-exporter:3.0.0-beta3"
value: "litmuschaos/chaos-exporter:3.0.0"
- name: SERVER_SERVICE_NAME
value: "litmusportal-server-service"
- name: INFRA_DEPLOYMENTS
value: '["app=chaos-exporter", "name=chaos-operator", "app=workflow-controller"]'
value: '["app=chaos-exporter", "name=chaos-operator", "app=workflow-controller", "app=event-tracker"]'
- name: NODE_NAME
valueFrom:
fieldRef:
fieldPath: spec.nodeName
- name: SELF_AGENT_NODE_SELECTOR
value: ""
- name: SELF_AGENT_TOLERATIONS
value: ""
- name: CHAOS_CENTER_UI_ENDPOINT
value: ""
- name: INGRESS
Expand All @@ -683,16 +675,18 @@ spec:
value: "litmus-ingress"
- name: CONTAINER_RUNTIME_EXECUTOR
value: "k8sapi"
- name: HUB_BRANCH_NAME
value: "refactor-hub-3.0.0"
- name: DEFAULT_HUB_BRANCH_NAME
value: "master"
- name: LITMUS_AUTH_GRPC_ENDPOINT
value: "litmusportal-auth-server-service.litmus.svc.cluster.local"
value: "litmusportal-auth-server-service"
- name: LITMUS_AUTH_GRPC_PORT
value: ":3030"
- name: WORKFLOW_HELPER_IMAGE_VERSION
value: "3.0.0-beta9"
value: "3.0.0"
- name: REMOTE_HUB_MAX_SIZE
value: "5000000"
- name: INFRA_COMPATIBLE_VERSIONS
value: '["ci"]'
ports:
- containerPort: 8080
- containerPort: 8000
Expand Down Expand Up @@ -755,7 +749,7 @@ spec:
- name: ADMIN_PASSWORD
value: "litmus"
- name: LITMUS_GQL_GRPC_ENDPOINT
value: "litmusportal-server-service.litmus.svc.cluster.local"
value: "litmusportal-server-service"
- name: LITMUS_GQL_GRPC_PORT
value: ":8000"
ports:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -132,7 +132,7 @@ function ChaosExecutionNode(props: ChaosExecutionNodeProps): JSX.Element {
{
nodeName: props.name ?? props.data.name,
stepStatus: props.status as ExperimentRunFaultStatus,
chaosResult: props.data.chaosData?.chaosResult
chaosResult: props.data.chaosResult
},
{
useArrows: true,
Expand Down
5 changes: 1 addition & 4 deletions chaoscenter/web/src/strings/strings.en.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -653,10 +653,7 @@ noKubernetesChaosInfrastructureFound: >-
noLogs: Sorry, Logs are currently not available
noMonitoredService: No monitoring services found for
noProbeDescription: >-
Probes are pluggable checks that can be defined within the ChaosEngine for any
Chaos Fault. The experiment pods execute these checks based on the mode they
are defined in & factor their success as necessary conditions in
determining the verdict of the experiment
Probes are lightweight, self-contained scripts that can be run against Kubernetes applications to gather information about their behavior under stress and failure conditions.
noProbeExecution: No Probe executions found
noProbeExecutionDetails:
subtitle: >-
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -156,7 +156,11 @@ export default function CreateEnvironment({
variation={ButtonVariation.SECONDARY}
text={getString('cancel')}
/>
<Button type="submit" variation={ButtonVariation.PRIMARY} text={getString('save')} />
<Button
onClick={() => formikProps.handleSubmit()}
variation={ButtonVariation.PRIMARY}
text={getString('save')}
/>
</Layout.Horizontal>
</Layout.Vertical>
</Form>
Expand Down
Loading

0 comments on commit 93c4aa5

Please sign in to comment.