Skip to content
This repository has been archived by the owner on Apr 24, 2023. It is now read-only.

Commit

Permalink
fix: Remove deprecated pod status updating (#266)
Browse files Browse the repository at this point in the history
  • Loading branch information
k-simons authored Apr 19, 2023
1 parent 5b3546a commit 0bf80a2
Show file tree
Hide file tree
Showing 3 changed files with 1 addition and 31 deletions.
1 change: 0 additions & 1 deletion cmd/server.go
Original file line number Diff line number Diff line change
Expand Up @@ -149,7 +149,6 @@ func InitServerWithClients(ctx context.Context, info witchcraft.InitInfo, allCli
install.AsyncClientConfig,
)
demandManager := demands.NewDefaultManager(
kubeClient.CoreV1(),
demandCache,
binpacker,
instanceGroupLabel)
Expand Down
29 changes: 0 additions & 29 deletions internal/demands/demand.go
Original file line number Diff line number Diff line change
Expand Up @@ -31,19 +31,6 @@ import (
"github.com/palantir/witchcraft-go-logging/wlog/svclog/svc1log"
v1 "k8s.io/api/core/v1"
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
corev1 "k8s.io/client-go/kubernetes/typed/core/v1"
podutil "k8s.io/kubernetes/pkg/api/v1/pod"
)

const (
podDemandCreated v1.PodConditionType = "PodDemandCreated"
)

var (
demandCreatedCondition = &v1.PodCondition{
Type: podDemandCreated,
Status: v1.ConditionTrue,
}
)

// Manager holds the types of demand operations that are available
Expand All @@ -55,38 +42,23 @@ type Manager interface {
}

type defaultManager struct {
coreClient corev1.CoreV1Interface
demands *cache.SafeDemandCache
binpacker *binpacker.Binpacker
instanceGroupLabel string
}

// NewDefaultManager creates the default implementation of the Manager
func NewDefaultManager(
coreClient corev1.CoreV1Interface,
demands *cache.SafeDemandCache,
binpacker *binpacker.Binpacker,
instanceGroupLabel string) Manager {
return &defaultManager{
coreClient: coreClient,
demands: demands,
binpacker: binpacker,
instanceGroupLabel: instanceGroupLabel,
}
}

// TODO: should patch instead of put to avoid conflicts
func (d *defaultManager) updatePodStatus(ctx context.Context, pod *v1.Pod, _ *v1.PodCondition) {
if !podutil.UpdatePodCondition(&pod.Status, demandCreatedCondition) {
svc1log.FromContext(ctx).Info("pod condition for demand creation already exist")
return
}
_, err := d.coreClient.Pods(pod.Namespace).UpdateStatus(ctx, pod, metav1.UpdateOptions{})
if err != nil {
svc1log.FromContext(ctx).Warn("pod condition update failed", svc1log.SafeParam("reason", err.Error()))
}
}

func (d *defaultManager) CreateDemandForExecutorInAnyZone(ctx context.Context, executorPod *v1.Pod, executorResources *resources.Resources) {
d.CreateDemandForExecutorInSpecificZone(ctx, executorPod, executorResources, nil)
}
Expand Down Expand Up @@ -136,7 +108,6 @@ func (d *defaultManager) createDemand(ctx context.Context, pod *v1.Pod, demandUn
svc1log.FromContext(ctx).Error("failed to create demand", svc1log.Stacktrace(err))
return
}
go d.updatePodStatus(ctx, pod, demandCreatedCondition)
}

func (d *defaultManager) doCreateDemand(ctx context.Context, newDemand *demandapi.Demand) error {
Expand Down
2 changes: 1 addition & 1 deletion internal/extender/extendertest/extender_test_utils.go
Original file line number Diff line number Diff line change
Expand Up @@ -136,7 +136,7 @@ func NewTestExtender(binpackAlgo string, objects ...runtime.Object) (*Harness, e

wasteMetricsReporter := metrics.NewWasteMetricsReporter(ctx, instanceGroupLabel)

demandManager := demands.NewDefaultManager(fakeKubeClient.CoreV1(), demandCache, binpacker, instanceGroupLabel)
demandManager := demands.NewDefaultManager(demandCache, binpacker, instanceGroupLabel)
sparkSchedulerExtender := extender.NewExtender(
nodeLister,
sparkPodLister,
Expand Down

0 comments on commit 0bf80a2

Please sign in to comment.