kubernetes / kops

Kubernetes Operations (kOps) - Production Grade k8s Installation, Upgrades and Management
https://kops.sigs.k8s.io/
Apache License 2.0
15.97k stars 4.65k forks source link

kops toolbox instance-selector command bug: panic: interface conversion: interface {} is *string, not string #16775

Closed opeoniye closed 2 months ago

opeoniye commented 2 months ago

/kind bug

1. What kops version are you running? The command kops version, will display this information. Client version: 1.30.0

2. What Kubernetes version are you running? kubectl version will print the version if a cluster is running or provide the Kubernetes version specified as a kops flag. Server Version: v1.30.2

3. What cloud provider are you using? Cloud: AWS

4. What commands did you run? What is the simplest way to reproduce this issue? AWS_PROFILE= kops toolbox instance-selector my-spot-mig --usage-class spot --flexible --dry-run -v 10

5. What happened after the commands executed? I got the following error:

panic: interface conversion: interface {} is *string, not string

goroutine 1 [running]:
main.getFilters(_, {_, _}, {_, _, _})
        k8s.io/kops/cmd/kops/toolbox_instance-selector.go:401 +0x685
main.RunToolboxInstanceSelector({0x113f1c018, 0xc0005a7140}, {0x113ec0100?, 0xc000b7a300?}, {0x113eab4b8, 0xc00012a020}, 0xc000b65080, 0xc000980380)
        k8s.io/kops/cmd/kops/toolbox_instance-selector.go:279 +0x827
main.NewCmdToolboxInstanceSelector.func3(0xc000191a00?, {0xc0009804d0?, 0x1?, 0x11142d4ae?})
        k8s.io/kops/cmd/kops/toolbox_instance-selector.go:154 +0x3c
github.com/spf13/cobra.(*Command).execute(0xc000f95b08, {0xc000980460, 0x7, 0x7})
        github.com/spf13/cobra@v1.8.1/command.go:985 +0xaca
github.com/spf13/cobra.(*Command).ExecuteC(0x1172c1f60)
        github.com/spf13/cobra@v1.8.1/command.go:1117 +0x3ff
github.com/spf13/cobra.(*Command).Execute(...)
        github.com/spf13/cobra@v1.8.1/command.go:1041
github.com/spf13/cobra.(*Command).ExecuteContext(...)
        github.com/spf13/cobra@v1.8.1/command.go:1034
main.Execute({0x113f1bf70, 0x117420e88})
        k8s.io/kops/cmd/kops/root.go:100 +0x374
main.run({0x113f1bf70, 0x117420e88})
        k8s.io/kops/cmd/kops/main.go:55 +0x165
main.main()
        k8s.io/kops/cmd/kops/main.go:29 +0x25

6. What did you expect to happen? I expect it to generate AWS EC2 instance groups with spot workers

7. Please provide your cluster manifest. Execute kops get --name my.example.com -o yaml to display your cluster manifest. You may want to remove your cluster name and other sensitive information.

apiVersion: kops.k8s.io/v1alpha2
kind: Cluster
metadata:
  creationTimestamp: "2024-08-25T08:48:21Z"
  name: <name>.k8s.local
spec:
  api:
    loadBalancer:
      class: Network
      type: Public
  authorization:
    rbac: {}
  channel: stable
  cloudProvider: aws
  configBase: s3://${BSS}/<name>.k8s.local
  etcdClusters:
  - cpuRequest: 200m
    etcdMembers:
    - encryptedVolume: true
      instanceGroup: control-plane-us-east-1a
      name: a
    manager:
      backupRetentionDays: 90
    memoryRequest: 100Mi
    name: main
  - cpuRequest: 100m
    etcdMembers:
    - encryptedVolume: true
      instanceGroup: control-plane-us-east-1a
      name: a
    manager:
      backupRetentionDays: 90
    memoryRequest: 100Mi
    name: events
  iam:
    allowContainerRegistry: true
    legacy: false
    useServiceAccountExternalPermissions: true
  kubeProxy:
    enabled: false
  kubelet:
    anonymousAuth: false
  kubernetesApiAccess:
  - 0.0.0.0/0
  - ::/0
  kubernetesVersion: 1.30.2
  networkCIDR: 172.20.0.0/16
  networking:
    cilium:
      enableNodePort: true
  nonMasqueradeCIDR: 100.64.0.0/10
  serviceAccountIssuerDiscovery:
    discoveryStore: s3://${BOS}/<name>.k8s.local/discovery/<name>.k8s.local
    enableAWSOIDCProvider: true
  sshAccess:
  - 0.0.0.0/0
  - ::/0
  subnets:
  - cidr: 172.20.0.0/16
    name: us-east-1a
    type: Public
    zone: us-east-1a
  topology:
    dns:
      type: None

