Code Monkey home page Code Monkey logo

litmusctl's Introduction

Litmusctl

BCH compliance GitHub Workflow GitHub stars GitHub Release

The Litmuschaos command-line tool, litmusctl, allows you to manage litmuschaos's agent plane. You can use litmusctl to connect Chaos Delegates, create project, schedule Chaos Scenarios, disconnect Chaos Delegates and manage multiple litmuschaos accounts.

Usage

For more information including a complete list of litmusctl operations, see the litmusctl reference documentation.

  • For 0.23.0 or latest: Click here
  • For v0.12.0 to v0.22.0: Click here
  • For v0.2.0 or earlier && compatible with Litmus-2.0.0-Beta8 or earlier: Click here

Requirements

The litmusctl CLI requires the following things:

  • kubeconfig - litmusctl needs the kubeconfig of the k8s cluster where we need to connect litmus Chaos Delegates. The CLI currently uses the default path of kubeconfig i.e. ~/.kube/config.
  • kubectl- litmusctl is using kubectl under the hood to apply the manifest. To install kubectl, follow: kubectl

Compatibility matrix

To check compatibility of litmusctl with Chaos Center

litmusctl version Lowest Chaos Center supported version Highest Chaos Center supported version
1.6.0 3.0.0 3.7.0
1.5.0 3.0.0 3.6.0
1.4.0 3.0.0 3.5.0
1.3.0 3.0.0 3.4.0
1.2.0 3.0.0 3.3.0
1.1.0 3.0.0 3.2.0
1.0.0 3.0.0 3.1.0
0.24.0 3.0.0-beta9 3.0.0-beta12
0.23.0 3.0.0-beta9 3.0.0-beta12
0.22.0 2.9.0 3.0.0-beta8

Installation

To install the latest version of litmusctl follow the below steps:

Platforms 1.6.0 1.5.0 1.4.0 1.3.0 1.2.0 1.1.0 1.0.0 0.24.0 master(Unreleased)
litmusctl-darwin-amd64 (MacOS) Click here Click here Click here Click here Click here Click here Click here Click here Click here
litmusctl-linux-386 Click here Click here Click here Click here Click here Click here Click here Click here Click here
litmusctl-linux-amd64 Click here Click here Click here Click here Click here Click here Click here Click here Click here
litmusctl-linux-arm Click here Click here Click here Click here Click here Click here Click here Click here Click here
litmusctl-linux-arm64 Click here Click here Click here Click here Click here Click here Click here Click here Click here
litmusctl-windows-386 Click here Click here Click here Click here Click here Click here Click here Click here Click here
litmusctl-windows-amd64 Click here Click here Click here Click here Click here Click here Click here Click here Click here
litmusctl-windows-arm Click here Click here Click here Click here Click here Click here Click here Click here Click here

Linux/MacOS

  • Extract the binary
tar -zxvf litmusctl-<OS>-<ARCH>-<VERSION>.tar.gz
  • Provide necessary permissions
chmod +x litmusctl
  • Move the litmusctl binary to /usr/local/bin/litmusctl. Note: Make sure to use root user or use sudo as a prefix
mv litmusctl /usr/local/bin/litmusctl
  • You can run the litmusctl command in Linux/macOS:
litmusctl <command> <subcommand> <subcommand> [options and parameters]

Windows

  • Extract the binary from the zip using WinZip or any other extraction tool.

  • You can run the litmusctl command in windows:

litmusctl.exe <command> <subcommand> <subcommand> [options and parameters]
  • To check the version of the litmusctl:
litmusctl version

Development Guide

You can find the local setup guide for litmusctl here.


litmusctl's People

Contributors

adarshkumar14 avatar alebcay avatar arkajyotimukherjee avatar aryan-bhokare avatar deep-poharkar avatar dependabot[bot] avatar fernandoalex avatar gdsoumya avatar harshshekhar15 avatar iamnicoj avatar imrajdas avatar jongwooo avatar jonsy13 avatar kartikaysaxena avatar litmuschaos-bot avatar nageshbansal avatar prayags avatar rohan2794 avatar saranya-jena avatar sarthakjain26 avatar shivam-purohit avatar vishnuitta avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

litmusctl's Issues

litmusctl upgrade chaos-delegate fails with configmaps "agent-config" not found

Hello,
We encouter issues with the litmusctl upgrade CLI v0.14.0.

$ litmusctl upgrade chaos-delegate --chaos-delegate-id="5aac7d8a-a0da-4807-9cbf-9b98a7192507" --project-id="802932df-a056-40a1-ad97-cdb03abc4498"
❌ Failed upgrading Chaos Delegate: 
configmaps "agent-config" not found

I guess the issue is triggered by this failure looking up the said configmap: https://github.com/litmuschaos/litmusctl/blob/master/pkg/apis/upgrade.go#L111
While looking at the API results (in the browser console), I see the agent namespace is well configured.
I tried setting the --kubeconfig field to a single context kubeconfig file with the current namespace set to the agent namespace, nothing works.

If you have any clue, feel free to share. I can gather additional data if you need so.

Display the reason for litmus create agent failure

Background:

