Skip to content

Commit

Permalink
Merge pull request #1077 from sykim-etri/prevent-to-access-out-of-range
Browse files Browse the repository at this point in the history
Prevent to access index out of range [0] with length 0
  • Loading branch information
powerkimhub authored Feb 16, 2024
2 parents bec2ec1 + ce34877 commit d22e4ae
Showing 1 changed file with 22 additions and 20 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -639,26 +639,28 @@ func getNodeGroupInfo(access_key, access_secret, region_id, cluster_id, node_gro
auto_scale_enalbed = true
}

nodeGroupInfo = &irs.NodeGroupInfo{
IId: irs.IID{
NameId: *res.Response.NodePool.Name,
SystemId: *res.Response.NodePool.NodePoolId,
},
ImageIID: irs.IID{
NameId: "",
SystemId: *launch_config.Response.LaunchConfigurationSet[0].ImageId,
},
VMSpecName: *launch_config.Response.LaunchConfigurationSet[0].InstanceType,
RootDiskType: *launch_config.Response.LaunchConfigurationSet[0].SystemDisk.DiskType,
RootDiskSize: fmt.Sprintf("%d", *launch_config.Response.LaunchConfigurationSet[0].SystemDisk.DiskSize),
KeyPairIID: irs.IID{NameId: "", SystemId: *launch_config.Response.LaunchConfigurationSet[0].LoginSettings.KeyIds[0]},
Status: status,
OnAutoScaling: auto_scale_enalbed,
MinNodeSize: int(*auto_scaling_group.Response.AutoScalingGroupSet[0].MinSize),
MaxNodeSize: int(*auto_scaling_group.Response.AutoScalingGroupSet[0].MaxSize),
DesiredNodeSize: int(*auto_scaling_group.Response.AutoScalingGroupSet[0].DesiredCapacity),
Nodes: []irs.IID{}, // to be implemented
KeyValueList: []irs.KeyValue{},
if len(launch_config.Response.LaunchConfigurationSet) > 0 || len(auto_scaling_group.Response.AutoScalingGroupSet) > 0 {
nodeGroupInfo = &irs.NodeGroupInfo{
IId: irs.IID{
NameId: *res.Response.NodePool.Name,
SystemId: *res.Response.NodePool.NodePoolId,
},
ImageIID: irs.IID{
NameId: "",
SystemId: *launch_config.Response.LaunchConfigurationSet[0].ImageId,
},
VMSpecName: *launch_config.Response.LaunchConfigurationSet[0].InstanceType,
RootDiskType: *launch_config.Response.LaunchConfigurationSet[0].SystemDisk.DiskType,
RootDiskSize: fmt.Sprintf("%d", *launch_config.Response.LaunchConfigurationSet[0].SystemDisk.DiskSize),
KeyPairIID: irs.IID{NameId: "", SystemId: *launch_config.Response.LaunchConfigurationSet[0].LoginSettings.KeyIds[0]},
Status: status,
OnAutoScaling: auto_scale_enalbed,
MinNodeSize: int(*auto_scaling_group.Response.AutoScalingGroupSet[0].MinSize),
MaxNodeSize: int(*auto_scaling_group.Response.AutoScalingGroupSet[0].MaxSize),
DesiredNodeSize: int(*auto_scaling_group.Response.AutoScalingGroupSet[0].DesiredCapacity),
Nodes: []irs.IID{}, // to be implemented
KeyValueList: []irs.KeyValue{},
}
}

nodes, err := tencent.DescribeClusterInstances(access_key, access_secret, region_id, cluster_id)
Expand Down

0 comments on commit d22e4ae

Please sign in to comment.