---

apiVersion: kops.k8s.io/v1alpha2
kind: InstanceGroup
metadata:
  creationTimestamp: "2024-08-25T08:48:22Z"
  labels:
    kops.k8s.io/cluster: <name>.k8s.local
  name: control-plane-us-east-1a
spec:
  image: 099720109477/ubuntu/images/hvm-ssd/ubuntu-jammy-22.04-amd64-server-20240607
  machineType: t3.medium
  maxSize: 1
  minSize: 1
  role: Master
  subnets:
  - us-east-1a

---

apiVersion: kops.k8s.io/v1alpha2
kind: InstanceGroup
metadata:
  creationTimestamp: "2024-08-25T08:48:22Z"
  labels:
    kops.k8s.io/cluster: <name>.k8s.local
  name: nodes-us-east-1a
spec:
  image: 099720109477/ubuntu/images/hvm-ssd/ubuntu-jammy-22.04-amd64-server-20240607
  machineType: t3.medium
  maxSize: 1
  minSize: 1
  nodeLabels:
    kops.k8s.io/lifecycle: OnDemand
  role: Node
  subnets:
  - us-east-1a

8. Please run the commands with most verbose logging by adding the -v 10 flag. Paste the logs into this report, or in a gist and provide the gist link here.

I0825 17:20:54.065175   24651 factory.go:82] state store s3://${BSS}
I0825 17:20:54.066755   24651 s3context.go:362] GOOS="darwin", assuming not running on EC2
I0825 17:20:54.066774   24651 s3context.go:192] defaulting region to "us-east-1"
I0825 17:20:54.884814   24651 s3context.go:228] found bucket in region "us-east-1"
I0825 17:20:54.885723   24651 s3fs.go:385] Reading file "s3://${BSS}/<name>.k8s.local/config"
I0825 17:20:55.136026   24651 channel.go:123] resolving "stable" against default channel location "https://raw.githubusercontent.com/kubernetes/kops/master/channels/"
I0825 17:20:55.136073   24651 channel.go:143] Loading channel from "https://raw.githubusercontent.com/kubernetes/kops/master/channels/stable"
I0825 17:20:55.136541   24651 context.go:245] Performing HTTP request: GET https://raw.githubusercontent.com/kubernetes/kops/master/channels/stable
I0825 17:20:55.586698   24651 channel.go:152] Channel contents: spec:
  images:
    # We put the "legacy" version first, for kops versions that don't support versions ( < 1.5.0 )
    - name: kope.io/k8s-1.4-debian-jessie-amd64-hvm-ebs-2017-07-28
      providerID: aws
      architectureID: amd64
      kubernetesVersion: ">=1.4.0 <1.5.0"
    - name: kope.io/k8s-1.5-debian-jessie-amd64-hvm-ebs-2018-08-17
      providerID: aws
      architectureID: amd64
      kubernetesVersion: ">=1.5.0 <1.6.0"
    - name: kope.io/k8s-1.6-debian-jessie-amd64-hvm-ebs-2018-08-17
      providerID: aws
      architectureID: amd64
      kubernetesVersion: ">=1.6.0 <1.7.0"
    - name: kope.io/k8s-1.7-debian-jessie-amd64-hvm-ebs-2018-08-17
      providerID: aws
      architectureID: amd64
      kubernetesVersion: ">=1.7.0 <1.8.0"
    - name: kope.io/k8s-1.8-debian-stretch-amd64-hvm-ebs-2018-08-17
      providerID: aws
      architectureID: amd64
      kubernetesVersion: ">=1.8.0 <1.9.0"
    - name: kope.io/k8s-1.9-debian-stretch-amd64-hvm-ebs-2018-08-17
      providerID: aws
      architectureID: amd64
      kubernetesVersion: ">=1.9.0 <1.10.0"
    - name: kope.io/k8s-1.10-debian-stretch-amd64-hvm-ebs-2018-08-17
      providerID: aws
      architectureID: amd64
      kubernetesVersion: ">=1.10.0 <1.11.0"
    # Stretch is the default for 1.11 (for nvme)
    - name: kope.io/k8s-1.11-debian-stretch-amd64-hvm-ebs-2021-02-05
      providerID: aws
      architectureID: amd64
      kubernetesVersion: ">=1.11.0 <1.12.0"
    - name: kope.io/k8s-1.12-debian-stretch-amd64-hvm-ebs-2021-02-05
      providerID: aws
      architectureID: amd64
      kubernetesVersion: ">=1.12.0 <1.13.0"
    - name: kope.io/k8s-1.13-debian-stretch-amd64-hvm-ebs-2021-02-05
      providerID: aws
      architectureID: amd64
      kubernetesVersion: ">=1.13.0 <1.14.0"
    - name: kope.io/k8s-1.14-debian-stretch-amd64-hvm-ebs-2021-02-05
      providerID: aws
      architectureID: amd64
      kubernetesVersion: ">=1.14.0 <1.15.0"
    - name: kope.io/k8s-1.15-debian-stretch-amd64-hvm-ebs-2021-02-05
      providerID: aws
      architectureID: amd64
      kubernetesVersion: ">=1.15.0 <1.16.0"
    - name: kope.io/k8s-1.16-debian-stretch-amd64-hvm-ebs-2021-02-05
      providerID: aws
      architectureID: amd64
      kubernetesVersion: ">=1.16.0 <1.17.0"
    - name: kope.io/k8s-1.17-debian-stretch-amd64-hvm-ebs-2021-02-05
      providerID: aws
      architectureID: amd64
      kubernetesVersion: ">=1.17.0 <1.18.0"
    - name: 099720109477/ubuntu/images/hvm-ssd/ubuntu-focal-20.04-amd64-server-20240610
      providerID: aws
      architectureID: amd64
      kubernetesVersion: ">=1.18.0 <1.27.0"
    - name: 099720109477/ubuntu/images/hvm-ssd/ubuntu-focal-20.04-arm64-server-20240610
      providerID: aws
      architectureID: arm64
      kubernetesVersion: ">=1.20.0 <1.27.0"
    - name: 099720109477/ubuntu/images/hvm-ssd/ubuntu-jammy-22.04-amd64-server-20240607
      providerID: aws
      architectureID: amd64
      kubernetesVersion: ">=1.27.0"
    - name: 099720109477/ubuntu/images/hvm-ssd/ubuntu-jammy-22.04-arm64-server-20240607
      providerID: aws
      architectureID: arm64
      kubernetesVersion: ">=1.27.0"
    - name: cos-cloud/cos-stable-65-10323-99-0
      providerID: gce
      architectureID: amd64
      kubernetesVersion: "<1.16.0-alpha.1"
    - name: "cos-cloud/cos-stable-77-12371-114-0"
      providerID: gce
      architectureID: amd64
      kubernetesVersion: ">=1.16.0 <1.18.0"
    - name: ubuntu-os-cloud/ubuntu-2004-focal-v20240607
      providerID: gce
      architectureID: amd64
      kubernetesVersion: ">=1.18.0 <1.27.0"
    - name: ubuntu-os-cloud/ubuntu-2204-jammy-v20240607
      providerID: gce
      architectureID: amd64
      kubernetesVersion: ">=1.27.0"
    - name: Canonical:0001-com-ubuntu-server-focal:20_04-lts-gen2:20.04.202406060
      providerID: azure
      architectureID: amd64
      kubernetesVersion: ">=1.20.0 <1.27.0"
    - name: Canonical:0001-com-ubuntu-server-jammy:22_04-lts-gen2:22.04.202405140
      providerID: azure
      architectureID: amd64
      kubernetesVersion: ">=1.27.0"
  cluster:
    kubernetesVersion: v1.5.8
    networking:
      kubenet: {}
  kubernetesVersions:
  - range: ">=1.30.0"
    recommendedVersion: 1.30.2
    requiredVersion: 1.30.0
  - range: ">=1.29.0"
    recommendedVersion: 1.29.6
    requiredVersion: 1.29.0
  - range: ">=1.28.0"
    recommendedVersion: 1.28.11
    requiredVersion: 1.28.0
  - range: ">=1.27.0"
    recommendedVersion: 1.27.15
    requiredVersion: 1.27.0
  - range: ">=1.26.0"
    recommendedVersion: 1.26.15
    requiredVersion: 1.26.0
  - range: ">=1.25.0"
    recommendedVersion: 1.25.16
    requiredVersion: 1.25.0
  - range: ">=1.24.0"
    recommendedVersion: 1.24.17
    requiredVersion: 1.24.0
  - range: ">=1.23.0"
    recommendedVersion: 1.23.17
    requiredVersion: 1.23.0
  - range: ">=1.22.0"
    recommendedVersion: 1.22.17
    requiredVersion: 1.22.0
  - range: ">=1.21.0"
    recommendedVersion: 1.21.14
    requiredVersion: 1.21.0
  - range: ">=1.20.0"
    recommendedVersion: 1.20.15
    requiredVersion: 1.20.0
  - range: ">=1.19.0"
    recommendedVersion: 1.19.16
    requiredVersion: 1.19.0
  - range: ">=1.18.0"
    recommendedVersion: 1.18.20
    requiredVersion: 1.18.0
  - range: ">=1.17.0"
    recommendedVersion: 1.17.17
    requiredVersion: 1.17.0
  - range: ">=1.16.0"
    recommendedVersion: 1.16.15
    requiredVersion: 1.16.0
  - range: ">=1.15.0"
    recommendedVersion: 1.15.12
    requiredVersion: 1.15.0
  - range: ">=1.14.0"
    recommendedVersion: 1.14.10
    requiredVersion: 1.14.0
  - range: ">=1.13.0"
    recommendedVersion: 1.13.12
    requiredVersion: 1.13.0
  - range: ">=1.12.0"
    recommendedVersion: 1.12.10
    requiredVersion: 1.12.0
  - range: ">=1.11.0"
    recommendedVersion: 1.11.10
    requiredVersion: 1.11.0
  - range: "<1.11.0"
    recommendedVersion: 1.11.10
    requiredVersion: 1.11.10
  kopsVersions:
  - range: ">=1.30.0-alpha.1"
    recommendedVersion: "1.29.0-beta.1"
    #requiredVersion: 1.30.0
    kubernetesVersion: 1.30.2
  - range: ">=1.29.0-alpha.1"
    recommendedVersion: "1.29.0-beta.1"
    #requiredVersion: 1.29.0
    kubernetesVersion: 1.29.6
  - range: ">=1.28.0-alpha.1"
    recommendedVersion: "1.28.4"
    #requiredVersion: 1.28.0
    kubernetesVersion: 1.28.11
  - range: ">=1.27.0-alpha.1"
    recommendedVersion: "1.28.4"
    #requiredVersion: 1.27.0
    kubernetesVersion: 1.27.15
  - range: ">=1.26.0-alpha.1"
    recommendedVersion: "1.28.4"
    #requiredVersion: 1.26.0
    kubernetesVersion: 1.26.15
  - range: ">=1.25.0-alpha.1"
    recommendedVersion: "1.28.4"
    #requiredVersion: 1.25.0
    kubernetesVersion: 1.25.16
  - range: ">=1.24.0-alpha.1"
    recommendedVersion: "1.28.4"
    #requiredVersion: 1.24.0
    kubernetesVersion: 1.24.17
  - range: ">=1.23.0-alpha.1"
    recommendedVersion: "1.28.4"
    #requiredVersion: 1.23.0
    kubernetesVersion: 1.23.17
  - range: ">=1.22.0-alpha.1"
    recommendedVersion: "1.27.0"
    #requiredVersion: 1.22.0
    kubernetesVersion: 1.22.17
  - range: ">=1.21.0-alpha.1"
    recommendedVersion: "1.26.5"
    #requiredVersion: 1.21.0
    kubernetesVersion: 1.21.14
  - range: ">=1.20.0-alpha.1"
    recommendedVersion: "1.25.4"
    #requiredVersion: 1.20.0
    kubernetesVersion: 1.20.15
  - range: ">=1.19.0-alpha.1"
    recommendedVersion: "1.24.5"
    #requiredVersion: 1.19.0
    kubernetesVersion: 1.19.16
  - range: ">=1.18.0-alpha.1"
    recommendedVersion: "1.23.4"
    #requiredVersion: 1.18.0
    kubernetesVersion: 1.18.20
  - range: ">=1.17.0-alpha.1"
    recommendedVersion: "1.22.3"
    #requiredVersion: 1.17.0
    kubernetesVersion: 1.17.17
  - range: ">=1.16.0-alpha.1"
    recommendedVersion: "1.21.4"
    #requiredVersion: 1.16.0
    kubernetesVersion: 1.16.15
  - range: ">=1.15.0-alpha.1"
    recommendedVersion: "1.21.4"
    #requiredVersion: 1.15.0
    kubernetesVersion: 1.15.12
  - range: ">=1.14.0-alpha.1"
    #recommendedVersion: "1.14.0"
    #requiredVersion: 1.14.0
    kubernetesVersion: 1.14.10
  - range: ">=1.13.0-alpha.1"
    #recommendedVersion: "1.13.0"
    #requiredVersion: 1.13.0
    kubernetesVersion: 1.13.12
  - range: ">=1.12.0-alpha.1"
    recommendedVersion: "1.12.1"
    #requiredVersion: 1.12.0
    kubernetesVersion: 1.12.10
  - range: ">=1.11.0-alpha.1"
    recommendedVersion: "1.11.1"
    #requiredVersion: 1.11.0
    kubernetesVersion: 1.11.10
  - range: "<1.11.0-alpha.1"
    recommendedVersion: "1.11.1"
    #requiredVersion: 1.10.0
    kubernetesVersion: 1.11.10
