Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[cherrypick]single POD without controller is forbidden to use SpiderSubnet feature #3021

Merged
merged 1 commit into from
Dec 27, 2023
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
Loading