Litmusctl create agent uses kuberentes client internally to apply the generated manifest on the agent. But for some reason(mostly due to mismatch of the kubectl client version being used in litmusctl with the kubernetes verison I have in my cluster) litmuctl fail to apply the manifest on the cluster. But I could not see any reason for the failure in the resulting printout.

Installation Mode: cluster
Applying YAML:
http://litmus-chaos-center.xxxx.xxx.xxxxxx.se/api/file/eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJjbHVzdGVyX2lkIjoiOGM2NDA3M2MtMDhlZi00OTU5LWExMzAtYzk5MGJhYmRiNWEwIn0.Md8F6sDb3reODR-iOYVB5_z9tEOfTOf9FDbRXz5aawlk.yaml
� Failed in applying connection yaml:

Solution:

I noticed in the code that the failure is due to kubectl apply -f failed to apply the patch. Here is where the code calls k8s.ApplyYaml method to apply the manifest. and the ApplyManifest method returns the yamlOutput and err(if the method fails to apply). But, in the message that is being printed when there is an error, It is just printing the yamlOutput which is empty incase of a failure.

yamlOutput should be replaced with err. So, a proper error message is returned back to user for better understanding.

https://github.com/litmuschaos/litmusctl/blob/v0.8.0/pkg/cmd/create/agent.go

//Apply agent connection yaml
		yamlOutput, err := k8s.ApplyYaml(k8s.ApplyYamlPrams{
			Token:    agent.Data.UserAgentReg.Token,
			Endpoint: credentials.Endpoint,
			YamlPath: utils.ChaosYamlPath,
		}, kubeconfig, false)
		if err != nil {
			utils.White_B.Print("\n❌ Failed in applying connection yaml: \n" + yamlOutput)
			os.Exit(1)
		}

litmusctl to connect to chaos infrastrastructure: invalid apiVersion

Litmus version: 3.3.0
Litmusctl version: 1.2.0

When setting up an account, although it says the account has been configured, an internal system error is being returned.

$ litmusctl config set-account --endpoint="http://my-test-endpoint" --username="admin" --password="password" --non-interactive

account.username/admin configured
Error:  internal system error

$ litmusctl connect chaos-infra
Project list:
1.  admin-project

Select a project [Range: 1-1]: 1

Installation Modes:
1. Cluster
2. Namespace

Select Mode [Default: cluster] [Range: 1-2]: 1

🏃 Running prerequisites check....ERROR:  exec plugin: invalid apiVersion "client.authentication.k8s.io/v1"

With respect to the account setup error, "Error: internal system error", I see it was also being referred to in #169 and that it was being looked into. Is it still being looked into?

Pre-commit permission

git commit -s -m "create_probe:add api"

hint: The '.git/hooks/pre-commit' hook was ignored because it's not set as executable.

hint: You can disable this warning with `git config advice.ignoredHook false`.


might have to make changes in the commit in the recently add pre-commit hook script to give the necessary permission in the script itself.

Litmusctl should check existence of workflow name before scheduling & add the same if not present already

If the manifest provided by users doesn't contain name & only contains generateName, It fails with empty workflow name.

Issue :

Currently, Litmusctl expects the users to use workflow.metadata.name explicitly.

Reason :

Graphql-server also checks the workflow name provided via API parameters with workflow.metadata.name before scheduling so that we are able to track the workflow after scheduling. In UI also, we generate the workflow name ourself if workflow doesn't have it.

How we can enhance this?

Litmusctl can check if workflow contains workflow.metadata.name or not. If workflow contains workflow.metadata.generateName & not the workflow.metadata.name, Litmusctl can add the workflow.metadata.name by generating it by adding some hash to generateName . So, workflow.metadata.name will be workflow.metadata.generateName+(some-hash) .

litmusctl 0.22 is incompatible with ChaosCenter 2.14

The compatibility matrix seems to be wrong for 0.22.

We install litmus with the latest helm chart, which only supports 2.14.

It states 0.22 is compatible with 2.9.0+, but when running commands (config set-accont), the command lane complains that it is incompatible with 2.14.

Installing 0.21 fixes the issue

litmusctl set-account doesn't work in non-interactive mode

Hello all,

it is in regard litmusctl 1.0.0

when I try to configure new account for litmusctl by providing following command

./litmusctl config set-account --endpoint "https://<my_url>" --username "admin" --password "passwd" it's not created immediately and I'm prompted for all parameters again:

✔ Host endpoint where litmus is installed: <my_url>
✔ Username [Default: admin]: █dmin
✔ Password: ******█

and finally got following message:

account.username/admin configured
Error: internal system error

But it seems like account is configured - at least I can schedule workflows etc.

But the problem is that non-interactive mode is not working in litmusctl 1.0.0 and I cannot automate this process.

Thanks in advance,

BUG: Unable to create project when using `litmusctl` with latest (`v3.0.0`) version of Litmus

When trying to create a project using litmusctl we get following error:

Unmatched status code:{"error":"invalid_request","errorDescription":"The request is missing a required parameter, includes an invalid parameter value, includes a parameter more than once, or is otherwise malformed"}

When checking the logs for auth-server I see this in the logs:

{"file":"/go/pkg/mod/github.com/sirupsen/[email protected]/logger.go:192","func":"github.com/sirupsen/logrus.(*Logger).Log","level":"warning","msg":"json: unknown field \"project_name\"","time":"2023-10-16T11:28:38Z"}