panic: interface conversion: interface {} is *string, not string

goroutine 1 [running]:
main.getFilters(_, {_, _}, {_, _, _})
        k8s.io/kops/cmd/kops/toolbox_instance-selector.go:401 +0x685
main.RunToolboxInstanceSelector({0x113f9c018, 0xc000559f50}, {0x113f40100?, 0xc00071c180?}, {0x113f2b4b8, 0xc0000c6028}, 0xc000235a80, 0xc00063e460)
        k8s.io/kops/cmd/kops/toolbox_instance-selector.go:279 +0x827
main.NewCmdToolboxInstanceSelector.func3(0xc00017ba00?, {0xc00063e5b0?, 0x1?, 0x1114ad4ae?})
        k8s.io/kops/cmd/kops/toolbox_instance-selector.go:154 +0x3c
github.com/spf13/cobra.(*Command).execute(0xc000759b08, {0xc00063e540, 0x7, 0x7})
        github.com/spf13/cobra@v1.8.1/command.go:985 +0xaca
github.com/spf13/cobra.(*Command).ExecuteC(0x117341f60)
        github.com/spf13/cobra@v1.8.1/command.go:1117 +0x3ff
github.com/spf13/cobra.(*Command).Execute(...)
        github.com/spf13/cobra@v1.8.1/command.go:1041
github.com/spf13/cobra.(*Command).ExecuteContext(...)
        github.com/spf13/cobra@v1.8.1/command.go:1034
main.Execute({0x113f9bf70, 0x1174a0e88})
        k8s.io/kops/cmd/kops/root.go:100 +0x374
main.run({0x113f9bf70, 0x1174a0e88})
        k8s.io/kops/cmd/kops/main.go:55 +0x165
main.main()
        k8s.io/kops/cmd/kops/main.go:29 +0x25

9. Anything else do we need to know?