Skip to content

Commit

Permalink
Merge pull request #3021 from Icarus9913/cherrypick2952
Browse files Browse the repository at this point in the history
  • Loading branch information
weizhoublue authored Dec 27, 2023
2 parents b029996 + 309885f commit f892377
Showing 1 changed file with 5 additions and 9 deletions.
14 changes: 5 additions & 9 deletions pkg/ipam/pool_selections.go
Original file line number Diff line number Diff line change
Expand Up @@ -27,8 +27,6 @@ import (
)

func (i *ipam) getPoolCandidates(ctx context.Context, addArgs *models.IpamAddArgs, pod *corev1.Pod, podController types.PodTopController) (ToBeAllocateds, error) {
log := logutils.FromContext(ctx)

// If feature SpiderSubnet is enabled, select IPPool candidates through the
// Pod annotations "ipam.spidernet.io/subnet" or "ipam.spidernet.io/subnets". (expect orphan Pod controller)
if i.config.EnableSpiderSubnet {
Expand All @@ -37,13 +35,7 @@ func (i *ipam) getPoolCandidates(ctx context.Context, addArgs *models.IpamAddArg
return nil, fmt.Errorf("failed to get IPPool candidates from Subnet: %v", err)
}
if fromSubnet != nil {
// The SpiderSubnet feature doesn't support orphan Pod.
// So the orphan pod would get the IPPool candidates from the other traditional IPPool rules.
if podController.APIVersion == corev1.SchemeGroupVersion.String() && podController.Kind == constant.KindPod {
log.Sugar().Warnf("SpiderSubnet feature doesn't support no-controller pod, try to allocate IPs in traditional IPPool way")
} else {
return ToBeAllocateds{fromSubnet}, nil
}
return ToBeAllocateds{fromSubnet}, nil
}
}

Expand Down Expand Up @@ -98,6 +90,10 @@ func (i *ipam) getPoolFromSubnetAnno(ctx context.Context, pod *corev1.Pod, nic s
if applicationinformers.IsDefaultIPPoolMode(subnetAnnoConfig) {
return nil, nil
}
// The SpiderSubnet feature doesn't support orphan Pod.
if podController.APIVersion == corev1.SchemeGroupVersion.String() && podController.Kind == constant.KindPod {
return nil, fmt.Errorf("SpiderSubnet feature doesn't support no-controller pod")
}

var subnetItem types.AnnoSubnetItem
if len(subnetAnnoConfig.MultipleSubnets) != 0 {
Expand Down

0 comments on commit f892377

Please sign in to comment.