Skip to content

Commit

Permalink
fix some typo style
Browse files Browse the repository at this point in the history
Signed-off-by: googs1025 <[email protected]>
  • Loading branch information
googs1025 committed Apr 13, 2024
1 parent ab7b61c commit 5037b94
Show file tree
Hide file tree
Showing 8 changed files with 27 additions and 29 deletions.
2 changes: 1 addition & 1 deletion pkg/dispatcher/internal/queue/priority_queue.go
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ type PriorityQueue struct {
queue priorityQueue
}

// LessFn is the func declaration used by sort or priority queue.
// LessFunc is the func declaration used by sort or priority queue.
type LessFunc func(interface{}, interface{}) bool

// CompareFn is the func declaration used by sort or priority queue.
Expand Down
20 changes: 10 additions & 10 deletions pkg/dispatcher/internal/queue/unit.go
Original file line number Diff line number Diff line change
Expand Up @@ -296,24 +296,24 @@ func (uis *unitInfos) Enqueue(podInfo *QueuedPodInfo) {
uis.readyUnitPods.Add(podInfo)
}

func (p *unitInfos) GetAssignedSchedulerForPodGroupUnit(pg *v1alpha1.PodGroup) string {
p.Lock()
defer p.Unlock()
func (uis *unitInfos) GetAssignedSchedulerForPodGroupUnit(pg *v1alpha1.PodGroup) string {
uis.Lock()
defer uis.Unlock()
unitKey := generateUnitKeyFromPodGroup(pg)
if ui, exist := p.units[unitKey]; exist {
if ui, exist := uis.units[unitKey]; exist {
return ui.scheduler
}
return ""
}

func (p *unitInfos) AssignSchedulerToPodGroupUnit(pg *v1alpha1.PodGroup, schedName string, forceUpdate bool) error {
p.Lock()
defer p.Unlock()
func (uis *unitInfos) AssignSchedulerToPodGroupUnit(pg *v1alpha1.PodGroup, schedName string, forceUpdate bool) error {
uis.Lock()
defer uis.Unlock()
unitKey := generateUnitKeyFromPodGroup(pg)
ui := p.units[unitKey]
ui := uis.units[unitKey]
if ui == nil {
p.units[unitKey] = NewUnitInfo()
ui = p.units[unitKey]
uis.units[unitKey] = NewUnitInfo()
ui = uis.units[unitKey]
}
if forceUpdate {
ui.scheduler = schedName
Expand Down
3 changes: 1 addition & 2 deletions pkg/dispatcher/internal/scheduler/scheduler.go
Original file line number Diff line number Diff line change
Expand Up @@ -88,9 +88,8 @@ func (gs *GodelScheduler) SetSchedulerInActive() {
gs.active = false
}

func (gs *GodelScheduler) SetScheduler(scheduler *schedulerapi.Scheduler) error {
func (gs *GodelScheduler) SetScheduler(scheduler *schedulerapi.Scheduler) {
gs.scheduler = scheduler
return nil
}

func (gs *GodelScheduler) GetScheduler() *schedulerapi.Scheduler {
Expand Down
5 changes: 2 additions & 3 deletions pkg/dispatcher/reconciler/podstatesyncer.go
Original file line number Diff line number Diff line change
Expand Up @@ -213,10 +213,9 @@ func (psr *PodStateReconciler) updateAbnormalStatePod(pod *corev1.Pod) error {
// blindly resetting to pending state
// TODO: add more fine-grained checking and resetting operations
return psr.resetPodToPendingState(pod)
} else {
// pod returns back to normal state, return directly
return nil
}
// pod returns back to normal state, return directly
return nil
}

// resetPodToPendingState resets pod state to Pending
Expand Down
2 changes: 1 addition & 1 deletion pkg/dispatcher/scheduler-maintainer/handlers.go
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ func (maintainer *SchedulerMaintainer) AddScheduler(scheduler *schedulerapi.Sche
// we assume the caller has already got the lock
func (maintainer *SchedulerMaintainer) updateSchedulerBasedOnSchedulerCRD(scheduler *schedulerapi.Scheduler) {
if maintainer.generalSchedulers[scheduler.Name] == nil {
// schedulers is not added before, add it to active schedulers map directly
// schedulers are not added before, add it to active schedulers map directly
gs := sche.NewGodelSchedulerWithSchedulerCRD(scheduler)
metrics.SchedulerSizeInc(metrics.ActiveScheduler)
maintainer.generalSchedulers[scheduler.Name] = gs
Expand Down
6 changes: 3 additions & 3 deletions pkg/dispatcher/util/resource.go
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ func (r DRFResource) IsInit() bool {
return r != DRFResource{}
}

// SetSpecificResourceValue sets the resource value for that specific
// SetResourceValue sets the resource value for that specific
// resource type.
func (r *DRFResource) SetResourceValue(rName v1.ResourceName, quantity int64) {
switch rName {
Expand Down Expand Up @@ -86,15 +86,15 @@ func (r *DRFResource) IsZero(rn v1.ResourceName) bool {
}
}

// Add is used to add the two resources
// AddResource is used to add the two resources
func (r *DRFResource) AddResource(rr DRFResource) *DRFResource {
r.MilliCPU += rr.MilliCPU
r.Memory += rr.Memory

return r
}

// Sub subtracts two Resource objects.
// SubResource subtracts two Resource objects.
func (r *DRFResource) SubResource(rr DRFResource) *DRFResource {
r.MilliCPU -= rr.MilliCPU
r.Memory -= rr.Memory
Expand Down
16 changes: 8 additions & 8 deletions pkg/volume/persistentvolume/testing/testing.go
Original file line number Diff line number Diff line change
Expand Up @@ -107,7 +107,7 @@ func (r *VolumeReactor) React(action core.Action) (handled bool, ret runtime.Obj
// check the volume does not exist
_, found := r.volumes[volume.Name]
if found {
return true, nil, fmt.Errorf("Cannot create volume %s: volume already exists", volume.Name)
return true, nil, fmt.Errorf("cannot create volume %s: volume already exists", volume.Name)
}

// mimic apiserver defaulting
Expand All @@ -133,7 +133,7 @@ func (r *VolumeReactor) React(action core.Action) (handled bool, ret runtime.Obj
// check the claim does not exist
_, found := r.claims[claim.Name]
if found {
return true, nil, fmt.Errorf("Cannot create claim %s: claim already exists", claim.Name)
return true, nil, fmt.Errorf("cannot create claim %s: claim already exists", claim.Name)
}

// Store the updated object to appropriate places.
Expand Down Expand Up @@ -166,7 +166,7 @@ func (r *VolumeReactor) React(action core.Action) (handled bool, ret runtime.Obj
volume = volume.DeepCopy()
volume.ResourceVersion = strconv.Itoa(storedVer + 1)
} else {
return true, nil, fmt.Errorf("Cannot update volume %s: volume not found", volume.Name)
return true, nil, fmt.Errorf("cannot update volume %s: volume not found", volume.Name)
}

// Store the updated object to appropriate places.
Expand Down Expand Up @@ -199,7 +199,7 @@ func (r *VolumeReactor) React(action core.Action) (handled bool, ret runtime.Obj
claim = claim.DeepCopy()
claim.ResourceVersion = strconv.Itoa(storedVer + 1)
} else {
return true, nil, fmt.Errorf("Cannot update claim %s: claim not found", claim.Name)
return true, nil, fmt.Errorf("cannot update claim %s: claim not found", claim.Name)
}

// Store the updated object to appropriate places.
Expand Down Expand Up @@ -244,7 +244,7 @@ func (r *VolumeReactor) React(action core.Action) (handled bool, ret runtime.Obj
r.changedSinceLastSync++
return true, nil, nil
}
return true, nil, fmt.Errorf("Cannot delete volume %s: not found", name)
return true, nil, fmt.Errorf("cannot delete volume %s: not found", name)

case action.Matches("delete", "persistentvolumeclaims"):
name := action.(core.DeleteAction).GetName()
Expand All @@ -258,7 +258,7 @@ func (r *VolumeReactor) React(action core.Action) (handled bool, ret runtime.Obj
r.changedSinceLastSync++
return true, nil, nil
}
return true, nil, fmt.Errorf("Cannot delete claim %s: not found", name)
return true, nil, fmt.Errorf("cannot delete claim %s: not found", name)
}

return false, nil, nil
Expand Down Expand Up @@ -348,7 +348,7 @@ func (r *VolumeReactor) CheckVolumes(expectedVolumes []*v1.PersistentVolume) err
if !reflect.DeepEqual(expectedMap, gotMap) {
// Print ugly but useful diff of expected and received objects for
// easier debugging.
return fmt.Errorf("Volume check failed [A-expected, B-got]: %s", diff.ObjectDiff(expectedMap, gotMap))
return fmt.Errorf("volume check failed [A-expected, B-got]: %s", diff.ObjectDiff(expectedMap, gotMap))
}
return nil
}
Expand Down Expand Up @@ -377,7 +377,7 @@ func (r *VolumeReactor) CheckClaims(expectedClaims []*v1.PersistentVolumeClaim)
if !reflect.DeepEqual(expectedMap, gotMap) {
// Print ugly but useful diff of expected and received objects for
// easier debugging.
return fmt.Errorf("Claim check failed [A-expected, B-got result]: %s", diff.ObjectDiff(expectedMap, gotMap))
return fmt.Errorf("claim check failed [A-expected, B-got result]: %s", diff.ObjectDiff(expectedMap, gotMap))
}
return nil
}
Expand Down
2 changes: 1 addition & 1 deletion pkg/volume/persistentvolume/util/util.go
Original file line number Diff line number Diff line change
Expand Up @@ -134,7 +134,7 @@ func GetBindVolumeToClaim(volume *v1.PersistentVolume, claim *v1.PersistentVolum

claimRef, err := reference.GetReference(scheme.Scheme, claim)
if err != nil {
return nil, false, fmt.Errorf("Unexpected error getting claim reference: %v", err)
return nil, false, fmt.Errorf("unexpected error getting claim reference: %v", err)
}
volumeClone.Spec.ClaimRef = claimRef
dirty = true
Expand Down

0 comments on commit 5037b94

Please sign in to comment.