Skip to content

Commit

Permalink
fix: subnet failed when create without protocol
Browse files Browse the repository at this point in the history
```
E0628 03:22:35.895023      13 subnet.go:487] handle subnet finalizer failed Subnet.kubeovn.io "subnet1" is invalid: spec.protocol: Unsupported value: "": supported values: "IPv4", "IPv6", "Dual"
E0628 03:22:35.895056      13 subnet.go:186] error syncing 'subnet1': Subnet.kubeovn.io "subnet1" is invalid: spec.protocol: Unsupported value: "": supported values: "IPv4", "IPv6", "Dual", requeuing
E0628 03:22:35.921654      13 subnet.go:427] failed to add finalizer to subnet subnet1, Subnet.kubeovn.io "subnet1" is invalid: spec.protocol: Unsupported value: "": supported values: "IPv4", "IPv6", "Dual"
E0628 03:22:35.921685      13 subnet.go:487] handle subnet finalizer failed Subnet.kubeovn.io "subnet1" is invalid: spec.protocol: Unsupported value: "": supported values: "IPv4", "IPv6", "Dual"
E0628 03:22:35.921717      13 subnet.go:186] error syncing 'subnet1': Subnet.kubeovn.io "subnet1" is invalid: spec.protocol: Unsupported value: "": supported values: "IPv4", "IPv6", "Dual", requeuing
E0628 03:22:35.968668      13 subnet.go:427] failed to add finalizer to subnet subnet1, Subnet.kubeovn.io "subnet1" is invalid: spec.protocol: Unsupported value: "": supported values: "IPv4", "IPv6", "Dual"

```
  • Loading branch information
oilbeater committed Jun 28, 2022
1 parent 4b06324 commit 7c4dfe7
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 10 deletions.
4 changes: 2 additions & 2 deletions Makefile
Expand Up @@ -66,7 +66,7 @@ base-arm64:
docker buildx build --platform linux/arm64 --build-arg ARCH=arm64 -t $(REGISTRY)/kube-ovn-base:$(RELEASE_TAG)-arm64 -o type=docker -f dist/images/Dockerfile.base dist/images/

.PHONY: release
release: lint build-go
release: build-go
docker buildx build --platform linux/amd64 --build-arg ARCH=amd64 -t $(REGISTRY)/kube-ovn:$(RELEASE_TAG) -o type=docker -f dist/images/Dockerfile dist/images/
docker buildx build --platform linux/amd64 --build-arg ARCH=amd64 -t $(REGISTRY)/kube-ovn:$(RELEASE_TAG)-no-avx512 -o type=docker -f dist/images/Dockerfile.no-avx512 dist/images/
docker buildx build --platform linux/amd64 --build-arg ARCH=amd64 -t $(REGISTRY)/kube-ovn:$(RELEASE_TAG)-dpdk -o type=docker -f dist/images/Dockerfile.dpdk dist/images/
Expand Down Expand Up @@ -385,7 +385,7 @@ lint:
echo "Code differs from gofmt's style" 1>&2 && exit 1; \
fi
@GOOS=linux go vet ./...
@GOOS=linux gosec -exclude=G204,G601,G306 -exclude-dir=test -exclude-dir=pkg/client ./...
@GOOS=linux gosec -exclude=G204,G601,G306,G404 -exclude-dir=test -exclude-dir=pkg/client ./...

.PHONY: lint-windows
lint-windows:
Expand Down
18 changes: 10 additions & 8 deletions pkg/controller/subnet.go
Expand Up @@ -473,6 +473,7 @@ func (c Controller) patchSubnetStatus(subnet *kubeovnv1.Subnet, reason string, e

func (c *Controller) handleAddOrUpdateSubnet(key string) error {
var err error

cachedSubnet, err := c.subnetsLister.Get(key)
if err != nil {
if k8serrors.IsNotFound(err) {
Expand All @@ -482,26 +483,27 @@ func (c *Controller) handleAddOrUpdateSubnet(key string) error {
}

subnet := cachedSubnet.DeepCopy()
deleted, err := c.handleSubnetFinalizer(subnet)
if err != nil {
klog.Errorf("handle subnet finalizer failed %v", err)
if err = formatSubnet(subnet, c); err != nil {
return err
}
if deleted {
return nil
}

if cachedSubnet, err = c.subnetsLister.Get(key); err != nil {
cachedSubnet, err = c.subnetsLister.Get(key)
if err != nil {
if k8serrors.IsNotFound(err) {
return nil
}
return err
}

subnet = cachedSubnet.DeepCopy()
if err = formatSubnet(subnet, c); err != nil {
deleted, err := c.handleSubnetFinalizer(subnet)
if err != nil {
klog.Errorf("handle subnet finalizer failed %v", err)
return err
}
if deleted {
return nil
}

vpc, err := c.vpcsLister.Get(subnet.Spec.Vpc)
if err != nil {
Expand Down

0 comments on commit 7c4dfe7

Please sign in to comment.