nokia / CPU-Pooler

A Device Plugin for Kubernetes, which exposes the CPU cores as consumable Devices to the Kubernetes scheduler.
BSD 3-Clause "New" or "Revised" License
92 stars 22 forks source link

Compilation error caused by code syntax error #63

Closed yjy5921591ok closed 3 years ago

yjy5921591ok commented 3 years ago

Describe the bug There is a code syntax error in line 194 of the file Cpu-pooler-master/pkg/sethandler/cotroller.go

Additional context

func (setHandler *SetHandler) adjustContainerSets(pod v1.Pod, containersToBeSet map[string]int) {
    var (
        pathToContainerCpusetFile string
        err error    //  Variable declaration
    )
    for _, container := range pod.Spec.Containers {
        if _, found := containersToBeSet[container.Name]; !found {
            continue
        }
        cpuset, err := setHandler.determineCorrectCpuset(pod, container)
        if err != nil {
            log.Printf("ERROR: Cpuset for the containers of Pod: %s ID: %s could not be re-adjusted, because: %s", pod.ObjectMeta.Name, pod.ObjectMeta.UID, err)
            continue
        }
        containerID := determineCid(pod.Status, container.Name)
        if containerID == "" {
            log.Printf("ERROR: Cannot determine container id for %s from Pod: %s ID: %s", container.Name, pod.ObjectMeta.Name, pod.ObjectMeta.UID)
            return
        }
        pathToContainerCpusetFile, err = setHandler.applyCpusetToContainer(containerID, cpuset)
        if err != nil {
            log.Printf("ERROR: Cpuset for the containers of Pod: %s with ID: %s could not be re-adjusted, because: %s", pod.ObjectMeta.Name, pod.ObjectMeta.UID, err)
            continue
        }
    }
         //  Duplicate variable declaration below,no need to add a colon here
    err := setHandler.applyCpusetToInfraContainer(pod.ObjectMeta, pod.Status, pathToContainerCpusetFile)  
    if err != nil {
        log.Printf("ERROR: Cpuset for the infracontainer of Pod: %s with ID: %s could not be re-adjusted, because: %s", pod.ObjectMeta.Name, pod.ObjectMeta.UID, err)
        return
    }
    err = k8sclient.SetPodAnnotation(pod, resourceBaseName+"~1"+setterAnnotationSuffix, "true")
    if err != nil {
        log.Printf("ERROR: %s ID: %s  annontation cannot update, because: %s", pod.ObjectMeta.Name, pod.ObjectMeta.UID, err)
    }
}
Levovar commented 3 years ago

very true: https://travis-ci.org/github/nokia/CPU-Pooler/builds/764875079

thanks for the notice, gonna quickly fix it on the master!

Levovar commented 3 years ago

fixed by https://github.com/nokia/CPU-Pooler/commit/dabb1b46e4ea2de396feb337b45126da572c0d9d , green CI: https://travis-ci.org/github/nokia/CPU-Pooler/builds/768421586