diff --git a/litmus-portal/cluster-agents/subscriber/pkg/k8s/operations.go b/litmus-portal/cluster-agents/subscriber/pkg/k8s/operations.go index 96d91fda88e..39dfdd4a6ee 100644 --- a/litmus-portal/cluster-agents/subscriber/pkg/k8s/operations.go +++ b/litmus-portal/cluster-agents/subscriber/pkg/k8s/operations.go @@ -31,7 +31,7 @@ var ( ) // IsClusterConfirmed checks if the config map with "is_cluster_confirmed" is true or not. -func IsClusterConfirmed(clusterData map[string]string) (bool, string, error) { +func IsClusterConfirmed() (bool, string, error) { clientset, err := GetGenericK8sClient() if err != nil { return false, "", err @@ -75,7 +75,7 @@ func ClusterRegister(clusterData map[string]string) (bool, error) { _, err = clientset.CoreV1().ConfigMaps(AgentNamespace).Create(&newConfigMap) if err != nil { - return false, nil + return false, err } log.Println("Configmap created") diff --git a/litmus-portal/cluster-agents/subscriber/subscriber.go b/litmus-portal/cluster-agents/subscriber/subscriber.go index f2258ece304..a428f5283c6 100644 --- a/litmus-portal/cluster-agents/subscriber/subscriber.go +++ b/litmus-portal/cluster-agents/subscriber/subscriber.go @@ -29,8 +29,7 @@ func init() { k8s.KubeConfig = flag.String("kubeconfig", "", "absolute path to the kubeconfig file") flag.Parse() - var isConfirmed bool - isConfirmed, newKey, err = k8s.IsClusterConfirmed(clusterData) + isConfirmed, newKey, err := k8s.IsClusterConfirmed() if err != nil { log.Fatal(err) } @@ -51,9 +50,12 @@ func init() { } if responseInterface.Data.ClusterConfirm.IsClusterConfirmed == true { - log.Println("cluster confirmed") clusterData["KEY"] = responseInterface.Data.ClusterConfirm.NewClusterKey - k8s.ClusterRegister(clusterData) + _, err = k8s.ClusterRegister(clusterData) + if err != nil { + log.Fatal(err) + } + log.Println("cluster confirmed") } else { log.Fatal("Cluster not confirmed") } diff --git a/litmus-portal/graphql-server/manifests/cluster-subscriber.yml b/litmus-portal/graphql-server/manifests/cluster-subscriber.yml index e49fffef875..570389d211b 100644 --- a/litmus-portal/graphql-server/manifests/cluster-subscriber.yml +++ b/litmus-portal/graphql-server/manifests/cluster-subscriber.yml @@ -1039,6 +1039,7 @@ metadata: name: argo-chaos namespace: #{AGENT-NAMESPACE} --- +--- apiVersion: rbac.authorization.k8s.io/v1 kind: ClusterRole metadata: @@ -1084,6 +1085,7 @@ rules: - configmaps verbs: - get + - create - apiGroups: - litmuschaos.io resources: diff --git a/litmus-portal/graphql-server/manifests/namespace-subscriber.yml b/litmus-portal/graphql-server/manifests/namespace-subscriber.yml index 4314dd25bc2..bef5de57624 100644 --- a/litmus-portal/graphql-server/manifests/namespace-subscriber.yml +++ b/litmus-portal/graphql-server/manifests/namespace-subscriber.yml @@ -407,6 +407,7 @@ rules: - configmaps verbs: - get + - create - apiGroups: - litmuschaos.io resources: