Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Daemonset fault tolerance #141

Merged
merged 28 commits into from
Oct 10, 2024
Merged
Show file tree
Hide file tree
Changes from 24 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
24 changes: 13 additions & 11 deletions internal/controller/capacity.go
Original file line number Diff line number Diff line change
Expand Up @@ -87,25 +87,27 @@ func (*InstasliceReconciler) getStartIndexFromPreparedState(instaslice *inferenc
for i := range gpuAllocatedIndex {
gpuAllocatedIndex[i] = 0
}
//TODO: remove this once we start using GPU operator with device plugin fix
for _, item := range instaslice.Spec.Prepared {
if item.Parent == gpuUUID {
for i := 0; i < int(item.Size); i++ {
gpuAllocatedIndex[int(item.Start)+i] = 1
}

}
}
// deleted allocations can be reused
// ungated allocations are already counted in prepared
for _, item := range instaslice.Spec.Allocations {
if item.GPUUUID == gpuUUID && item.Allocationstatus != inferencev1alpha1.AllocationStatusDeleted && item.Allocationstatus != inferencev1alpha1.AllocationStatusUngated {
if item.GPUUUID == gpuUUID && item.Allocationstatus != inferencev1alpha1.AllocationStatusDeleted {
for i := 0; i < int(item.Size); i++ {
gpuAllocatedIndex[int(item.Start)+i] = 1
}
}
}

// Check if all indices are allocated
allAllocated := true
for _, allocated := range gpuAllocatedIndex {
if allocated != 1 {
allAllocated = false
break
}
}
if allAllocated {
// invalid index
return uint32(9)
}
var neededContinousSlot int
var possiblePlacements []int
for _, placement := range instaslice.Spec.Migplacement {
Expand Down
1 change: 1 addition & 0 deletions internal/controller/constants.go
Original file line number Diff line number Diff line change
Expand Up @@ -26,4 +26,5 @@ const (
AttributeMediaExtensions = "me"
instaSliceOperatorNamespace = "default"
NvidiaMIGPrefix = "nvidia.com/mig-"
NodeLabel = "kubernetes.io/hostname"
)
265 changes: 180 additions & 85 deletions internal/controller/instaslice_controller.go

Large diffs are not rendered by default.

14 changes: 5 additions & 9 deletions internal/controller/instaslice_controller_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ import (
inferencev1alpha1 "github.com/openshift/instaslice-operator/api/v1alpha1"
)

func TestChangesAllocationDeletionndFinalizer(t *testing.T) {
func TestChangesAllocationDeletionAndFinalizer(t *testing.T) {
var _ = Describe("InstasliceReconciler processInstasliceAllocation", func() {
var (
ctx context.Context
Expand Down Expand Up @@ -105,10 +105,9 @@ func TestChangesAllocationDeletionndFinalizer(t *testing.T) {
}
Expect(fakeClient.Update(ctx, instaslice)).To(Succeed())

found, result, err := r.processInstasliceAllocation(ctx, instaslice.Name, podUUID, instaslice.Spec.Allocations[podUUID], req)
result, err := r.deleteInstasliceAllocation(ctx, instaslice.Name, instaslice.Spec.Allocations[podUUID])

Expect(err).NotTo(HaveOccurred())
Expect(found).To(BeTrue())
Expect(result).To(Equal(ctrl.Result{}))

updatedInstaSlice := &inferencev1alpha1.Instaslice{}
Expand All @@ -125,10 +124,9 @@ func TestChangesAllocationDeletionndFinalizer(t *testing.T) {
}
Expect(fakeClient.Update(ctx, instaslice)).To(Succeed())

found, result, err := r.processInstasliceAllocation(ctx, instaslice.Name, podUUID, instaslice.Spec.Allocations[podUUID], req)
result, err := r.removeInstaSliceFinalizer(ctx, req)

Expect(err).NotTo(HaveOccurred())
Expect(found).To(BeTrue())
Expect(result).To(Equal(ctrl.Result{}))

updatedPod := &v1.Pod{}
Expand All @@ -137,10 +135,9 @@ func TestChangesAllocationDeletionndFinalizer(t *testing.T) {
})

It("should set allocation status to Deleting if status is not Deleted", func() {
found, result, err := r.processInstasliceAllocation(ctx, instaslice.Name, podUUID, instaslice.Spec.Allocations[podUUID], req)
result, err := r.setInstasliceAllocationToDeleting(ctx, instaslice.Name, podUUID, instaslice.Spec.Allocations[podUUID])

Expect(err).NotTo(HaveOccurred())
Expect(found).To(BeTrue())

updatedInstaSlice := &inferencev1alpha1.Instaslice{}
Expect(fakeClient.Get(ctx, types.NamespacedName{Name: instaslice.Name, Namespace: instasliceNamespace}, updatedInstaSlice)).To(Succeed())
Expand All @@ -153,9 +150,8 @@ func TestChangesAllocationDeletionndFinalizer(t *testing.T) {
It("should requeue if there is an error updating the instaslice", func() {
r.Client = fake.NewClientBuilder().WithScheme(runtime.NewScheme()).Build()

found, result, err := r.processInstasliceAllocation(ctx, instaslice.Name, podUUID, instaslice.Spec.Allocations[podUUID], req)
result, err := r.setInstasliceAllocationToDeleting(ctx, instaslice.Name, podUUID, instaslice.Spec.Allocations[podUUID])

Expect(found).To(BeTrue())
Expect(err).To(HaveOccurred())
Expect(result.Requeue).To(BeTrue())
})
Expand Down
Loading