**Rancher Server Setup**
- Rancher version: 2.6.5
- Installation option (Docke…r install/Helm Chart): Helm Chart
- If Helm Chart, Kubernetes Cluster and version (RKE1, RKE2, k3s, EKS, etc): Brand new RKE2 cluster (v1.22.9+rke2r2)
- Proxy/Cert Details: Rancher sitting behind NGINX+ reverse proxy, used for inbound connections only, no outbound proxy.
**Information about the Cluster**
- Kubernetes version: v1.22.9+rke2r2
- Cluster Type (Local/Downstream): Downstream
- If downstream, what type of cluster? (Custom/Imported or specify provider for Hosted/Infrastructure Provider): AKS (v1.21.9).
<!--
* Custom = Running a docker command on a node
* Imported = Running kubectl apply onto an existing k8s cluster
* Hosted = EKS, GKE, AKS, etc
* Infrastructure Provider = Rancher provisioning the nodes using different node drivers (e.g. AWS, Digital Ocean, etc)
-->
**User Information**
- What is the role of the user logged in? (Admin/Cluster Owner/Cluster Member/Project Owner/Project Member/Custom): Owner
- If custom, define the set of permissions:
**Describe the bug**
When importing an AKS (v1.21.9) cluster, the aks-config-operator pod goes into CrashLoopBackoff state with the following error:
```
PS C:\Users\egk01> kubectl logs -p -n cattle-system aks-config-operator-67b5b98448-98bsf
Doing /etc/rancher/ssl
W0530 16:00:54.422468 9 loader.go:221] Config not found: /home/aks-operator/.kube/config
time="2022-05-30T16:00:54Z" level=info msg="Starting aks.cattle.io/v1, Kind=AKSClusterConfig controller"
time="2022-05-30T16:00:54Z" level=info msg="Starting /v1, Kind=Secret controller"
time="2022-05-30T16:00:55Z" level=info msg="Checking configuration for cluster [uk1ds-kc-001]"
time="2022-05-30T16:00:55Z" level=info msg="Checking configuration for cluster [uk1d-kc-001]"
E0530 16:00:55.553476 9 runtime.go:78] Observed a panic: runtime.boundsError{x:1, y:0, signed:true, code:0x0} (runtime error: index out of range [1] with length 0)
goroutine 216 [running]:
k8s.io/apimachinery/pkg/util/runtime.logPanic(0x14c27a0, 0xc00022a168)
/go/pkg/mod/k8s.io/apimachinery@v0.21.2/pkg/util/runtime/runtime.go:74 +0x95
k8s.io/apimachinery/pkg/util/runtime.HandleCrash(0x0, 0x0, 0x0)
/go/pkg/mod/k8s.io/apimachinery@v0.21.2/pkg/util/runtime/runtime.go:48 +0x86
panic(0x14c27a0, 0xc00022a168)
/usr/local/go/src/runtime/panic.go:965 +0x1b9
github.com/rancher/aks-operator/controller.BuildUpstreamClusterState(0x1760658, 0xc0008a4d40, 0x17609d8, 0xc000217bc0, 0x7faa033d41a0, 0xc0002261c0, 0xc00048ad70, 0xd18c2e2800, 0x3, 0x6fc23ac00)
/go/src/github.com/rancher/aks-operator/controller/aks-cluster-config-handler.go:674 +0x131f
github.com/rancher/aks-operator/controller.(*Handler).checkAndUpdate(0xc000240400, 0xc00048ac58, 0x0, 0x0, 0x0)
/go/src/github.com/rancher/aks-operator/controller/aks-cluster-config-handler.go:339 +0x55c
github.com/rancher/aks-operator/controller.(*Handler).OnAksConfigChanged(0xc000240400, 0xc00058c0a0, 0x1a, 0xc00048ac58, 0x7faa03445258, 0x1, 0x100000000000028)
/go/src/github.com/rancher/aks-operator/controller/aks-cluster-config-handler.go:121 +0x9d
github.com/rancher/aks-operator/controller.(*Handler).recordError.func1(0xc00058c0a0, 0x1a, 0xc00048ac58, 0xc000294300, 0x21, 0xc000294330)
/go/src/github.com/rancher/aks-operator/controller/aks-cluster-config-handler.go:171 +0x67
github.com/rancher/aks-operator/pkg/generated/controllers/aks.cattle.io/v1.FromAKSClusterConfigHandlerToHandler.func1(0xc00058c0a0, 0x1a, 0x1739d68, 0xc00048ac58, 0xc0006b9c38, 0x41659b, 0xc0006b9c18, 0x4eaeba)
/go/src/github.com/rancher/aks-operator/pkg/generated/controllers/aks.cattle.io/v1/aksclusterconfig.go:105 +0x6b
github.com/rancher/lasso/pkg/controller.SharedControllerHandlerFunc.OnChange(0xc000214920, 0xc00058c0a0, 0x1a, 0x1739d68, 0xc00048ac58, 0x1a, 0x756ea14a212d01, 0x40a43f, 0xc000030000)
/go/pkg/mod/github.com/rancher/lasso@v0.0.0-20210616224652-fc3ebd901c08/pkg/controller/sharedcontroller.go:29 +0x4e
github.com/rancher/lasso/pkg/controller.(*SharedHandler).OnChange(0xc000240380, 0xc00058c0a0, 0x1a, 0x1739d68, 0xc00048ac58, 0xc0004b5c01, 0x0)
/go/pkg/mod/github.com/rancher/lasso@v0.0.0-20210616224652-fc3ebd901c08/pkg/controller/sharedhandler.go:69 +0x14c
github.com/rancher/lasso/pkg/controller.(*controller).syncHandler(0xc000242210, 0xc00058c0a0, 0x1a, 0xc0004b5d38, 0xc0006b9da0)
/go/pkg/mod/github.com/rancher/lasso@v0.0.0-20210616224652-fc3ebd901c08/pkg/controller/controller.go:215 +0xd1
github.com/rancher/lasso/pkg/controller.(*controller).processSingleItem(0xc000242210, 0x13ce1e0, 0xc0004d0e10, 0x0, 0x0)
/go/pkg/mod/github.com/rancher/lasso@v0.0.0-20210616224652-fc3ebd901c08/pkg/controller/controller.go:197 +0xe7
github.com/rancher/lasso/pkg/controller.(*controller).processNextWorkItem(0xc000242210, 0x203000)
/go/pkg/mod/github.com/rancher/lasso@v0.0.0-20210616224652-fc3ebd901c08/pkg/controller/controller.go:174 +0x54
github.com/rancher/lasso/pkg/controller.(*controller).runWorker(...)
/go/pkg/mod/github.com/rancher/lasso@v0.0.0-20210616224652-fc3ebd901c08/pkg/controller/controller.go:163
k8s.io/apimachinery/pkg/util/wait.BackoffUntil.func1(0xc0004d0ea0)
/go/pkg/mod/k8s.io/apimachinery@v0.21.2/pkg/util/wait/wait.go:155 +0x5f
k8s.io/apimachinery/pkg/util/wait.BackoffUntil(0xc0004d0ea0, 0x1734000, 0xc000561bf0, 0xc0004d0e01, 0xc0002486c0)
/go/pkg/mod/k8s.io/apimachinery@v0.21.2/pkg/util/wait/wait.go:156 +0x9b
k8s.io/apimachinery/pkg/util/wait.JitterUntil(0xc0004d0ea0, 0x3b9aca00, 0x0, 0x1, 0xc0002486c0)
/go/pkg/mod/k8s.io/apimachinery@v0.21.2/pkg/util/wait/wait.go:133 +0x98
k8s.io/apimachinery/pkg/util/wait.Until(0xc0004d0ea0, 0x3b9aca00, 0xc0002486c0)
/go/pkg/mod/k8s.io/apimachinery@v0.21.2/pkg/util/wait/wait.go:90 +0x4d
created by github.com/rancher/lasso/pkg/controller.(*controller).run
/go/pkg/mod/github.com/rancher/lasso@v0.0.0-20210616224652-fc3ebd901c08/pkg/controller/controller.go:134 +0x33b
panic: runtime error: index out of range [1] with length 0 [recovered]
panic: runtime error: index out of range [1] with length 0
goroutine 216 [running]:
k8s.io/apimachinery/pkg/util/runtime.HandleCrash(0x0, 0x0, 0x0)
/go/pkg/mod/k8s.io/apimachinery@v0.21.2/pkg/util/runtime/runtime.go:55 +0x109
panic(0x14c27a0, 0xc00022a168)
/usr/local/go/src/runtime/panic.go:965 +0x1b9
github.com/rancher/aks-operator/controller.BuildUpstreamClusterState(0x1760658, 0xc0008a4d40, 0x17609d8, 0xc000217bc0, 0x7faa033d41a0, 0xc0002261c0, 0xc00048ad70, 0xd18c2e2800, 0x3, 0x6fc23ac00)
/go/src/github.com/rancher/aks-operator/controller/aks-cluster-config-handler.go:674 +0x131f
github.com/rancher/aks-operator/controller.(*Handler).checkAndUpdate(0xc000240400, 0xc00048ac58, 0x0, 0x0, 0x0)
/go/src/github.com/rancher/aks-operator/controller/aks-cluster-config-handler.go:339 +0x55c
github.com/rancher/aks-operator/controller.(*Handler).OnAksConfigChanged(0xc000240400, 0xc00058c0a0, 0x1a, 0xc00048ac58, 0x7faa03445258, 0x1, 0x100000000000028)
/go/src/github.com/rancher/aks-operator/controller/aks-cluster-config-handler.go:121 +0x9d
github.com/rancher/aks-operator/controller.(*Handler).recordError.func1(0xc00058c0a0, 0x1a, 0xc00048ac58, 0xc000294300, 0x21, 0xc000294330)
/go/src/github.com/rancher/aks-operator/controller/aks-cluster-config-handler.go:171 +0x67
github.com/rancher/aks-operator/pkg/generated/controllers/aks.cattle.io/v1.FromAKSClusterConfigHandlerToHandler.func1(0xc00058c0a0, 0x1a, 0x1739d68, 0xc00048ac58, 0xc0006b9c38, 0x41659b, 0xc0006b9c18, 0x4eaeba)
/go/src/github.com/rancher/aks-operator/pkg/generated/controllers/aks.cattle.io/v1/aksclusterconfig.go:105 +0x6b
github.com/rancher/lasso/pkg/controller.SharedControllerHandlerFunc.OnChange(0xc000214920, 0xc00058c0a0, 0x1a, 0x1739d68, 0xc00048ac58, 0x1a, 0x756ea14a212d01, 0x40a43f, 0xc000030000)
/go/pkg/mod/github.com/rancher/lasso@v0.0.0-20210616224652-fc3ebd901c08/pkg/controller/sharedcontroller.go:29 +0x4e
github.com/rancher/lasso/pkg/controller.(*SharedHandler).OnChange(0xc000240380, 0xc00058c0a0, 0x1a, 0x1739d68, 0xc00048ac58, 0xc0004b5c01, 0x0)
/go/pkg/mod/github.com/rancher/lasso@v0.0.0-20210616224652-fc3ebd901c08/pkg/controller/sharedhandler.go:69 +0x14c
github.com/rancher/lasso/pkg/controller.(*controller).syncHandler(0xc000242210, 0xc00058c0a0, 0x1a, 0xc0004b5d38, 0xc0006b9da0)
/go/pkg/mod/github.com/rancher/lasso@v0.0.0-20210616224652-fc3ebd901c08/pkg/controller/controller.go:215 +0xd1
github.com/rancher/lasso/pkg/controller.(*controller).processSingleItem(0xc000242210, 0x13ce1e0, 0xc0004d0e10, 0x0, 0x0)
/go/pkg/mod/github.com/rancher/lasso@v0.0.0-20210616224652-fc3ebd901c08/pkg/controller/controller.go:197 +0xe7
github.com/rancher/lasso/pkg/controller.(*controller).processNextWorkItem(0xc000242210, 0x203000)
/go/pkg/mod/github.com/rancher/lasso@v0.0.0-20210616224652-fc3ebd901c08/pkg/controller/controller.go:174 +0x54
github.com/rancher/lasso/pkg/controller.(*controller).runWorker(...)
/go/pkg/mod/github.com/rancher/lasso@v0.0.0-20210616224652-fc3ebd901c08/pkg/controller/controller.go:163
k8s.io/apimachinery/pkg/util/wait.BackoffUntil.func1(0xc0004d0ea0)
/go/pkg/mod/k8s.io/apimachinery@v0.21.2/pkg/util/wait/wait.go:155 +0x5f
k8s.io/apimachinery/pkg/util/wait.BackoffUntil(0xc0004d0ea0, 0x1734000, 0xc000561bf0, 0xc0004d0e01, 0xc0002486c0)
/go/pkg/mod/k8s.io/apimachinery@v0.21.2/pkg/util/wait/wait.go:156 +0x9b
k8s.io/apimachinery/pkg/util/wait.JitterUntil(0xc0004d0ea0, 0x3b9aca00, 0x0, 0x1, 0xc0002486c0)
/go/pkg/mod/k8s.io/apimachinery@v0.21.2/pkg/util/wait/wait.go:133 +0x98
k8s.io/apimachinery/pkg/util/wait.Until(0xc0004d0ea0, 0x3b9aca00, 0xc0002486c0)
/go/pkg/mod/k8s.io/apimachinery@v0.21.2/pkg/util/wait/wait.go:90 +0x4d
created by github.com/rancher/lasso/pkg/controller.(*controller).run
/go/pkg/mod/github.com/rancher/lasso@v0.0.0-20210616224652-fc3ebd901c08/pkg/controller/controller.go:134 +0x33b
```
In this error, "uk1ds-kc-001" is a cluster which has already been successfully imported, and "uk1d-kc-001" is a the cluster which I am attempting to import.
At the same time, the rancher pods continually crash with the same error (with a bit more preceding detail):
```
2022/05/30 16:00:10 [INFO] [mgmt-cluster-rbac-delete] Creating namespace c-t89dk
2022/05/30 16:00:10 [INFO] [mgmt-cluster-rbac-delete] Creating Default project for cluster c-t89dk
2022/05/30 16:00:10 [INFO] [mgmt-project-rbac-create] Creating namespace p-z8w8t
2022/05/30 16:00:10 [ERROR] defaultSvcAccountHandler: Sync: error handling default ServiceAccount of namespace key=c-t89dk, err=Operation cannot be fulfilled on namespaces "c-t89dk": the object has been modified; please apply your changes to the latest version and try again
2022/05/30 16:00:10 [INFO] [mgmt-cluster-rbac-delete] Creating System project for cluster c-t89dk
2022/05/30 16:00:10 [INFO] [mgmt-project-rbac-create] Creating namespace p-gccb2
2022/05/30 16:00:10 [INFO] [mgmt-project-rbac-create] Creating creator projectRoleTemplateBinding for user user-t6wbb for project p-z8w8t
2022/05/30 16:00:10 [INFO] [mgmt-cluster-rbac-delete] Updating cluster c-t89dk
2022/05/30 16:00:10 [ERROR] defaultSvcAccountHandler: Sync: error handling default ServiceAccount of namespace key=c-t89dk, err=Operation cannot be fulfilled on namespaces "c-t89dk": the object has been modified; please apply your changes to the latest version and try again
2022/05/30 16:00:11 [INFO] [mgmt-project-rbac-create] Creating creator projectRoleTemplateBinding for user user-t6wbb for project p-gccb2
2022/05/30 16:00:11 [INFO] [mgmt-project-rbac-create] Creating creator clusterRoleTemplateBinding for user user-t6wbb for cluster c-t89dk
2022/05/30 16:00:11 [INFO] [mgmt-auth-crtb-controller] Setting InitialRolesPopulated condition on project p-z8w8t
2022/05/30 16:00:11 [INFO] [mgmt-auth-prtb-controller] Creating role/clusterRole p-z8w8t-projectowner
2022/05/30 16:00:11 [INFO] [mgmt-auth-crtb-controller] Setting InitialRolesPopulated condition on project p-gccb2
2022/05/30 16:00:11 [INFO] [mgmt-project-rbac-create] Updating project p-z8w8t
2022/05/30 16:00:11 [INFO] [mgmt-auth-crtb-controller] Creating role/clusterRole c-t89dk-clusterowner
2022/05/30 16:00:11 [INFO] [mgmt-auth-prtb-controller] Creating roleBinding for membership in project p-z8w8t for subject user-t6wbb
2022/05/30 16:00:11 [INFO] [mgmt-project-rbac-create] Updating project p-gccb2
2022/05/30 16:00:11 [INFO] [mgmt-auth-prtb-controller] Creating role/clusterRole p-gccb2-projectowner
2022/05/30 16:00:11 [INFO] [mgmt-auth-crtb-controller] Creating clusterRoleBinding for membership in cluster c-t89dk for subject user-t6wbb
2022/05/30 16:00:11 [INFO] [mgmt-auth-prtb-controller] Creating role/clusterRole c-t89dk-clustermember
2022/05/30 16:00:11 [INFO] [mgmt-auth-prtb-controller] Creating roleBinding for membership in project p-gccb2 for subject user-t6wbb
2022/05/30 16:00:11 [INFO] [mgmt-auth-prtb-controller] Creating clusterRoleBinding for membership in cluster c-t89dk for subject user-t6wbb
2022/05/30 16:00:11 [INFO] [mgmt-project-rbac-create] Updating project p-z8w8t
2022/05/30 16:00:11 [INFO] [mgmt-auth-crtb-controller] Creating role cluster-owner in namespace c-t89dk
2022/05/30 16:00:11 [INFO] [mgmt-auth-crtb-controller] Setting InitialRolesPopulated condition on cluster
2022/05/30 16:00:11 [INFO] [mgmt-cluster-rbac-delete] Updating cluster c-t89dk
2022/05/30 16:00:11 [ERROR] defaultSvcAccountHandler: Sync: error handling default ServiceAccount of namespace key=p-z8w8t, err=Operation cannot be fulfilled on namespaces "p-z8w8t": the object has been modified; please apply your changes to the latest version and try again
2022/05/30 16:00:11 [INFO] [mgmt-auth-prtb-controller] Creating role project-owner in namespace c-t89dk
2022/05/30 16:00:11 [INFO] [mgmt-auth-crtb-controller] Creating roleBinding for subject user-t6wbb with role cluster-owner in namespace c-t89dk
2022/05/30 16:00:11 [INFO] [mgmt-auth-prtb-controller] Creating roleBinding for subject user-t6wbb with role project-owner in namespace c-t89dk
2022/05/30 16:00:11 [INFO] [mgmt-project-rbac-create] Updating project p-gccb2
2022/05/30 16:00:11 [INFO] [mgmt-auth-crtb-controller] Creating role cluster-owner in namespace p-z8w8t
2022/05/30 16:00:11 [INFO] [mgmt-auth-prtb-controller] Updating clusterRoleBinding crb-7yl3oxhpng for cluster membership in cluster c-t89dk for subject user-t6wbb
2022/05/30 16:00:11 [INFO] [mgmt-auth-prtb-controller] Creating role project-owner in namespace p-z8w8t
2022/05/30 16:00:11 [ERROR] defaultSvcAccountHandler: Sync: error handling default ServiceAccount of namespace key=p-gccb2, err=Operation cannot be fulfilled on namespaces "p-gccb2": the object has been modified; please apply your changes to the latest version and try again
2022/05/30 16:00:11 [INFO] [mgmt-auth-crtb-controller] Creating roleBinding for subject user-t6wbb with role cluster-owner in namespace p-z8w8t
2022/05/30 16:00:11 [ERROR] defaultSvcAccountHandler: Sync: error handling default ServiceAccount of namespace key=p-z8w8t, err=Operation cannot be fulfilled on namespaces "p-z8w8t": the object has been modified; please apply your changes to the latest version and try again
2022/05/30 16:00:11 [INFO] [mgmt-auth-prtb-controller] Creating roleBinding for subject user-t6wbb with role project-owner in namespace c-t89dk
2022/05/30 16:00:11 [INFO] [mgmt-auth-crtb-controller] Creating role cluster-owner in namespace p-gccb2
2022/05/30 16:00:11 [INFO] [mgmt-auth-prtb-controller] Creating role project-owner in namespace p-gccb2
2022/05/30 16:00:11 [INFO] [mgmt-auth-prtb-controller] Creating role admin in namespace p-z8w8t
2022/05/30 16:00:11 [INFO] [mgmt-auth-crtb-controller] Creating roleBinding for subject user-t6wbb with role cluster-owner in namespace p-gccb2
2022/05/30 16:00:11 [INFO] [mgmt-auth-prtb-controller] Creating roleBinding for subject user-t6wbb with role project-owner in namespace p-z8w8t
2022/05/30 16:00:11 [INFO] [mgmt-auth-prtb-controller] Creating role admin in namespace p-gccb2
2022/05/30 16:00:11 [INFO] [mgmt-auth-prtb-controller] Creating roleBinding for subject user-t6wbb with role admin in namespace p-z8w8t
2022/05/30 16:00:11 [INFO] [mgmt-auth-prtb-controller] Creating roleBinding for subject user-t6wbb with role project-owner in namespace p-gccb2
2022/05/30 16:00:11 [INFO] [mgmt-auth-prtb-controller] Creating roleBinding for subject user-t6wbb with role admin in namespace p-gccb2
2022/05/30 16:00:11 [INFO] [mgmt-cluster-rbac-delete] Updating cluster c-t89dk
2022/05/30 16:00:11 [INFO] waiting for cluster import [c-t89dk] to start
2022/05/30 16:00:11 [INFO] waiting for cluster import [c-t89dk] to start
2022/05/30 16:00:11 [INFO] waiting for cluster import [c-t89dk] to start
2022/05/30 16:00:11 [INFO] waiting for cluster import [c-t89dk] to start
2022/05/30 16:00:11 [INFO] waiting for cluster import [c-t89dk] to start
2022/05/30 16:00:11 [INFO] waiting for cluster import [c-t89dk] to start
2022/05/30 16:00:13 [INFO] setting initial upstreamSpec on cluster [c-t89dk]
E0530 16:00:14.107171 33 runtime.go:78] Observed a panic: runtime.boundsError{x:1, y:0, signed:true, code:0x0} (runtime error: index out of range [1] with length 0)
goroutine 2809 [running]:
k8s.io/apimachinery/pkg/util/runtime.logPanic({0x3cf6500, 0xc00c10af78})
/go/pkg/mod/k8s.io/apimachinery@v0.23.3/pkg/util/runtime/runtime.go:74 +0x7d
k8s.io/apimachinery/pkg/util/runtime.HandleCrash({0x0, 0x0, 0xc001f1a1d0})
/go/pkg/mod/k8s.io/apimachinery@v0.23.3/pkg/util/runtime/runtime.go:48 +0x75
panic({0x3cf6500, 0xc00c10af78})
/usr/lib64/go/1.17/src/runtime/panic.go:1038 +0x215
github.com/rancher/aks-operator/controller.BuildUpstreamClusterState({0x47f9dd0, 0xc000084048}, {0x47fc220, 0xc00747db00}, {0x7f031d6bafc0, 0xc0011de930}, 0xc00e452b40)
/go/pkg/mod/github.com/rancher/aks-operator@v1.0.5/controller/aks-cluster-config-handler.go:674 +0xa97
github.com/rancher/rancher/pkg/controllers/management/clusterupstreamrefresher.BuildAKSUpstreamSpec({0x47fc220, 0xc00747db00}, {0x7f031d6bafc0, 0xc0011de930}, 0xc00e455000)
/go/src/github.com/rancher/rancher/pkg/controllers/management/clusterupstreamrefresher/aks_upstream_spec.go:14 +0x65
github.com/rancher/rancher/pkg/controllers/management/aks.(*aksOperatorController).setInitialUpstreamSpec(0xc004874dd0, 0xc00e455000)
/go/src/github.com/rancher/rancher/pkg/controllers/management/aks/aks_cluster_handler.go:269 +0x9f
github.com/rancher/rancher/pkg/controllers/management/aks.(*aksOperatorController).onClusterChange(0xc004874dd0, {0xc00e4afb68, 0x40b2d4}, 0x3e41980)
/go/src/github.com/rancher/rancher/pkg/controllers/management/aks/aks_cluster_handler.go:154 +0x738
github.com/rancher/rancher/pkg/generated/controllers/management.cattle.io/v3.FromClusterHandlerToHandler.func1({0xc00bcfc600, 0x18e93bc5b778}, {0x47b41b0, 0xc00e455000})
/go/src/github.com/rancher/rancher/pkg/generated/controllers/management.cattle.io/v3/cluster.go:105 +0x44
github.com/rancher/lasso/pkg/controller.SharedControllerHandlerFunc.OnChange(0xc00e455000, {0xc00bcfc600, 0x4015ceb}, {0x47b41b0, 0xc00e455000})
/go/pkg/mod/github.com/rancher/lasso@v0.0.0-20220412224715-5f3517291ad4/pkg/controller/sharedcontroller.go:29 +0x38
github.com/rancher/lasso/pkg/controller.(*SharedHandler).OnChange(0xc0008ba780, {0xc00bcfc600, 0x7}, {0x47b41b0, 0xc00af29000})
/go/pkg/mod/github.com/rancher/lasso@v0.0.0-20220412224715-5f3517291ad4/pkg/controller/sharedhandler.go:75 +0x23f
github.com/rancher/lasso/pkg/controller.(*controller).syncHandler(0xc000bfd3f0, {0xc00bcfc600, 0x7})
/go/pkg/mod/github.com/rancher/lasso@v0.0.0-20220412224715-5f3517291ad4/pkg/controller/controller.go:220 +0x93
github.com/rancher/lasso/pkg/controller.(*controller).processSingleItem(0xc000bfd3f0, {0x35bd920, 0xc001f1a1d0})
/go/pkg/mod/github.com/rancher/lasso@v0.0.0-20220412224715-5f3517291ad4/pkg/controller/controller.go:201 +0x10e
github.com/rancher/lasso/pkg/controller.(*controller).processNextWorkItem(0xc000bfd3f0)
/go/pkg/mod/github.com/rancher/lasso@v0.0.0-20220412224715-5f3517291ad4/pkg/controller/controller.go:178 +0x46
github.com/rancher/lasso/pkg/controller.(*controller).runWorker(...)
/go/pkg/mod/github.com/rancher/lasso@v0.0.0-20220412224715-5f3517291ad4/pkg/controller/controller.go:167
k8s.io/apimachinery/pkg/util/wait.BackoffUntil.func1(0x7f031d6d4050)
/go/pkg/mod/k8s.io/apimachinery@v0.23.3/pkg/util/wait/wait.go:155 +0x67
k8s.io/apimachinery/pkg/util/wait.BackoffUntil(0x0, {0x47886e0, 0xc003bb30b0}, 0x1, 0xc0018b6fc0)
/go/pkg/mod/k8s.io/apimachinery@v0.23.3/pkg/util/wait/wait.go:156 +0xb6
k8s.io/apimachinery/pkg/util/wait.JitterUntil(0x8, 0x3b9aca00, 0x0, 0x0, 0x0)
/go/pkg/mod/k8s.io/apimachinery@v0.23.3/pkg/util/wait/wait.go:133 +0x89
k8s.io/apimachinery/pkg/util/wait.Until(0x7, 0x0, 0x0)
/go/pkg/mod/k8s.io/apimachinery@v0.23.3/pkg/util/wait/wait.go:90 +0x25
created by github.com/rancher/lasso/pkg/controller.(*controller).run
/go/pkg/mod/github.com/rancher/lasso@v0.0.0-20220412224715-5f3517291ad4/pkg/controller/controller.go:135 +0x2c6
panic: runtime error: index out of range [1] with length 0 [recovered]
panic: runtime error: index out of range [1] with length 0
goroutine 2809 [running]:
k8s.io/apimachinery/pkg/util/runtime.HandleCrash({0x0, 0x0, 0xc001f1a1d0})
/go/pkg/mod/k8s.io/apimachinery@v0.23.3/pkg/util/runtime/runtime.go:55 +0xd8
panic({0x3cf6500, 0xc00c10af78})
/usr/lib64/go/1.17/src/runtime/panic.go:1038 +0x215
github.com/rancher/aks-operator/controller.BuildUpstreamClusterState({0x47f9dd0, 0xc000084048}, {0x47fc220, 0xc00747db00}, {0x7f031d6bafc0, 0xc0011de930}, 0xc00e452b40)
/go/pkg/mod/github.com/rancher/aks-operator@v1.0.5/controller/aks-cluster-config-handler.go:674 +0xa97
github.com/rancher/rancher/pkg/controllers/management/clusterupstreamrefresher.BuildAKSUpstreamSpec({0x47fc220, 0xc00747db00}, {0x7f031d6bafc0, 0xc0011de930}, 0xc00e455000)
/go/src/github.com/rancher/rancher/pkg/controllers/management/clusterupstreamrefresher/aks_upstream_spec.go:14 +0x65
github.com/rancher/rancher/pkg/controllers/management/aks.(*aksOperatorController).setInitialUpstreamSpec(0xc004874dd0, 0xc00e455000)
/go/src/github.com/rancher/rancher/pkg/controllers/management/aks/aks_cluster_handler.go:269 +0x9f
github.com/rancher/rancher/pkg/controllers/management/aks.(*aksOperatorController).onClusterChange(0xc004874dd0, {0xc00e4afb68, 0x40b2d4}, 0x3e41980)
/go/src/github.com/rancher/rancher/pkg/controllers/management/aks/aks_cluster_handler.go:154 +0x738
github.com/rancher/rancher/pkg/generated/controllers/management.cattle.io/v3.FromClusterHandlerToHandler.func1({0xc00bcfc600, 0x18e93bc5b778}, {0x47b41b0, 0xc00e455000})
/go/src/github.com/rancher/rancher/pkg/generated/controllers/management.cattle.io/v3/cluster.go:105 +0x44
github.com/rancher/lasso/pkg/controller.SharedControllerHandlerFunc.OnChange(0xc00e455000, {0xc00bcfc600, 0x4015ceb}, {0x47b41b0, 0xc00e455000})
/go/pkg/mod/github.com/rancher/lasso@v0.0.0-20220412224715-5f3517291ad4/pkg/controller/sharedcontroller.go:29 +0x38
github.com/rancher/lasso/pkg/controller.(*SharedHandler).OnChange(0xc0008ba780, {0xc00bcfc600, 0x7}, {0x47b41b0, 0xc00af29000})
/go/pkg/mod/github.com/rancher/lasso@v0.0.0-20220412224715-5f3517291ad4/pkg/controller/sharedhandler.go:75 +0x23f
github.com/rancher/lasso/pkg/controller.(*controller).syncHandler(0xc000bfd3f0, {0xc00bcfc600, 0x7})
/go/pkg/mod/github.com/rancher/lasso@v0.0.0-20220412224715-5f3517291ad4/pkg/controller/controller.go:220 +0x93
github.com/rancher/lasso/pkg/controller.(*controller).processSingleItem(0xc000bfd3f0, {0x35bd920, 0xc001f1a1d0})
/go/pkg/mod/github.com/rancher/lasso@v0.0.0-20220412224715-5f3517291ad4/pkg/controller/controller.go:201 +0x10e
github.com/rancher/lasso/pkg/controller.(*controller).processNextWorkItem(0xc000bfd3f0)
/go/pkg/mod/github.com/rancher/lasso@v0.0.0-20220412224715-5f3517291ad4/pkg/controller/controller.go:178 +0x46
github.com/rancher/lasso/pkg/controller.(*controller).runWorker(...)
/go/pkg/mod/github.com/rancher/lasso@v0.0.0-20220412224715-5f3517291ad4/pkg/controller/controller.go:167
k8s.io/apimachinery/pkg/util/wait.BackoffUntil.func1(0x7f031d6d4050)
/go/pkg/mod/k8s.io/apimachinery@v0.23.3/pkg/util/wait/wait.go:155 +0x67
k8s.io/apimachinery/pkg/util/wait.BackoffUntil(0x0, {0x47886e0, 0xc003bb30b0}, 0x1, 0xc0018b6fc0)
/go/pkg/mod/k8s.io/apimachinery@v0.23.3/pkg/util/wait/wait.go:156 +0xb6
k8s.io/apimachinery/pkg/util/wait.JitterUntil(0x8, 0x3b9aca00, 0x0, 0x0, 0x0)
/go/pkg/mod/k8s.io/apimachinery@v0.23.3/pkg/util/wait/wait.go:133 +0x89
k8s.io/apimachinery/pkg/util/wait.Until(0x7, 0x0, 0x0)
/go/pkg/mod/k8s.io/apimachinery@v0.23.3/pkg/util/wait/wait.go:90 +0x25
created by github.com/rancher/lasso/pkg/controller.(*controller).run
/go/pkg/mod/github.com/rancher/lasso@v0.0.0-20220412224715-5f3517291ad4/pkg/controller/controller.go:135 +0x2c6
```
Before first discovered, I left this import running overnight and when I came back in the morning Rancher was completely unavailable as all pods were unavailable.
I have completely rebuilt Rancher on a new RKE2 cluster (previously discovered on a RKE v1 cluster) but this still remains. As far as I am aware, the AKS clusters were built in the exact same way.
**To Reproduce**
**This is not easily reproducible, the resource group our service principal has permissions on contains 2 AKS clusters, one imports successfully and the other does not**.
* In Azure, create a service principal and give "Contributor" role to resource group containing relevant AKS cluster.
* Navigate to Cluster Management -> Import Existing.
* Select "Azure AKS" and give the cluster a name.
* Select the credentials in the "Cloud Credentials" drop-down then click Next.
* Select the cluster from the "Cluster to register" drop-down, then click "Register Cluster".
**Result**
aks-config-operator and rancher pods continually crash and the cluster fails to import.
**Expected Result**
The cluster is imported and becomes visible in the "Cluster Management" section of Rancher, with all Rancher features available.
**Screenshots**
N/A, logs should be sufficient.
**Additional context**
None that I can think of which would be relevant.