Skip to content

Commit

Permalink
chore: Update nodeClaim manifest and add nodeClass (#509)
Browse files Browse the repository at this point in the history
**Reason for Change**:
- Update nodeClaim manifest:
  - Use `ResourceEphemeralStorage` instead of `ResourceStorage`
  - Add `LabelInstanceTypeStable` to the Node Selector.
- Check if NodeClass for either Azure or AWS cases has been created. if
not, the controller will create it automatically.
- Add nodeClaim error handle for plugin error case.
- Update go toolchain to 1.22.5 to be able to import karpenter/aws
**Requirements**

- [ ] added unit tests and e2e tests (if applicable).

**Issue Fixed**:
<!-- If this PR fixes GitHub issue 4321, add "Fixes #4321" to the next
line. -->

**Notes for Reviewers**:

---------

Signed-off-by: Heba Elayoty <[email protected]>
  • Loading branch information
helayoty authored Jul 20, 2024
1 parent f42a77d commit 531207e
Show file tree
Hide file tree
Showing 14 changed files with 247 additions and 67 deletions.
49 changes: 48 additions & 1 deletion cmd/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,13 +3,19 @@
package main

import (
"context"
"flag"
"os"
"os/signal"
"strconv"
"syscall"
"time"

"github.com/azure/kaito/pkg/featuregates"
"github.com/azure/kaito/pkg/k8sclient"
"github.com/azure/kaito/pkg/nodeclaim"
"github.com/azure/kaito/pkg/utils/consts"
"sigs.k8s.io/controller-runtime/pkg/client"
metricsserver "sigs.k8s.io/controller-runtime/pkg/metrics/server"
"sigs.k8s.io/karpenter/pkg/apis/v1beta1"

Expand Down Expand Up @@ -108,9 +114,10 @@ func main() {
}

k8sclient.SetGlobalClient(mgr.GetClient())
kClient := k8sclient.GetGlobalClient()

if err = (&controllers.WorkspaceReconciler{
Client: k8sclient.GetGlobalClient(),
Client: kClient,
Log: log.Log.WithName("controllers").WithName("Workspace"),
Scheme: mgr.GetScheme(),
Recorder: mgr.GetEventRecorderFor("KAITO-Workspace-controller"),
Expand Down Expand Up @@ -159,4 +166,44 @@ func main() {
klog.ErrorS(err, "problem running manager")
exitWithErrorFunc()
}
ctx := withShutdownSignal(context.Background())

// check if Karpenter NodeClass is available. If not, the controller will create it automatically.
if featuregates.FeatureGates[consts.FeatureFlagKarpenter] {
cloud := GetCloudProviderName()
if !nodeclaim.IsNodeClassAvailable(ctx, cloud, kClient) {
klog.Infof("NodeClass is not available, creating NodeClass")
if err := nodeclaim.CreateKarpenterNodeClass(ctx, kClient); err != nil {
if client.IgnoreAlreadyExists(err) != nil {
exitWithErrorFunc()
}
}
}
}
}

// withShutdownSignal returns a copy of the parent context that will close if
// the process receives termination signals.
func withShutdownSignal(ctx context.Context) context.Context {
signalChan := make(chan os.Signal, 1)
signal.Notify(signalChan, syscall.SIGTERM, syscall.SIGINT, os.Interrupt)

nctx, cancel := context.WithCancel(ctx)

go func() {
<-signalChan
klog.Info("received shutdown signal")
cancel()
}()
return nctx
}

// GetCloudProviderName returns the cloud provider name from the environment variable.
// If the environment variable is not set, the controller will exit with an error.
func GetCloudProviderName() string {
cloudProvider := os.Getenv("CLOUD_PROVIDER")
if cloudProvider == "" {
exitWithErrorFunc()
}
return cloudProvider
}
17 changes: 10 additions & 7 deletions go.mod
Original file line number Diff line number Diff line change
@@ -1,22 +1,23 @@
module github.com/azure/kaito

go 1.22.0
go 1.22.3

toolchain go1.22.2
toolchain go1.22.5

require (
github.com/Azure/karpenter-provider-azure v0.5.0
github.com/aws/karpenter-core v0.29.2
github.com/aws/karpenter-provider-aws v0.36.2
github.com/go-logr/logr v1.4.2
github.com/onsi/ginkgo/v2 v2.19.0
github.com/onsi/gomega v1.33.1
github.com/samber/lo v1.45.0
github.com/stretchr/testify v1.9.0
gopkg.in/yaml.v2 v2.4.0
gotest.tools v2.2.0+incompatible
k8s.io/api v0.30.1
k8s.io/apimachinery v0.30.1
k8s.io/client-go v0.30.1
k8s.io/api v0.30.2
k8s.io/apimachinery v0.30.2
k8s.io/client-go v0.30.2
k8s.io/component-base v0.30.1
k8s.io/klog/v2 v2.130.1
k8s.io/kubernetes v1.30.1
Expand All @@ -29,14 +30,15 @@ require (
require (
contrib.go.opencensus.io/exporter/ocagent v0.7.1-0.20200907061046-05415f1de66d // indirect
contrib.go.opencensus.io/exporter/prometheus v0.4.2 // indirect
github.com/aws/aws-sdk-go v1.51.16 // indirect
github.com/beorn7/perks v1.0.1 // indirect
github.com/blang/semver/v4 v4.0.0 // indirect
github.com/blendle/zapdriver v1.3.1 // indirect
github.com/census-instrumentation/opencensus-proto v0.4.1 // indirect
github.com/cespare/xxhash/v2 v2.2.0 // indirect
github.com/davecgh/go-spew v1.1.1 // indirect
github.com/emicklei/go-restful/v3 v3.11.0 // indirect
github.com/evanphx/json-patch v4.12.0+incompatible // indirect
github.com/evanphx/json-patch v5.7.0+incompatible // indirect
github.com/evanphx/json-patch/v5 v5.9.0 // indirect
github.com/fsnotify/fsnotify v1.7.0 // indirect
github.com/go-kit/log v0.2.1 // indirect
Expand All @@ -59,6 +61,7 @@ require (
github.com/hashicorp/golang-lru v1.0.2 // indirect
github.com/imdario/mergo v0.3.16 // indirect
github.com/inconshreveable/mousetrap v1.1.0 // indirect
github.com/jmespath/go-jmespath v0.4.0 // indirect
github.com/josharian/intern v1.0.0 // indirect
github.com/json-iterator/go v1.1.12 // indirect
github.com/kelseyhightower/envconfig v1.4.0 // indirect
Expand All @@ -70,7 +73,7 @@ require (
github.com/pkg/errors v0.9.1 // indirect
github.com/pmezard/go-difflib v1.0.0 // indirect
github.com/prometheus/client_golang v1.19.1 // indirect
github.com/prometheus/client_model v0.6.0 // indirect
github.com/prometheus/client_model v0.6.1 // indirect
github.com/prometheus/common v0.53.0 // indirect
github.com/prometheus/procfs v0.12.0 // indirect
github.com/prometheus/statsd_exporter v0.24.0 // indirect
Expand Down
20 changes: 16 additions & 4 deletions go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -109,8 +109,14 @@ github.com/alecthomas/units v0.0.0-20211218093645-b94a6e3cc137/go.mod h1:OMCwj8V
github.com/antihax/optional v1.0.0/go.mod h1:uupD/76wgC+ih3iEmQUL+0Ugr19nfwCT1kdvxnR2qWY=
github.com/avast/retry-go v3.0.0+incompatible h1:4SOWQ7Qs+oroOTQOYnAHqelpCO0biHSxpiH9JdtuBj0=
github.com/avast/retry-go v3.0.0+incompatible/go.mod h1:XtSnn+n/sHqQIpZ10K1qAevBhOOCWBLXXy3hyiqqBrY=
github.com/aws/aws-sdk-go v1.51.16 h1:vnWKK8KjbftEkuPX8bRj3WHsLy1uhotn0eXptpvrxJI=
github.com/aws/aws-sdk-go v1.51.16/go.mod h1:LF8svs817+Nz+DmiMQKTO3ubZ/6IaTpq3TjupRn3Eqk=
github.com/aws/karpenter-core v0.29.2 h1:iS8bjC1911LA459gLEl7Jkr0QRbyKMeXB2b4NEVGQIE=
github.com/aws/karpenter-core v0.29.2/go.mod h1:GzFITbd2ijUiV4UJ0wox4RJQsFD2ncyJYtLmUlYnmJY=
github.com/aws/karpenter-provider-aws v0.36.2 h1:4JEK2OMLDOkNthITDyngbvFo2FZRd8JJFQuDLQoGc9s=
github.com/aws/karpenter-provider-aws v0.36.2/go.mod h1:sLDYiuoQr4PPTE9c3ZwFtVCTz6my+bjxIiO5SF5/M1A=
github.com/awslabs/amazon-eks-ami/nodeadm v0.0.0-20240229193347-cfab22a10647 h1:8yRBVsjGmI7qQsPWtIrbWP+XfwHO9Wq7gdLVzjqiZFs=
github.com/awslabs/amazon-eks-ami/nodeadm v0.0.0-20240229193347-cfab22a10647/go.mod h1:9NafTAUHL0FlMeL6Cu5PXnMZ1q/LnC9X2emLXHsVbM8=
github.com/beorn7/perks v0.0.0-20180321164747-3a771d992973/go.mod h1:Dwedo/Wpr24TaqPxmxbtue+5NUziq4I4S80YR8gNf3Q=
github.com/beorn7/perks v1.0.0/go.mod h1:KWe93zE9D1o94FZ5RNwFwVgaQK1VOXiVxmqh+CedLV8=
github.com/beorn7/perks v1.0.1 h1:VlbKKnNfV8bJzeqoa4cOKqO6bYr3WgKZxO8Z16+hsOM=
Expand Down Expand Up @@ -142,8 +148,8 @@ github.com/envoyproxy/go-control-plane v0.9.0/go.mod h1:YTl/9mNaCwkRvm6d1a2C3ymF
github.com/envoyproxy/go-control-plane v0.9.1-0.20191026205805-5f8ba28d4473/go.mod h1:YTl/9mNaCwkRvm6d1a2C3ymFceY/DCBVvsKhRF0iEA4=
github.com/envoyproxy/go-control-plane v0.9.4/go.mod h1:6rpuAdCZL397s3pYoYcLgu1mIlRU8Am5FuJP05cCM98=
github.com/envoyproxy/protoc-gen-validate v0.1.0/go.mod h1:iSmxcyjqTsJpI2R4NaDN7+kN2VEUnK/pcBlmesArF7c=
github.com/evanphx/json-patch v4.12.0+incompatible h1:4onqiflcdA9EOZ4RxV643DvftH5pOlLGNtQ5lPWQu84=
github.com/evanphx/json-patch v4.12.0+incompatible/go.mod h1:50XU6AFN0ol/bzJsmQLiYLvXMP4fmwYFNcr97nuDLSk=
github.com/evanphx/json-patch v5.7.0+incompatible h1:vgGkfT/9f8zE6tvSCe74nfpAVDQ2tG6yudJd8LBksgI=
github.com/evanphx/json-patch v5.7.0+incompatible/go.mod h1:50XU6AFN0ol/bzJsmQLiYLvXMP4fmwYFNcr97nuDLSk=
github.com/evanphx/json-patch/v5 v5.9.0 h1:kcBlZQbplgElYIlo/n1hJbls2z/1awpXxpRi0/FOJfg=
github.com/evanphx/json-patch/v5 v5.9.0/go.mod h1:VNkHZ/282BpEyt/tObQO8s5CMPmYYq14uClGH4abBuQ=
github.com/felixge/httpsnoop v1.0.4 h1:NFTV2Zj1bL4mc9sqWACXbQFVBBg2W3GPvqp8/ESS2Wg=
Expand Down Expand Up @@ -283,6 +289,10 @@ github.com/imdario/mergo v0.3.16 h1:wwQJbIsHYGMUyLSPrEq1CT16AhnhNJQ51+4fdHUnCl4=
github.com/imdario/mergo v0.3.16/go.mod h1:WBLT9ZmE3lPoWsEzCh9LPo3TiwVN+ZKEjmz+hD27ysY=
github.com/inconshreveable/mousetrap v1.1.0 h1:wN+x4NVGpMsO7ErUn/mUI3vEoE6Jt13X2s0bqwp9tc8=
github.com/inconshreveable/mousetrap v1.1.0/go.mod h1:vpF70FUmC8bwa3OWnCshd2FqLfsEA9PFc4w1p2J65bw=
github.com/jmespath/go-jmespath v0.4.0 h1:BEgLn5cpjn8UN1mAw4NjwDrS35OdebyEtFe+9YPoQUg=
github.com/jmespath/go-jmespath v0.4.0/go.mod h1:T8mJZnbsbmF+m6zOOFylbeCJqk5+pHWvzYPziyZiYoo=
github.com/jmespath/go-jmespath/internal/testify v1.5.1 h1:shLQSRRSCCPj3f2gpwzGwWFoC7ycTf1rcQZHOlsJ6N8=
github.com/jmespath/go-jmespath/internal/testify v1.5.1/go.mod h1:L3OGu8Wl2/fWfCI6z80xFu9LTZmf1ZRjMHUOPmWr69U=
github.com/jongio/azidext/go/azidext v0.5.0 h1:uPInXD4NZ3J0k79FPwIA0YXknFn+WcqZqSgs3/jPgvQ=
github.com/jongio/azidext/go/azidext v0.5.0/go.mod h1:TVRX/hJhzbsCKaOIzicH6a8IvOH0hpjWk/JwZZgtXeU=
github.com/josharian/intern v1.0.0 h1:vlS4z54oSdjm0bgjRigI+G1HpF+tI+9rE5LLzOg8HmY=
Expand Down Expand Up @@ -338,6 +348,8 @@ github.com/onsi/gomega v1.33.1 h1:dsYjIxxSR755MDmKVsaFQTE22ChNBcuuTWgkUDSubOk=
github.com/onsi/gomega v1.33.1/go.mod h1:U4R44UsT+9eLIaYRB2a5qajjtQYn0hauxvRm16AVYg0=
github.com/patrickmn/go-cache v2.1.0+incompatible h1:HRMgzkcYKYpi3C8ajMPV8OFXaaRUnok+kx1WdO15EQc=
github.com/patrickmn/go-cache v2.1.0+incompatible/go.mod h1:3Qf8kWWT7OJRJbdiICTKqZju1ZixQ/KpMGzzAfe6+WQ=
github.com/pelletier/go-toml/v2 v2.2.0 h1:QLgLl2yMN7N+ruc31VynXs1vhMZa7CeHHejIeBAsoHo=
github.com/pelletier/go-toml/v2 v2.2.0/go.mod h1:1t835xjRzz80PqgE6HHgN2JOsmgYu/h4qDAS4n929Rs=
github.com/pkg/browser v0.0.0-20240102092130-5ac0b6a4141c h1:+mdjkGKdHQG3305AYmdv1U2eRNDiU2ErMBj1gwrq8eQ=
github.com/pkg/browser v0.0.0-20240102092130-5ac0b6a4141c/go.mod h1:7rwL4CYBLnjLxUqIJNnCWiEdr3bn6IUYi15bNlnbCCU=
github.com/pkg/errors v0.8.0/go.mod h1:bwawxfHBFNV+L2hUp1rHADufV3IMtnDRdf1r5NINEl0=
Expand All @@ -361,8 +373,8 @@ github.com/prometheus/client_model v0.0.0-20180712105110-5c3871d89910/go.mod h1:
github.com/prometheus/client_model v0.0.0-20190129233127-fd36f4220a90/go.mod h1:xMI15A0UPsDsEKsMN9yxemIoYk6Tm2C1GtYGdfGttqA=
github.com/prometheus/client_model v0.0.0-20190812154241-14fe0d1b01d4/go.mod h1:xMI15A0UPsDsEKsMN9yxemIoYk6Tm2C1GtYGdfGttqA=
github.com/prometheus/client_model v0.2.0/go.mod h1:xMI15A0UPsDsEKsMN9yxemIoYk6Tm2C1GtYGdfGttqA=
github.com/prometheus/client_model v0.6.0 h1:k1v3CzpSRUTrKMppY35TLwPvxHqBu0bYgxZzqGIgaos=
github.com/prometheus/client_model v0.6.0/go.mod h1:NTQHnmxFpouOD0DpvP4XujX3CdOAGQPoaGhyTchlyt8=
github.com/prometheus/client_model v0.6.1 h1:ZKSh/rekM+n3CeS952MLRAdFwIKqeY8b62p8ais2e9E=
github.com/prometheus/client_model v0.6.1/go.mod h1:OrxVMOVHjw3lKMa8+x6HeMGkHMQyHDk9E3jmP2AmGiY=
github.com/prometheus/common v0.4.1/go.mod h1:TNfzLD0ON7rHzMJeJkieUDPYmFC7Snx/y86RQel1bk4=
github.com/prometheus/common v0.10.0/go.mod h1:Tlit/dnDKsSWFlCLTWaA1cyBgKHSMdTB80sz/V91rCo=
github.com/prometheus/common v0.26.0/go.mod h1:M7rCNAaPfAosfx8veZJCuw84e35h3Cfd9VFqTh1DIvc=
Expand Down
16 changes: 12 additions & 4 deletions pkg/controllers/workspace_controller.go
Original file line number Diff line number Diff line change
Expand Up @@ -457,10 +457,18 @@ func (c *WorkspaceReconciler) ensureNodePlugins(ctx context.Context, wObj *kaito
if err := resources.UpdateNodeWithLabel(ctx, nodeObj.Name, resources.LabelKeyNvidia, resources.LabelValueNvidia, c.Client); err != nil {
if apierrors.IsNotFound(err) {
klog.ErrorS(err, "nvidia plugin cannot be installed, node not found", "node", nodeObj.Name)
if updateErr := c.updateStatusConditionIfNotMatch(ctx, wObj, kaitov1alpha1.WorkspaceConditionTypeMachineStatus, metav1.ConditionFalse,
"checkMachineStatusFailed", err.Error()); updateErr != nil {
klog.ErrorS(updateErr, "failed to update workspace status", "workspace", klog.KObj(wObj))
return updateErr
if featuregates.FeatureGates[consts.FeatureFlagKarpenter] {
if updateErr := c.updateStatusConditionIfNotMatch(ctx, wObj, kaitov1alpha1.WorkspaceConditionTypeNodeClaimStatus, metav1.ConditionFalse,
"checkNodeClaimStatusFailed", err.Error()); updateErr != nil {
klog.ErrorS(updateErr, "failed to update workspace status", "workspace", klog.KObj(wObj))
return updateErr
}
} else {
if updateErr := c.updateStatusConditionIfNotMatch(ctx, wObj, kaitov1alpha1.WorkspaceConditionTypeMachineStatus, metav1.ConditionFalse,
"checkMachineStatusFailed", err.Error()); updateErr != nil {
klog.ErrorS(updateErr, "failed to update workspace status", "workspace", klog.KObj(wObj))
return updateErr
}
}
return err
}
Expand Down
39 changes: 33 additions & 6 deletions pkg/controllers/workspace_controller_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -6,17 +6,19 @@ package controllers
import (
"context"
"errors"
"os"
"reflect"
"sort"
"testing"
"time"

azurev1alpha2 "github.com/Azure/karpenter-provider-azure/pkg/apis/v1alpha2"
"github.com/aws/karpenter-core/pkg/apis/v1alpha5"
awsv1beta1 "github.com/aws/karpenter-provider-aws/pkg/apis/v1beta1"
"github.com/azure/kaito/api/v1alpha1"
"github.com/azure/kaito/pkg/featuregates"
"github.com/azure/kaito/pkg/machine"
"github.com/azure/kaito/pkg/nodeclaim"
"github.com/azure/kaito/pkg/utils"
"github.com/azure/kaito/pkg/utils/consts"
"github.com/azure/kaito/pkg/utils/test"
"github.com/stretchr/testify/mock"
Expand Down Expand Up @@ -171,7 +173,7 @@ func TestSelectWorkspaceNodes(t *testing.T) {
ObjectMeta: v1.ObjectMeta{
Name: "node3",
Labels: map[string]string{
machine.LabelGPUProvisionerCustom: utils.GPUString,
machine.LabelGPUProvisionerCustom: consts.GPUString,
},
},
},
Expand All @@ -197,7 +199,7 @@ func TestSelectWorkspaceNodes(t *testing.T) {
ObjectMeta: v1.ObjectMeta{
Name: "node3",
Labels: map[string]string{
machine.LabelGPUProvisionerCustom: utils.GPUString,
machine.LabelGPUProvisionerCustom: consts.GPUString,
},
},
},
Expand All @@ -223,7 +225,7 @@ func TestSelectWorkspaceNodes(t *testing.T) {
ObjectMeta: v1.ObjectMeta{
Name: "node3",
Labels: map[string]string{
machine.LabelGPUProvisionerCustom: utils.GPUString,
machine.LabelGPUProvisionerCustom: consts.GPUString,
},
},
},
Expand Down Expand Up @@ -253,7 +255,7 @@ func TestSelectWorkspaceNodes(t *testing.T) {
ObjectMeta: v1.ObjectMeta{
Name: "node3",
Labels: map[string]string{
machine.LabelGPUProvisionerCustom: utils.GPUString,
machine.LabelGPUProvisionerCustom: consts.GPUString,
},
},
},
Expand Down Expand Up @@ -359,11 +361,31 @@ func TestCreateAndValidateMachineNode(t *testing.T) {
workspace: *test.MockWorkspaceDistributedModel,
expectedError: nil,
},
"A nodeClaim is successfully created": {
"An Azure nodeClaim is successfully created": {
callMocks: func(c *test.MockClient) {
c.On("Create", mock.IsType(context.Background()), mock.IsType(&azurev1alpha2.AKSNodeClass{}), mock.Anything).Return(nil)
c.On("Create", mock.IsType(context.Background()), mock.IsType(&v1beta1.NodeClaim{}), mock.Anything).Return(nil)
c.On("Get", mock.IsType(context.Background()), mock.Anything, mock.IsType(&v1beta1.NodeClaim{}), mock.Anything).Return(nil)
c.On("Get", mock.IsType(context.Background()), mock.Anything, mock.IsType(&corev1.Node{}), mock.Anything).Return(nil)
os.Setenv("CLOUD_PROVIDER", consts.AzureCloudName)
},
objectConditions: apis.Conditions{
{
Type: apis.ConditionReady,
Status: corev1.ConditionTrue,
},
},
workspace: *test.MockWorkspaceDistributedModel,
karpenterFeatureGates: true,
expectedError: nil,
},
"An AWS nodeClaim is successfully created": {
callMocks: func(c *test.MockClient) {
c.On("Create", mock.IsType(context.Background()), mock.IsType(&awsv1beta1.EC2NodeClass{}), mock.Anything).Return(nil)
c.On("Create", mock.IsType(context.Background()), mock.IsType(&v1beta1.NodeClaim{}), mock.Anything).Return(nil)
c.On("Get", mock.IsType(context.Background()), mock.Anything, mock.IsType(&v1beta1.NodeClaim{}), mock.Anything).Return(nil)
c.On("Get", mock.IsType(context.Background()), mock.Anything, mock.IsType(&corev1.Node{}), mock.Anything).Return(nil)
os.Setenv("CLOUD_PROVIDER", "aws")
},
objectConditions: apis.Conditions{
{
Expand All @@ -377,10 +399,12 @@ func TestCreateAndValidateMachineNode(t *testing.T) {
},
"Node is not created because nodeClaim creation fails": {
callMocks: func(c *test.MockClient) {
c.On("Create", mock.IsType(context.Background()), mock.IsType(&azurev1alpha2.AKSNodeClass{}), mock.Anything).Return(nil)
c.On("Create", mock.IsType(context.Background()), mock.IsType(&v1beta1.NodeClaim{}), mock.Anything).Return(nil)
c.On("Get", mock.IsType(context.Background()), mock.Anything, mock.IsType(&v1beta1.NodeClaim{}), mock.Anything).Return(nil)
c.On("Get", mock.IsType(context.Background()), mock.Anything, mock.IsType(&v1alpha1.Workspace{}), mock.Anything).Return(nil)
c.StatusMock.On("Update", mock.IsType(context.Background()), mock.IsType(&v1alpha1.Workspace{}), mock.Anything).Return(nil)
os.Setenv("CLOUD_PROVIDER", consts.AzureCloudName)
},
objectConditions: apis.Conditions{
{
Expand Down Expand Up @@ -444,10 +468,12 @@ func TestCreateAndValidateNodeClaimNode(t *testing.T) {
}{
"Node is not created because nodeClaim creation fails": {
callMocks: func(c *test.MockClient) {
c.On("Create", mock.IsType(context.Background()), mock.IsType(&azurev1alpha2.AKSNodeClass{}), mock.Anything).Return(nil)
c.On("Create", mock.IsType(context.Background()), mock.IsType(&v1beta1.NodeClaim{}), mock.Anything).Return(nil)
c.On("Get", mock.IsType(context.Background()), mock.Anything, mock.IsType(&v1beta1.NodeClaim{}), mock.Anything).Return(nil)
c.On("Get", mock.IsType(context.Background()), mock.Anything, mock.IsType(&v1alpha1.Workspace{}), mock.Anything).Return(nil)
c.StatusMock.On("Update", mock.IsType(context.Background()), mock.IsType(&v1alpha1.Workspace{}), mock.Anything).Return(nil)
os.Setenv("CLOUD_PROVIDER", consts.AzureCloudName)
},
karpenterFeatureGates: true,
nodeClaimConditions: apis.Conditions{
Expand All @@ -462,6 +488,7 @@ func TestCreateAndValidateNodeClaimNode(t *testing.T) {
},
"A nodeClaim is successfully created": {
callMocks: func(c *test.MockClient) {
c.On("Create", mock.IsType(context.Background()), mock.IsType(&azurev1alpha2.AKSNodeClass{}), mock.Anything).Return(nil)
c.On("Create", mock.IsType(context.Background()), mock.IsType(&v1beta1.NodeClaim{}), mock.Anything).Return(nil)
c.On("Get", mock.IsType(context.Background()), mock.Anything, mock.IsType(&v1beta1.NodeClaim{}), mock.Anything).Return(nil)
c.On("Get", mock.IsType(context.Background()), mock.Anything, mock.IsType(&corev1.Node{}), mock.Anything).Return(nil)
Expand Down
5 changes: 3 additions & 2 deletions pkg/inference/preset-inferences.go
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ import (
"strconv"

"github.com/azure/kaito/pkg/utils"
"github.com/azure/kaito/pkg/utils/consts"

kaitov1alpha1 "github.com/azure/kaito/api/v1alpha1"
"github.com/azure/kaito/pkg/model"
Expand Down Expand Up @@ -62,8 +63,8 @@ var (
},
{
Effect: corev1.TaintEffectNoSchedule,
Value: utils.GPUString,
Key: utils.SKUString,
Value: consts.GPUString,
Key: consts.SKUString,
Operator: corev1.TolerationOpEqual,
},
}
Expand Down
8 changes: 4 additions & 4 deletions pkg/machine/machine.go
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ import (

"github.com/aws/karpenter-core/pkg/apis/v1alpha5"
kaitov1alpha1 "github.com/azure/kaito/api/v1alpha1"
"github.com/azure/kaito/pkg/utils"
"github.com/azure/kaito/pkg/utils/consts"
"github.com/samber/lo"
v1 "k8s.io/api/core/v1"
"k8s.io/apimachinery/pkg/api/resource"
Expand Down Expand Up @@ -76,7 +76,7 @@ func GenerateMachineManifest(ctx context.Context, storageRequirement string, wor
{
Key: LabelGPUProvisionerCustom,
Operator: v1.NodeSelectorOpIn,
Values: []string{utils.GPUString},
Values: []string{consts.GPUString},
},
{
Key: v1.LabelArchStable,
Expand All @@ -91,8 +91,8 @@ func GenerateMachineManifest(ctx context.Context, storageRequirement string, wor
},
Taints: []v1.Taint{
{
Key: utils.SKUString,
Value: utils.GPUString,
Key: consts.SKUString,
Value: consts.GPUString,
Effect: v1.TaintEffectNoSchedule,
},
},
Expand Down
Loading

0 comments on commit 531207e

Please sign in to comment.