This is because the project_name param has been renamed here to projectName. Changing payload to use projectName fixes the problem. Here is an example curl request.

curl --location 'http://localhost:9003/create_project' \
--header 'Content-Type: application/json' \
--header 'Authorization: Bearer <JWT TOKEN>' \
--data '{
    "projectName": "awesome-project"
}'

litmusctl 1.5.0 connect chaos-infra failed with openshift using namespace installation mode

$ litmusctl config use-account

Host endpoint where litmus is installed: https://

Username: admin

✅ Successfully set the current account to 'admin' at 'https://'

$ litmusctl connect chaos-infra
Project list:

  1. admin-project

Select a project [Range: 1-1]: 1

Installation Modes:

  1. Cluster
  2. Namespace

Select Mode [Default: cluster] [Range: 1-2]: 2

🏃 Running prerequisites check....
🔑 role ❌
🔑 rolebinding ❌
🚫 You don't have sufficient permissions.
🙄 Please use a service account with sufficient permissions.

Looking at litmus-server-role the following is set -->

  • apiGroups: [rbac.authorization.k8s.io]
    resources: [rolebindings, roles]
    verbs: [create]

And in the ValidateSAPermissions function on ops.go the resources are like -->

if mode == "cluster" {
resources = [2]string{"clusterrole", "clusterrolebinding"}
} else {
resources = [2]string{"role", "rolebinding"}

I guess that should be 'roles' and 'rolesbinding', right?.

Refactor the update command

Update command currently does not follow the command convention. we already have a version command we can just add this update command as subcommand for version command. It should look something like this
litmusctl version update

or we can just add a flag for updating
litmusctl version --update

this seems like a better approach for me

missing imagePullSecrets when using custom private image registry

After chaosCenter is configured to use private image registry, when use litmusctl to connect new delegate, it will get the images from the new private registry, however imagePullSecrets tag is missing from the generated deployment, result in all imagepull failure.

This issue can be easily replicated by change the image registry to a private registry in chaosCenter, then try with a litmusctl connect.

Will the litmusctl to support create/list/delete probe?

I don't find the command line support to create the probes. I have to create them via UI. It prevents to me create a bash script to automate the testing. Please suggest if there is a plan. I am happy to submit a PR if I know where to check the graphql api specs for probes.

Upgrade operation in litmusctl needs error handling

What happened:

Tried creating a new user and invited the same as viewer in my project. When that user tries to upgrade an agent, we get this error -

panic: runtime error: invalid memory address or nil pointer dereference
[signal SIGSEGV: segmentation violation code=0x1 addr=0x0 pc=0x1ed9b9a]

goroutine 1 [running]: 

What you expected to happen:

As a viewer, user should not able to upgrade agent. Checked from API, it is returning permission denied error. But litmusctl is not handling the same.

Where can this issue be corrected? (optional)

We need add checks for error in below places -

	if resp.StatusCode == http.StatusOK {
		err = json.Unmarshal(bodyBytes, &agent)
		if err != nil {
			return "", err
		}
	}
	// Checks if status code is OK(200)
	if resp.StatusCode == http.StatusOK {
		var manifest manifestData
		err = json.Unmarshal(bodyBytes, &manifest)
		if err != nil {
			return "", err
		}

How to reproduce it (as minimally and precisely as possible):

  1. Create a new user
  2. Invite same user as viewer in your project.
  3. configure litmusctl with viewer's credentials & try to upgrade the agent.

Anything else we need to know?:

The error is actually handled in similar places for ref -

if len(agent.Errors) > 0 {

connect chaos-delegate

Did I understand correctly - with "litmusctl connect chaos-delegate" command you can connect another cluster (delegated)?

In my case it creates resources, but hangs in a "pending" state.
Delegated subscriber tries to connect to the SVC IP address from another cluster (not via litmus ENDPOINT / API)
msg="Failed to confirm cluster" data= error="Post \"http://10.99.20.228:9002/query\": dial tcp 10.99.20.228:9002: i/o timeout"
image

--output=json does not print json format

Hi. When I try to get the project id in json or yaml format, the output is the interactive table, not json

$ litmusctl get projects --output=json
$ litmusctl get projects --output json
$ litmusctl get projects -o=json
$ litmusctl get projects -o json
PROJECT ID                                      PROJECT NAME            CREATED AT
1234567-89ab-cdef-12345-6789abcdefab            admin-project           123-45-67 89:01:23 +0000 UTC
✔ Press Enter to show the next page (or type 'q' to quit): █

How can I print json format? I tried with litmusctl 1.1.0 and 1.2.0.

What I'm trying to do is to automate the creation of a chaos-environment with litmusctl, but it asks for a project-id first.

$ litmusctl create chaos-environment --name=my-environment --type=cluster --project-id=XXXXX

How to use the config file to provide parameters for the command: litmusctl connect chaos-delegate --config config.yaml

I am learning how to use litmusctl command to connect chaotic delegates,and an example of non-interactive mode usage of this command is as follows:

litmusctl connect chaos-delegate \
--project-id="bbc9558a-2033-439e-85b1-84dd33b02837" \
--name="chaos-delegate" \
--skip-ssl=true \
--installation-mode="cluster" \
--namespace="chaos-delegate-ns" \
--ns-exists=false \
--platform-name="Others" \
--service-account="litmus" \
--sa-exists=false \
--non-interactive

In the process of learning, I found this usage: litmusctl connect chaos-delegate --config [config file].
So I wonder whether the config file here has the usage of providing the parameters required for the litmusctl connect chaos-delete command, such as "-- namespace" and “--name”.
If the config file has this function, how should I write my config file?

graphql server encountered a runtime error

Before following the official documentation, I wanted to do something related to the litmusctl command.
When running the command below, an internal system error occurred.

litmusctl config set-account 

image

I checked and found that a runtime error occurred in the graphql server.
When I try to process the litmusctl command with the password of the admin account as the initial password 'litmus' and a random string created by the password generator, I get the same error.

{"body_size":109,"client_ip":"111.222.333.444","error":"","file":"/gql-server/api/middleware/logger.go:60","func":"github.com/litmuschaos/litmus/chaoscenter/graphql/server/api/middleware.Structure  
runtime error: invalid memory address or nil pointer dereference                                                                                                                                      
                                                                                                                                                                                                      
goroutine 591 [running]:                                                                                                                                                                              
runtime/debug.Stack()                                                                                                                                                                                 
    /usr/local/go/src/runtime/debug/stack.go:24 +0x65                                                                                                                                                 
runtime/debug.PrintStack()                                                                                                                                                                            
    /usr/local/go/src/runtime/debug/stack.go:16 +0x19                                                                                                                                                 
github.com/99designs/gqlgen/graphql.DefaultRecover({0xafd5c6?, 0x0?}, {0x1be0400?, 0x3040f00?})                                                                                                       
    /go/pkg/mod/github.com/99designs/[email protected]/graphql/recovery.go:16 +0x71                                                                                                                      
github.com/litmuschaos/litmus/chaoscenter/graphql/server/graph/generated.(*executionContext)._Query_getServerVersion.func1()                                                                          
    /gql-server/graph/generated/generated.go:23220 +0x71                                                                                                                                              
panic({0x1be0400, 0x3040f00})                                                                                                                                                                         
    /usr/local/go/src/runtime/panic.go:884 +0x213                                                                                                                                                     
github.com/litmuschaos/litmus/chaoscenter/graphql/server/pkg/chaos_infrastructure.(*infraService).QueryServerVersion(0x1a0c665?, {0x21e8370?, 0xc007b5f770?})                                         
    /gql-server/pkg/chaos_infrastructure/service.go:925 +0x49                                                                                                                                         
github.com/litmuschaos/litmus/chaoscenter/graphql/server/graph.(*queryResolver).GetServerVersion(0xc0004678c0?, {0x21e8370?, 0xc007b5f770?})                                                          
    /gql-server/graph/chaos_infrastructure.resolvers.go:197 +0x31                                                                                                                                     
github.com/litmuschaos/litmus/chaoscenter/graphql/server/graph/generated.(*executionContext)._Query_getServerVersion.func2({0x21e8370?, 0xc007b5f770})                                                
    /gql-server/graph/generated/generated.go:23234 +0x77                                                                                                                                              
github.com/99designs/gqlgen/graphql/executor.processExtensions.func3({0x21e8370?, 0xc007b5f770?}, 0xc000bb89c0?)                                                                                      
    /go/pkg/mod/github.com/99designs/[email protected]/graphql/executor/extensions.go:62 +0x26                                                                                                           
github.com/litmuschaos/litmus/chaoscenter/graphql/server/graph/generated.(*executionContext)._Query_getServerVersion(0xc0005b47c0, {0x21e8370, 0xc007b5f740}, {0xc0006ca680?, {0xc00071e660?, 0x10?,  
    /gql-server/graph/generated/generated.go:23232 +0x243                                                                                                                                             
github.com/litmuschaos/litmus/chaoscenter/graphql/server/graph/generated.(*executionContext)._Query.func13()                                                                                          
    /gql-server/graph/generated/generated.go:32706 +0x90                                                                                                                                              
github.com/99designs/gqlgen/graphql.(*FieldSet).Dispatch(0xc0003847d0)                                                                                                                                
    /go/pkg/mod/github.com/99designs/[email protected]/graphql/fieldset.go:34 +0x8e                                                                                                                      
github.com/litmuschaos/litmus/chaoscenter/graphql/server/graph/generated.(*executionContext)._Query(0xc0005b47c0, {0x21e8370, 0xc007b5f710}, {0xc0005b4570, 0x1, 0x1})                                
    /gql-server/graph/generated/generated.go:32963 +0x41e7                                                                                                                                            
github.com/litmuschaos/litmus/chaoscenter/graphql/server/graph/generated.(*executableSchema).Exec.func1({0x21e8370?, 0xc007b5f710?})                                                                  
    /gql-server/graph/generated/generated.go:4340 +0x5b                                                                                                                                               
github.com/99designs/gqlgen/graphql/executor.(*Executor).DispatchOperation.func1.1.1({0x21e8370, 0xc007b5f710})                                                                                       
    /go/pkg/mod/github.com/99designs/[email protected]/graphql/executor/executor.go:105 +0x2b                                                                                                            
github.com/99designs/gqlgen/graphql/executor.processExtensions.func2({0x21e8370?, 0xc007b5f710?}, 0x1b33b60?)                                                                                         
    /go/pkg/mod/github.com/99designs/[email protected]/graphql/executor/extensions.go:59 +0x26                                                                                                           
github.com/99designs/gqlgen/graphql/executor.(*Executor).DispatchOperation.func1.1({0x21e8370, 0xc007b5f6b0})                                                                                         
    /go/pkg/mod/github.com/99designs/[email protected]/graphql/executor/executor.go:104 +0x110                                                                                                           
github.com/99designs/gqlgen/graphql/handler/transport.POST.Do({}, {0x7efde0f59178, 0xc0001bee00}, 0xc000aa6300, {0x21daf70, 0xc0005b6240})                                                            
    /go/pkg/mod/github.com/99designs/[email protected]/graphql/handler/transport/http_post.go:52 +0x308                                                                                                  
github.com/99designs/gqlgen/graphql/handler.(*Server).ServeHTTP(0xc0007bc220, {0x7efde0f59178, 0xc0001bee00}, 0xc000aa6300)                                                                           
    /go/pkg/mod/github.com/99designs/[email protected]/graphql/handler/server.go:115 +0x273                                                                                                              
github.com/litmuschaos/litmus/chaoscenter/graphql/server/pkg/authorization.Middleware.func1(0xc0001bee00)                                                                                             
    /gql-server/pkg/authorization/middleware.go:39 +0x2a5                                                                                                                                             
github.com/gin-gonic/gin.(*Context).Next(...)                                                                                                                                                         
    /go/pkg/mod/github.com/gin-gonic/[email protected]/context.go:174                                                                                                                                        
github.com/gin-gonic/gin.CustomRecoveryWithWriter.func1(0xc0001bee00)                                                                                                                                 
    /go/pkg/mod/github.com/gin-gonic/[email protected]/recovery.go:102 +0x82                                                                                                                                 
github.com/gin-gonic/gin.(*Context).Next(...)                                                                                                                                                         
    /go/pkg/mod/github.com/gin-gonic/[email protected]/context.go:174                                                                                                                                        
github.com/litmuschaos/litmus/chaoscenter/graphql/server/api/middleware.StructuredLogger.func1(0xc0001bee00)                                                                                          
    /gql-server/api/middleware/logger.go:26 +0x9a                                                                                                                                                     
github.com/gin-gonic/gin.(*Context).Next(...)                                                                                                                                                         
    /go/pkg/mod/github.com/gin-gonic/[email protected]/context.go:174                                                                                                                                        
github.com/gin-gonic/gin.(*Engine).handleHTTPRequest(0xc000449d40, 0xc0001bee00)                                                                                                                      
    /go/pkg/mod/github.com/gin-gonic/[email protected]/gin.go:620 +0x66b                                                                                                                                     
github.com/gin-gonic/gin.(*Engine).ServeHTTP(0xc000449d40, {0x21e71e0?, 0xc0009247e0}, 0xc0001bf600)                                                                                                  
    /go/pkg/mod/github.com/gin-gonic/[email protected]/gin.go:576 +0x1dd                                                                                                                                     
net/http.serverHandler.ServeHTTP({0x21d9178?}, {0x21e71e0, 0xc0009247e0}, 0xc0001bf600)                                                                                                               
    /usr/local/go/src/net/http/server.go:2936 +0x316                                                                                                                                                  
net/http.(*conn).serve(0xc000530cf0, {0x21e8370, 0xc0002a1d70})                                                                                                                                       
    /usr/local/go/src/net/http/server.go:1995 +0x612                                                                                                                                                  
created by net/http.(*Server).Serve                                                                                                                                                                   
    /usr/local/go/src/net/http/server.go:3089 +0x5ed
$ litmusctl version
Litmusctl version:  1.4.0
Compatible ChaosCenter versions: 
[ '3.0.0' '3.1.0' '3.2.0' '3.3.0' '3.4.0' '3.5.0' ]

$ helm list -n litmus
NAME    NAMESPACE       REVISION        UPDATED                                 STATUS          CHART           APP VERSION
chaos   litmus          1               2024-03-25 14:56:51.308193 +0900 KST    deployed        litmus-3.1.0    3.1.0

Separate API query for get and list environment

I think we should separate the api query for get environment command and list environment command. Currently for get environment command we use the GetEnvironmentList api function and iterate it for the environment id we need details on. In this process we also query details of environments we does not need.

litmusctl connect chaos-infra: failed to get the Infra registration token:

What happened:
Litmusctl version: 1.0.0

$litmusctl config set-account
Host endpoint where litmus is installed:
Username [Default: admin]: admin
Password: ******

account.username/admin configured
Error: internal system error

$litmusctl connect chaos-infra
...

❌ failed to get the Infra registration token:

there is issue #169 on "litmusctl config set-account" error, i have the same issue before use "litmusctl connect chaos-infra"

not sure if the fix of issue 169 will resolve this issue or not.

Broken dependencies on master

Description
When trying to build binary for master branch using command go build. It throws this error

../../../go/pkg/mod/github.com/argoproj/argo-workflows/[email protected]/pkg/apis/workflow/common.go:6:2: missing go.sum entry for module providing package k8s.io/client-go/rest (imported by github.com/litmuschaos/litmusctl/pkg/k8s); to add:

	go get github.com/litmuschaos/litmusctl/pkg/k8s

../../../go/pkg/mod/github.com/argoproj/argo-workflows/[email protected]/pkg/apis/workflow/common.go:7:2: missing go.sum entry for module providing package k8s.io/client-go/tools/clientcmd/api (imported by github.com/argoproj/argo-workflows/v3/pkg/apis/workflow); to add:

	go get github.com/argoproj/argo-workflows/v3/pkg/apis/[email protected]

../../../go/pkg/mod/github.com/argoproj/argo-workflows/[email protected]/pkg/apis/workflow/v1alpha1/container_set_template_types.go:7:2: missing go.sum entry for module providing package k8s.io/api/core/v1 (imported by github.com/litmuschaos/litmusctl/pkg/k8s); to add:

	go get github.com/litmuschaos/litmusctl/pkg/k8s

../../../go/pkg/mod/github.com/argoproj/argo-workflows/[email protected]/pkg/apis/workflow/v1alpha1/generated.pb.go:16:2: missing go.sum entry for module providing package k8s.io/api/policy/v1beta1 (imported by github.com/argoproj/argo-workflows/v3/pkg/apis/workflow/v1alpha1); to add:

	go get github.com/argoproj/argo-workflows/v3/pkg/apis/workflow/[email protected]

../../../go/pkg/mod/github.com/argoproj/argo-workflows/[email protected]/pkg/apis/workflow/v1alpha1/workflow_types.go:19:2: missing go.sum entry for module providing package k8s.io/apimachinery/pkg/api/resource (imported by github.com/argoproj/argo-workflows/v3/pkg/apis/workflow/v1alpha1); to add:

	go get github.com/argoproj/argo-workflows/v3/pkg/apis/workflow/[email protected]

../../../go/pkg/mod/github.com/argoproj/argo-workflows/[email protected]/pkg/apis/workflow/v1alpha1/cluster_workflow_template_types.go:6:2: missing go.sum entry for module providing package k8s.io/apimachinery/pkg/apis/meta/v1 (imported by github.com/litmuschaos/litmusctl/pkg/infra_ops); to add:

	go get github.com/litmuschaos/litmusctl/pkg/infra_ops

../../../go/pkg/mod/github.com/argoproj/argo-workflows/[email protected]/pkg/apis/workflow/v1alpha1/workflow_types.go:21:2: missing go.sum entry for module providing package k8s.io/apimachinery/pkg/labels (imported by github.com/argoproj/argo-workflows/v3/pkg/apis/workflow/v1alpha1); to add:

	go get github.com/argoproj/argo-workflows/v3/pkg/apis/workflow/[email protected]

../../../go/pkg/mod/github.com/argoproj/argo-workflows/[email protected]/pkg/apis/workflow/v1alpha1/register.go:5:2: missing go.sum entry for module providing package k8s.io/apimachinery/pkg/runtime (imported by github.com/argoproj/argo-workflows/v3/pkg/apis/workflow/v1alpha1); to add:

	go get github.com/argoproj/argo-workflows/v3/pkg/apis/workflow/[email protected]

../../../go/pkg/mod/github.com/argoproj/argo-workflows/[email protected]/pkg/apis/workflow/v1alpha1/common.go:5:2: missing go.sum entry for module providing package k8s.io/apimachinery/pkg/runtime/schema (imported by github.com/litmuschaos/litmusctl/pkg/k8s); to add:

	go get github.com/litmuschaos/litmusctl/pkg/k8s

../../../go/pkg/mod/github.com/argoproj/argo-workflows/[email protected]/pkg/apis/workflow/v1alpha1/cron_workflow_types.go:6:2: missing go.sum entry for module providing package k8s.io/apimachinery/pkg/types (imported by github.com/argoproj/argo-workflows/v3/pkg/apis/workflow/v1alpha1); to add:

	go get github.com/argoproj/argo-workflows/v3/pkg/apis/workflow/[email protected]

../../../go/pkg/mod/github.com/argoproj/argo-workflows/[email protected]/pkg/apis/workflow/v1alpha1/container_set_template_types.go:8:2: missing go.sum entry for module providing package k8s.io/apimachinery/pkg/util/intstr (imported by github.com/argoproj/argo-workflows/v3/pkg/apis/workflow/v1alpha1); to add:

	go get github.com/argoproj/argo-workflows/v3/pkg/apis/workflow/[email protected]

../../../go/pkg/mod/github.com/argoproj/argo-workflows/[email protected]/pkg/apis/workflow/v1alpha1/validation_utils.go:9:2: missing go.sum entry for module providing package k8s.io/apimachinery/pkg/util/validation (imported by github.com/argoproj/argo-workflows/v3/pkg/apis/workflow/v1alpha1); to add:

	go get github.com/argoproj/argo-workflows/v3/pkg/apis/workflow/[email protected]

../../../go/pkg/mod/github.com/argoproj/argo-workflows/[email protected]/pkg/apis/workflow/v1alpha1/container_set_template_types.go:9:2: missing go.sum entry for module providing package k8s.io/apimachinery/pkg/util/wait (imported by github.com/argoproj/argo-workflows/v3/pkg/apis/workflow/v1alpha1); to add:

	go get github.com/argoproj/argo-workflows/v3/pkg/apis/workflow/[email protected]

../../../go/pkg/mod/k8s.io/[email protected]/pkg/common/common.go:23:2: github.com/go-openapi/[email protected]: missing go.sum entry for go.mod file; to add it:

	go mod download github.com/go-openapi/jsonpointer

../../../go/pkg/mod/k8s.io/[email protected]/pkg/validation/spec/ref.go:23:2: missing go.sum entry for module providing package github.com/go-openapi/jsonreference (imported by k8s.io/kube-openapi/pkg/validation/spec); to add:

	go get k8s.io/kube-openapi/pkg/validation/[email protected]

../../../go/pkg/mod/k8s.io/[email protected]/pkg/validation/spec/header.go:20:2: missing go.sum entry for module providing package github.com/go-openapi/swag (imported by k8s.io/kube-openapi/pkg/validation/spec); to add:

	go get k8s.io/kube-openapi/pkg/validation/[email protected]

../../../go/pkg/mod/github.com/litmuschaos/[email protected]/api/litmuschaos/v1alpha1/chaosexperiment_types.go:21:2: missing go.sum entry for module providing package k8s.io/api/rbac/v1 (imported by github.com/litmuschaos/chaos-operator/api/litmuschaos/v1alpha1); to add:

	go get github.com/litmuschaos/chaos-operator/api/litmuschaos/[email protected]

pkg/k8s/operations.go:41:2: missing go.sum entry for module providing package k8s.io/api/authorization/v1 (imported by github.com/litmuschaos/litmusctl/pkg/k8s); to add:

	go get github.com/litmuschaos/litmusctl/pkg/k8s

pkg/k8s/operations.go:43:2: missing go.sum entry for module providing package k8s.io/apimachinery/pkg/api/errors (imported by github.com/litmuschaos/litmusctl/pkg/k8s); to add:

	go get github.com/litmuschaos/litmusctl/pkg/k8s

pkg/k8s/operations.go:44:2: missing go.sum entry for module providing package k8s.io/apimachinery/pkg/api/meta (imported by github.com/litmuschaos/litmusctl/pkg/k8s); to add:

	go get github.com/litmuschaos/litmusctl/pkg/k8s

pkg/k8s/operations.go:46:2: missing go.sum entry for module providing package k8s.io/apimachinery/pkg/apis/meta/v1/unstructured (imported by github.com/litmuschaos/litmusctl/pkg/k8s); to add:

	go get github.com/litmuschaos/litmusctl/pkg/k8s

pkg/k8s/operations.go:48:2: missing go.sum entry for module providing package k8s.io/apimachinery/pkg/util/yaml (imported by github.com/litmuschaos/litmusctl/pkg/k8s); to add:

	go get github.com/litmuschaos/litmusctl/pkg/k8s

pkg/k8s/operations.go:49:2: missing go.sum entry for module providing package k8s.io/client-go/discovery (imported by github.com/litmuschaos/litmusctl/pkg/k8s); to add:

	go get github.com/litmuschaos/litmusctl/pkg/k8s

pkg/k8s/operations.go:31:2: missing go.sum entry for module providing package k8s.io/client-go/discovery/cached/memory (imported by github.com/litmuschaos/litmusctl/pkg/k8s); to add:

	go get github.com/litmuschaos/litmusctl/pkg/k8s

pkg/k8s/operations.go:32:2: missing go.sum entry for module providing package k8s.io/client-go/dynamic (imported by github.com/litmuschaos/litmusctl/pkg/k8s); to add:

	go get github.com/litmuschaos/litmusctl/pkg/k8s

pkg/k8s/client.go:24:2: missing go.sum entry for module providing package k8s.io/client-go/kubernetes (imported by github.com/litmuschaos/litmusctl/pkg/k8s); to add:

	go get github.com/litmuschaos/litmusctl/pkg/k8s

pkg/k8s/operations.go:50:2: missing go.sum entry for module providing package k8s.io/client-go/kubernetes/typed/authorization/v1 (imported by github.com/litmuschaos/litmusctl/pkg/k8s); to add:

	go get github.com/litmuschaos/litmusctl/pkg/k8s

pkg/k8s/client.go:25:2: missing go.sum entry for module providing package k8s.io/client-go/plugin/pkg/client/auth (imported by github.com/litmuschaos/litmusctl/pkg/k8s); to add:

	go get github.com/litmuschaos/litmusctl/pkg/k8s

pkg/k8s/operations.go:35:2: missing go.sum entry for module providing package k8s.io/client-go/restmapper (imported by github.com/litmuschaos/litmusctl/pkg/k8s); to add:

	go get github.com/litmuschaos/litmusctl/pkg/k8s

pkg/k8s/client.go:26:2: missing go.sum entry for module providing package k8s.io/client-go/tools/clientcmd (imported by github.com/litmuschaos/litmusctl/pkg/k8s); to add:

	go get github.com/litmuschaos/litmusctl/pkg/k8s

pkg/k8s/client.go:27:2: missing go.sum entry for module providing package k8s.io/client-go/util/homedir (imported by github.com/litmuschaos/litmusctl/pkg/k8s); to add:

	go get github.com/litmuschaos/litmusctl/pkg/k8s

Fix :
go get to get the missing dependencies.

litmusctl version command shows empty output for local setup

how to reproduce:

  1. clone the repository
  2. build the binary
  3. move to the binary to local bin folder
  4. use command litmusctl version

possible reasons
In the version command defined under pkg/cmd/version/version.go it uses the environment variables to extract the litmusctl version.
As I checked further the environment variable CLIversion is set under the main.go file. Which relies on the build process to get the version, which is not what we do for local setup.

possible solution
For now i think we should simply add a check if the version is set in the environment rather than giving an empty output. golang doesn't throw any error as it supports variables without explicitly initialising them. I will add that check but I am confused about the version information in the local.

Resolve staticcheck warnings

how to reproduce:

run golangci-lint run --enable goimports --enable gofmt --timeout 10m in the terminal

Screenshot:
Screenshot 2024-02-03 at 7 04 23 PM

Make scenario parsing logic for `litmsuctl create scenario` command independent of `install-chaos-experiments` step

Generally the scenario manifests created via Chaos-Center contains an install-chaos-experiments step, which contains definition for all experiments users are going to run as part of that scenario. At the time of implementation of this feature (litmusctl create scenario), it was decided to use install-chaos-experiments step to fetch names of all experiments, users have added in the manifest.

But this can't be always the case, users may not have install-chaos-experiments step in their manifests while scheduling it via litmusctl.

When we upload a manifest in frontend, we had enhanced the logic in frontend by searching for templates which contains kind: ChaosEngine & fetch their names. Since a template containing kind: ChaosEngine denotes a chaos experiment. Same can be done in litmusctl making it independent of install-chaos-experiment.

For reference, how it's done in frontend - https://github.com/litmuschaos/litmus/blob/643f3bffb87a20fee209a77b842ad7eda01d1e54/litmus-portal/frontend/src/utils/yamlUtils.ts#L250

Get chaos environments command

Add a command to get a list of chaos environments in a project.
litmusctl get chaos-environment --project-id="" --environment-id=""
litmusctl list chaos-environment --project-id=""

Issues when reconnect a delegate

  1. when a delegate is disconnected from chaosCenter, the services (workflow-controller, cahos-operator etc) still running in the delegate cluster. Unable to reconnect using the existing namespace and service account, as it will complain a delegate is existed.
    How do we reconnect using the existing delegate back to the chaosCenter? or the only option is to undeploy all the related services and start from litmusctl connect chaos-delegate command again?

  2. when reconnect a delegate, it will always assigned with a new delegate ID, which means all the previously configured scenarios cannot be used, will have to re-create again. Any future enhancement to allow reconnect a delegate with existing delegate-id?

Out of bound error in get projects command

Description
If there are no more projects to display litmusctl get projects throws out of bound error.

litmusctl get projects

PROJECT ID					PROJECT NAME		CREATED AT
8adf62d5-64f8-4c66-ab53-63729db9dd9a		admin-project		55908-03-27 09:52:19 +0530 IST	
	
Press Enter to show the next page (or type 'q' to quit): 
panic: runtime error: slice bounds out of range [5:1]


goroutine 1 [running]:
github.com/litmuschaos/litmusctl/pkg/cmd/get.glob..func5(0xc000279d00?, {0x1813151?, 0x4?, 0x1812ff9?})
	/home/vboxuser/Desktop/lfx/litmusctl/pkg/cmd/get/projects.go:72 +0x50c
github.com/spf13/cobra.(*Command).execute(0x26646e0, {0x26a90a0, 0x0, 0x0})
	/home/vboxuser/go/pkg/mod/github.com/spf13/[email protected]/command.go:860 +0x67b
github.com/spf13/cobra.(*Command).ExecuteC(0x265fbe0)
	/home/vboxuser/go/pkg/mod/github.com/spf13/[email protected]/command.go:974 +0x38d
github.com/spf13/cobra.(*Command).Execute(...)
	/home/vboxuser/go/pkg/mod/github.com/spf13/[email protected]/command.go:902
github.com/litmuschaos/litmusctl/pkg/cmd/root.Execute()
	/home/vboxuser/Desktop/lfx/litmusctl/pkg/cmd/root/root.go:62 +0x1a
main.main()
	/home/vboxuser/Desktop/lfx/litmusctl/main.go:33 +0x75

Possible solution
It would be nice to add a little check if the start index goes out of bound and show a message that there exists no more projects.

Automate tests in pre-commit hook script.

Currently we dont have any scripts to check for linting/ formatting error in local. I propose we should add a script to extract certain steps/command directly from .github/workflow and execute them before committing. This will eliminate extra commit fixing the lint and format. This will also ensure each commit is independent and does not give any error. We can further expand it to run the tests before any push to ensure each commit is complete without any errors.

what we need:
A script to extract steps/commads ( probably python script )

A script to execute the commands ( bash script ) .precommit script which can be symlink with git/hook/precommit
ln -s ../../.pre-commit .git/hooks/pre-commit . This will automatically trigger on commit.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.