Skip to content

Commit

Permalink
Fix gofmt issues (#695)
Browse files Browse the repository at this point in the history
  • Loading branch information
uditgaurav committed Apr 25, 2024
1 parent 78eec36 commit a440615
Show file tree
Hide file tree
Showing 50 changed files with 106 additions and 103 deletions.
10 changes: 5 additions & 5 deletions chaoslib/litmus/container-kill/helper/container-kill.go
Original file line number Diff line number Diff line change
Expand Up @@ -171,7 +171,7 @@ func validate(t targetDetails, timeout, delay int, clients clients.ClientSets) e
return verifyRestartCount(t, timeout, delay, clients, t.RestartCountBefore)
}

//stopContainerdContainer kill the application container
// stopContainerdContainer kill the application container
func stopContainerdContainer(containerIDs []string, socketPath, signal, source string) error {
if signal != "SIGKILL" && signal != "SIGTERM" {
return cerrors.Error{ErrorCode: cerrors.ErrorTypeHelper, Source: source, Reason: fmt.Sprintf("unsupported signal %s, use either SIGTERM or SIGKILL", signal)}
Expand All @@ -192,7 +192,7 @@ func stopContainerdContainer(containerIDs []string, socketPath, signal, source s
return nil
}

//stopDockerContainer kill the application container
// stopDockerContainer kill the application container
func stopDockerContainer(containerIDs []string, socketPath, signal, source string) error {
var errOut, out bytes.Buffer
cmd := exec.Command("sudo", "docker", "--host", fmt.Sprintf("unix://%s", socketPath), "kill", "--signal", signal)
Expand All @@ -205,7 +205,7 @@ func stopDockerContainer(containerIDs []string, socketPath, signal, source strin
return nil
}

//getRestartCount return the restart count of target container
// getRestartCount return the restart count of target container
func getRestartCount(target targetDetails, clients clients.ClientSets) (int, error) {
pod, err := clients.KubeClient.CoreV1().Pods(target.Namespace).Get(context.Background(), target.Name, v1.GetOptions{})
if err != nil {
Expand All @@ -221,7 +221,7 @@ func getRestartCount(target targetDetails, clients clients.ClientSets) (int, err
return restartCount, nil
}

//verifyRestartCount verify the restart count of target container that it is restarted or not after chaos injection
// verifyRestartCount verify the restart count of target container that it is restarted or not after chaos injection
func verifyRestartCount(t targetDetails, timeout, delay int, clients clients.ClientSets, restartCountBefore int) error {

restartCountAfter := 0
Expand All @@ -247,7 +247,7 @@ func verifyRestartCount(t targetDetails, timeout, delay int, clients clients.Cli
})
}

//getENV fetches all the env variables from the runner pod
// getENV fetches all the env variables from the runner pod
func getENV(experimentDetails *experimentTypes.ExperimentDetails) {
experimentDetails.ExperimentName = types.Getenv("EXPERIMENT_NAME", "")
experimentDetails.InstanceID = types.Getenv("INSTANCE_ID", "")
Expand Down
6 changes: 3 additions & 3 deletions chaoslib/litmus/container-kill/lib/container-kill.go
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ import (
v1 "k8s.io/apimachinery/pkg/apis/meta/v1"
)

//PrepareContainerKill contains the preparation steps before chaos injection
// PrepareContainerKill contains the preparation steps before chaos injection
func PrepareContainerKill(experimentsDetails *experimentTypes.ExperimentDetails, clients clients.ClientSets, resultDetails *types.ResultDetails, eventsDetails *types.EventDetails, chaosDetails *types.ChaosDetails) error {

var err error
Expand Down Expand Up @@ -280,8 +280,8 @@ func getPodEnv(experimentsDetails *experimentTypes.ExperimentDetails, targets st
return envDetails.ENV
}

//SetChaosTunables will setup a random value within a given range of values
//If the value is not provided in range it'll setup the initial provided value.
// SetChaosTunables will setup a random value within a given range of values
// If the value is not provided in range it'll setup the initial provided value.
func SetChaosTunables(experimentsDetails *experimentTypes.ExperimentDetails) {
experimentsDetails.PodsAffectedPerc = common.ValidateRange(experimentsDetails.PodsAffectedPerc)
experimentsDetails.Sequence = common.GetRandomSequence(experimentsDetails.Sequence)
Expand Down
2 changes: 1 addition & 1 deletion chaoslib/litmus/disk-fill/lib/disk-fill.go
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ import (
v1 "k8s.io/apimachinery/pkg/apis/meta/v1"
)

//PrepareDiskFill contains the preparation steps before chaos injection
// PrepareDiskFill contains the preparation steps before chaos injection
func PrepareDiskFill(experimentsDetails *experimentTypes.ExperimentDetails, clients clients.ClientSets, resultDetails *types.ResultDetails, eventsDetails *types.EventDetails, chaosDetails *types.ChaosDetails) error {

var err error
Expand Down
2 changes: 1 addition & 1 deletion chaoslib/litmus/http-chaos/lib/header/header.go
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ import (
"github.com/sirupsen/logrus"
)

//PodHttpModifyHeaderChaos contains the steps to prepare and inject http modify header chaos
// PodHttpModifyHeaderChaos contains the steps to prepare and inject http modify header chaos
func PodHttpModifyHeaderChaos(experimentsDetails *experimentTypes.ExperimentDetails, clients clients.ClientSets, resultDetails *types.ResultDetails, eventsDetails *types.EventDetails, chaosDetails *types.ChaosDetails) error {

log.InfoWithValues("[Info]: The chaos tunables are:", logrus.Fields{
Expand Down
6 changes: 3 additions & 3 deletions chaoslib/litmus/http-chaos/lib/http-chaos.go
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ import (
v1 "k8s.io/apimachinery/pkg/apis/meta/v1"
)

//PrepareAndInjectChaos contains the preparation & injection steps
// PrepareAndInjectChaos contains the preparation & injection steps
func PrepareAndInjectChaos(experimentsDetails *experimentTypes.ExperimentDetails, clients clients.ClientSets, resultDetails *types.ResultDetails, eventsDetails *types.EventDetails, chaosDetails *types.ChaosDetails, args string) error {

var err error
Expand Down Expand Up @@ -284,8 +284,8 @@ func getPodEnv(experimentsDetails *experimentTypes.ExperimentDetails, targets, a
return envDetails.ENV
}

//SetChaosTunables will set up a random value within a given range of values
//If the value is not provided in range it'll set up the initial provided value.
// SetChaosTunables will set up a random value within a given range of values
// If the value is not provided in range it'll set up the initial provided value.
func SetChaosTunables(experimentsDetails *experimentTypes.ExperimentDetails) {
experimentsDetails.PodsAffectedPerc = common.ValidateRange(experimentsDetails.PodsAffectedPerc)
experimentsDetails.Sequence = common.GetRandomSequence(experimentsDetails.Sequence)
Expand Down
2 changes: 1 addition & 1 deletion chaoslib/litmus/http-chaos/lib/latency/latency.go
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ import (
"github.com/sirupsen/logrus"
)

//PodHttpLatencyChaos contains the steps to prepare and inject http latency chaos
// PodHttpLatencyChaos contains the steps to prepare and inject http latency chaos
func PodHttpLatencyChaos(experimentsDetails *experimentTypes.ExperimentDetails, clients clients.ClientSets, resultDetails *types.ResultDetails, eventsDetails *types.EventDetails, chaosDetails *types.ChaosDetails) error {

log.InfoWithValues("[Info]: The chaos tunables are:", logrus.Fields{
Expand Down
2 changes: 1 addition & 1 deletion chaoslib/litmus/http-chaos/lib/reset/reset.go
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ import (
"github.com/sirupsen/logrus"
)

//PodHttpResetPeerChaos contains the steps to prepare and inject http reset peer chaos
// PodHttpResetPeerChaos contains the steps to prepare and inject http reset peer chaos
func PodHttpResetPeerChaos(experimentsDetails *experimentTypes.ExperimentDetails, clients clients.ClientSets, resultDetails *types.ResultDetails, eventsDetails *types.EventDetails, chaosDetails *types.ChaosDetails) error {

log.InfoWithValues("[Info]: The chaos tunables are:", logrus.Fields{
Expand Down
4 changes: 2 additions & 2 deletions chaoslib/litmus/network-chaos/helper/netem.go
Original file line number Diff line number Diff line change
Expand Up @@ -76,7 +76,7 @@ func Helper(clients clients.ClientSets) {

}

//preparePodNetworkChaos contains the prepration steps before chaos injection
// preparePodNetworkChaos contains the prepration steps before chaos injection
func preparePodNetworkChaos(experimentsDetails *experimentTypes.ExperimentDetails, clients clients.ClientSets, eventsDetails *types.EventDetails, chaosDetails *types.ChaosDetails, resultDetails *types.ResultDetails) error {

targetEnv := os.Getenv("TARGETS")
Expand Down Expand Up @@ -295,7 +295,7 @@ type targetDetails struct {
Source string
}

//getENV fetches all the env variables from the runner pod
// getENV fetches all the env variables from the runner pod
func getENV(experimentDetails *experimentTypes.ExperimentDetails) {
experimentDetails.ExperimentName = types.Getenv("EXPERIMENT_NAME", "")
experimentDetails.InstanceID = types.Getenv("INSTANCE_ID", "")
Expand Down
2 changes: 1 addition & 1 deletion chaoslib/litmus/network-chaos/lib/corruption/corruption.go
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ import (
"github.com/litmuschaos/litmus-go/pkg/types"
)

//PodNetworkCorruptionChaos contains the steps to prepare and inject chaos
// PodNetworkCorruptionChaos contains the steps to prepare and inject chaos
func PodNetworkCorruptionChaos(experimentsDetails *experimentTypes.ExperimentDetails, clients clients.ClientSets, resultDetails *types.ResultDetails, eventsDetails *types.EventDetails, chaosDetails *types.ChaosDetails) error {

args := "corrupt " + experimentsDetails.NetworkPacketCorruptionPercentage
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ import (
"github.com/litmuschaos/litmus-go/pkg/types"
)

//PodNetworkDuplicationChaos contains the steps to prepare and inject chaos
// PodNetworkDuplicationChaos contains the steps to prepare and inject chaos
func PodNetworkDuplicationChaos(experimentsDetails *experimentTypes.ExperimentDetails, clients clients.ClientSets, resultDetails *types.ResultDetails, eventsDetails *types.EventDetails, chaosDetails *types.ChaosDetails) error {

args := "duplicate " + experimentsDetails.NetworkPacketDuplicationPercentage
Expand Down
2 changes: 1 addition & 1 deletion chaoslib/litmus/network-chaos/lib/latency/latency.go
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ import (
"github.com/litmuschaos/litmus-go/pkg/types"
)

//PodNetworkLatencyChaos contains the steps to prepare and inject chaos
// PodNetworkLatencyChaos contains the steps to prepare and inject chaos
func PodNetworkLatencyChaos(experimentsDetails *experimentTypes.ExperimentDetails, clients clients.ClientSets, resultDetails *types.ResultDetails, eventsDetails *types.EventDetails, chaosDetails *types.ChaosDetails) error {

args := "delay " + strconv.Itoa(experimentsDetails.NetworkLatency) + "ms " + strconv.Itoa(experimentsDetails.Jitter) + "ms"
Expand Down
2 changes: 1 addition & 1 deletion chaoslib/litmus/network-chaos/lib/loss/loss.go
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ import (
"github.com/litmuschaos/litmus-go/pkg/types"
)

//PodNetworkLossChaos contains the steps to prepare and inject chaos
// PodNetworkLossChaos contains the steps to prepare and inject chaos
func PodNetworkLossChaos(experimentsDetails *experimentTypes.ExperimentDetails, clients clients.ClientSets, resultDetails *types.ResultDetails, eventsDetails *types.EventDetails, chaosDetails *types.ChaosDetails) error {

args := "loss " + experimentsDetails.NetworkPacketLossPercentage
Expand Down
6 changes: 3 additions & 3 deletions chaoslib/litmus/network-chaos/lib/network-chaos.go
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ var serviceMesh = []string{"istio", "envoy"}
var destIpsSvcMesh string
var destIps string

//PrepareAndInjectChaos contains the preparation & injection steps
// PrepareAndInjectChaos contains the preparation & injection steps
func PrepareAndInjectChaos(experimentsDetails *experimentTypes.ExperimentDetails, clients clients.ClientSets, resultDetails *types.ResultDetails, eventsDetails *types.EventDetails, chaosDetails *types.ChaosDetails, args string) error {

var err error
Expand Down Expand Up @@ -414,8 +414,8 @@ func getIpsForTargetHosts(targetHosts string, clients clients.ClientSets, servic
return strings.Join(commaSeparatedIPs, ","), nil
}

//SetChaosTunables will set up a random value within a given range of values
//If the value is not provided in range it'll set up the initial provided value.
// SetChaosTunables will set up a random value within a given range of values
// If the value is not provided in range it'll set up the initial provided value.
func SetChaosTunables(experimentsDetails *experimentTypes.ExperimentDetails) {
experimentsDetails.NetworkPacketLossPercentage = common.ValidateRange(experimentsDetails.NetworkPacketLossPercentage)
experimentsDetails.NetworkPacketCorruptionPercentage = common.ValidateRange(experimentsDetails.NetworkPacketCorruptionPercentage)
Expand Down
6 changes: 3 additions & 3 deletions chaoslib/litmus/node-cpu-hog/lib/node-cpu-hog.go
Original file line number Diff line number Diff line change
Expand Up @@ -217,7 +217,7 @@ func injectChaosInParallelMode(experimentsDetails *experimentTypes.ExperimentDet
return nil
}

//setCPUCapacity fetch the node cpu capacity
// setCPUCapacity fetch the node cpu capacity
func setCPUCapacity(experimentsDetails *experimentTypes.ExperimentDetails, appNode string, clients clients.ClientSets) error {
node, err := clients.KubeClient.CoreV1().Nodes().Get(context.Background(), appNode, v1.GetOptions{})
if err != nil {
Expand Down Expand Up @@ -278,8 +278,8 @@ func createHelperPod(experimentsDetails *experimentTypes.ExperimentDetails, chao
return nil
}

//setChaosTunables will set up a random value within a given range of values
//If the value is not provided in range it'll set up the initial provided value.
// setChaosTunables will set up a random value within a given range of values
// If the value is not provided in range it'll set up the initial provided value.
func setChaosTunables(experimentsDetails *experimentTypes.ExperimentDetails) {
experimentsDetails.NodeCPUcores = common.ValidateRange(experimentsDetails.NodeCPUcores)
experimentsDetails.CPULoad = common.ValidateRange(experimentsDetails.CPULoad)
Expand Down
2 changes: 1 addition & 1 deletion chaoslib/litmus/node-drain/lib/node-drain.go
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ var (
inject, abort chan os.Signal
)

//PrepareNodeDrain contains the preparation steps before chaos injection
// PrepareNodeDrain contains the preparation steps before chaos injection
func PrepareNodeDrain(experimentsDetails *experimentTypes.ExperimentDetails, clients clients.ClientSets, resultDetails *types.ResultDetails, eventsDetails *types.EventDetails, chaosDetails *types.ChaosDetails) error {

// inject channel is used to transmit signal notifications.
Expand Down
4 changes: 2 additions & 2 deletions chaoslib/litmus/node-io-stress/lib/node-io-stress.go
Original file line number Diff line number Diff line change
Expand Up @@ -287,8 +287,8 @@ func getContainerArguments(experimentsDetails *experimentTypes.ExperimentDetails
return stressArgs
}

//setChaosTunables will set up a random value within a given range of values
//If the value is not provided in range it'll set up the initial provided value.
// setChaosTunables will set up a random value within a given range of values
// If the value is not provided in range it'll set up the initial provided value.
func setChaosTunables(experimentsDetails *experimentTypes.ExperimentDetails) {
experimentsDetails.FilesystemUtilizationBytes = common.ValidateRange(experimentsDetails.FilesystemUtilizationBytes)
experimentsDetails.FilesystemUtilizationPercentage = common.ValidateRange(experimentsDetails.FilesystemUtilizationPercentage)
Expand Down
4 changes: 2 additions & 2 deletions chaoslib/litmus/node-memory-hog/lib/node-memory-hog.go
Original file line number Diff line number Diff line change
Expand Up @@ -362,8 +362,8 @@ func createHelperPod(experimentsDetails *experimentTypes.ExperimentDetails, chao
return nil
}

//setChaosTunables will set up a random value within a given range of values
//If the value is not provided in range it'll set up the initial provided value.
// setChaosTunables will set up a random value within a given range of values
// If the value is not provided in range it'll set up the initial provided value.
func setChaosTunables(experimentsDetails *experimentTypes.ExperimentDetails) {
experimentsDetails.MemoryConsumptionMebibytes = common.ValidateRange(experimentsDetails.MemoryConsumptionMebibytes)
experimentsDetails.MemoryConsumptionPercentage = common.ValidateRange(experimentsDetails.MemoryConsumptionPercentage)
Expand Down
2 changes: 1 addition & 1 deletion chaoslib/litmus/node-taint/lib/node-taint.go
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ var (
inject, abort chan os.Signal
)

//PrepareNodeTaint contains the preparation steps before chaos injection
// PrepareNodeTaint contains the preparation steps before chaos injection
func PrepareNodeTaint(experimentsDetails *experimentTypes.ExperimentDetails, clients clients.ClientSets, resultDetails *types.ResultDetails, eventsDetails *types.EventDetails, chaosDetails *types.ChaosDetails) error {

// inject channel is used to transmit signal notifications.
Expand Down
16 changes: 8 additions & 8 deletions chaoslib/litmus/pod-autoscaler/lib/pod-autoscaler.go
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ var (
appsv1StatefulsetClient appsv1.StatefulSetInterface
)

//PreparePodAutoscaler contains the preparation steps and chaos injection steps
// PreparePodAutoscaler contains the preparation steps and chaos injection steps
func PreparePodAutoscaler(experimentsDetails *experimentTypes.ExperimentDetails, clients clients.ClientSets, resultDetails *types.ResultDetails, eventsDetails *types.EventDetails, chaosDetails *types.ChaosDetails) error {

//Waiting for the ramp time before chaos injection
Expand Down Expand Up @@ -117,7 +117,7 @@ func getSliceOfTotalApplicationsTargeted(appList []experimentTypes.ApplicationUn
return appList[:newAppListLength]
}

//getDeploymentDetails is used to get the name and total number of replicas of the deployment
// getDeploymentDetails is used to get the name and total number of replicas of the deployment
func getDeploymentDetails(experimentsDetails *experimentTypes.ExperimentDetails) ([]experimentTypes.ApplicationUnderTest, error) {

deploymentList, err := appsv1DeploymentClient.List(context.Background(), metav1.ListOptions{LabelSelector: experimentsDetails.AppLabel})
Expand All @@ -135,7 +135,7 @@ func getDeploymentDetails(experimentsDetails *experimentTypes.ExperimentDetails)
return getSliceOfTotalApplicationsTargeted(appsUnderTest, experimentsDetails), nil
}

//getStatefulsetDetails is used to get the name and total number of replicas of the statefulsets
// getStatefulsetDetails is used to get the name and total number of replicas of the statefulsets
func getStatefulsetDetails(experimentsDetails *experimentTypes.ExperimentDetails) ([]experimentTypes.ApplicationUnderTest, error) {

statefulsetList, err := appsv1StatefulsetClient.List(context.Background(), metav1.ListOptions{LabelSelector: experimentsDetails.AppLabel})
Expand All @@ -154,7 +154,7 @@ func getStatefulsetDetails(experimentsDetails *experimentTypes.ExperimentDetails
return getSliceOfTotalApplicationsTargeted(appsUnderTest, experimentsDetails), nil
}

//podAutoscalerChaosInDeployment scales up the replicas of deployment and verify the status
// podAutoscalerChaosInDeployment scales up the replicas of deployment and verify the status
func podAutoscalerChaosInDeployment(experimentsDetails *experimentTypes.ExperimentDetails, clients clients.ClientSets, appsUnderTest []experimentTypes.ApplicationUnderTest, resultDetails *types.ResultDetails, eventsDetails *types.EventDetails, chaosDetails *types.ChaosDetails) error {

// Scale Application
Expand Down Expand Up @@ -185,7 +185,7 @@ func podAutoscalerChaosInDeployment(experimentsDetails *experimentTypes.Experime
return deploymentStatusCheck(experimentsDetails, clients, appsUnderTest, resultDetails, eventsDetails, chaosDetails)
}

//podAutoscalerChaosInStatefulset scales up the replicas of statefulset and verify the status
// podAutoscalerChaosInStatefulset scales up the replicas of statefulset and verify the status
func podAutoscalerChaosInStatefulset(experimentsDetails *experimentTypes.ExperimentDetails, clients clients.ClientSets, appsUnderTest []experimentTypes.ApplicationUnderTest, resultDetails *types.ResultDetails, eventsDetails *types.EventDetails, chaosDetails *types.ChaosDetails) error {

// Scale Application
Expand Down Expand Up @@ -305,7 +305,7 @@ func statefulsetStatusCheck(experimentsDetails *experimentTypes.ExperimentDetail
return nil
}

//autoscalerRecoveryInDeployment rollback the replicas to initial values in deployment
// autoscalerRecoveryInDeployment rollback the replicas to initial values in deployment
func autoscalerRecoveryInDeployment(experimentsDetails *experimentTypes.ExperimentDetails, clients clients.ClientSets, appsUnderTest []experimentTypes.ApplicationUnderTest, chaosDetails *types.ChaosDetails) error {

// Scale back to initial number of replicas
Expand Down Expand Up @@ -351,7 +351,7 @@ func autoscalerRecoveryInDeployment(experimentsDetails *experimentTypes.Experime
})
}

//autoscalerRecoveryInStatefulset rollback the replicas to initial values in deployment
// autoscalerRecoveryInStatefulset rollback the replicas to initial values in deployment
func autoscalerRecoveryInStatefulset(experimentsDetails *experimentTypes.ExperimentDetails, clients clients.ClientSets, appsUnderTest []experimentTypes.ApplicationUnderTest, chaosDetails *types.ChaosDetails) error {

// Scale back to initial number of replicas
Expand Down Expand Up @@ -399,7 +399,7 @@ func autoscalerRecoveryInStatefulset(experimentsDetails *experimentTypes.Experim

func int32Ptr(i int32) *int32 { return &i }

//abortPodAutoScalerChaos go routine will continuously watch for the abort signal for the entire chaos duration and generate the required events and result
// abortPodAutoScalerChaos go routine will continuously watch for the abort signal for the entire chaos duration and generate the required events and result
func abortPodAutoScalerChaos(appsUnderTest []experimentTypes.ApplicationUnderTest, experimentsDetails *experimentTypes.ExperimentDetails, clients clients.ClientSets, resultDetails *types.ResultDetails, eventsDetails *types.EventDetails, chaosDetails *types.ChaosDetails) {

// signChan channel is used to transmit signal notifications.
Expand Down
Loading

0 comments on commit a440615

Please sign in to comment.