Skip to content

MatchExistingSvc() has logic problem #219

@nokia-t1zhou

Description

@nokia-t1zhou

Is this a BUG REPORT or FEATURE REQUEST?:

Uncomment only one, leave it on its own line:

bug

feature

What happened:

func MatchExistingSvc(de *danmv1.DanmEp, servicesList []*corev1.Service) []*corev1.Service {
	deNs := de.Namespace
	var svcList []*corev1.Service
	for _, svc := range servicesList {
		annotations := svc.GetAnnotations()
		selectorMap, svcNets, err := GetDanmSvcAnnotations(annotations)
		if err != nil {
			return svcList
		}
		if len(selectorMap) == 0 || !isDepSelectedBySvc(de, svcNets) || svc.GetNamespace() != deNs {
			continue
		}
		deMap := de.GetLabels()
		deFit := IsContain(deMap, selectorMap)
		if !deFit {
			continue
		}
		svcList = append(svcList, svc.DeepCopy())
	}
	return svcList
}

if GetDanmSvcAnnotations() return with error code, if the K8s service with wrong format of DANM service exist, then will cause some K8s endpoint can't be update/modified,
What you expected to happen:
i think the code should be:

		annotations := svc.GetAnnotations()
		selectorMap, svcNets, err := GetDanmSvcAnnotations(annotations)
		if err != nil {
			continue
		}

by the way:
my service YAML file with below Annotations:
danm.k8s.io/selector: '{ "nwservice": "l1-nwmgmtservice" }'
svcwatcher will ouput these error log:
utils.go:44] utils: json error: invalid character 'f' after object key:value pair
and DANM can't update K8s endpoint with selected IP.
but if use below Annotations:
danm.k8s.io/selector: '{"nwservice":"l1-nwmgmtservice"}'
everything is OK.

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't working

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions