Skip to content

Commit

Permalink
fix: cherry picking appeng fixes for 2.18 (#367)
Browse files Browse the repository at this point in the history
* fix: added accept header to nim manifest pull requests accepting oci (#362)

* fix: added accept header to nim manifest pull requests accepting oci

Signed-off-by: Tomer Figenblat <[email protected]>

* chore: removed left-over debugging message

Signed-off-by: Tomer Figenblat <[email protected]>

---------

Signed-off-by: Tomer Figenblat <[email protected]>
(cherry picked from commit f7fdf0a)

* Fix: Ensure odh-model-controller Deployment Waits for ConfigMap (#361)

* initial commit to fix NIM and deployment issues

Signed-off-by: Marcus Trujillo <[email protected]>

* update to set default on nimState

Signed-off-by: Marcus Trujillo <[email protected]>

* updated optinal to false

Signed-off-by: Marcus Trujillo <[email protected]>

---------

Signed-off-by: Marcus Trujillo <[email protected]>
(cherry picked from commit 7806732)

* fix: nim containers terminated prematurely (#363)

Signed-off-by: Tomer Figenblat <[email protected]>
Co-authored-by: Mikhail Mikhailitchenko <[email protected]>
(cherry picked from commit c92b19f)

* chore: added gocyclo no linting comment on the main function

Signed-off-by: Tomer Figenblat <[email protected]>

---------

Signed-off-by: Tomer Figenblat <[email protected]>
Co-authored-by: Marcus Trujillo <[email protected]>
  • Loading branch information
TomerFi and trujillm authored Feb 7, 2025
1 parent 7307576 commit e705bf9
Show file tree
Hide file tree
Showing 4 changed files with 14 additions and 7 deletions.
7 changes: 5 additions & 2 deletions cmd/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,6 @@ import (
"crypto/tls"
"flag"
"os"
"slices"
"strconv"

// Import all Kubernetes client auth plugins (e.g. Azure, GCP, OIDC, etc.)
Expand Down Expand Up @@ -78,6 +77,7 @@ func getEnvAsBool(name string, defaultValue bool) bool {
return defaultValue
}

// nolint:gocyclo
func main() {
var metricsAddr string
var enableLeaderElection bool
Expand Down Expand Up @@ -244,7 +244,10 @@ func main() {

nimState := os.Getenv("NIM_STATE")
signalHandlerCtx := ctrl.SetupSignalHandler()
if !slices.Contains([]string{"removed", ""}, nimState) {
if nimState == "" {
nimState = "managed"
}
if nimState != "removed" {
if err = (&nim.AccountReconciler{
Client: mgr.GetClient(),
Scheme: mgr.GetScheme(),
Expand Down
2 changes: 1 addition & 1 deletion config/manager/manager.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -105,7 +105,7 @@ spec:
configMapKeyRef:
name: odh-model-controller-parameters
key: nim-state
optional: true
optional: false
livenessProbe:
httpGet:
path: /healthz
Expand Down
6 changes: 4 additions & 2 deletions internal/controller/testdata/nvidia_api_mock.go
Original file line number Diff line number Diff line change
Expand Up @@ -70,8 +70,10 @@ func (r *NimHttpClientMock) Do(req *http.Request) (*http.Response, error) {
// check testdata/ngc_catalog_response_page_0.json
authHeaderParts := strings.Split(req.Header.Get("Authorization"), " ")
if authHeaderParts[0] == "Bearer" && authHeaderParts[1] == "this-is-my-fake-token-please-dont-share-it-with-anyone" {
// the token is returned by the nvcr.io/proxy-auth endpoint (stubbed), check testdata/runtime_token_response.json
return &http.Response{StatusCode: 200}, nil
if req.Header.Get("Accept") == "application/vnd.oci.image.index.v1+json" {
// the token is returned by the nvcr.io/proxy-auth endpoint (stubbed), check testdata/runtime_token_response.json
return &http.Response{StatusCode: 200}, nil
}
}
}

Expand Down
6 changes: 4 additions & 2 deletions internal/controller/utils/nim.go
Original file line number Diff line number Diff line change
Expand Up @@ -273,6 +273,7 @@ func attemptToPullManifest(runtime NimRuntime, tokenResp *NimTokenResponse) erro
}

req.Header.Add("Authorization", fmt.Sprintf("Bearer %s", tokenResp.Token))
req.Header.Add("Accept", "application/vnd.oci.image.index.v1+json")

resp, respErr := NimHttpClient.Do(req)
if respErr != nil {
Expand Down Expand Up @@ -331,8 +332,9 @@ func GetNimServingRuntimeTemplate(scheme *runtime.Scheme) (*v1alpha1.ServingRunt
Spec: v1alpha1.ServingRuntimeSpec{
ServingRuntimePodSpec: v1alpha1.ServingRuntimePodSpec{
Annotations: map[string]string{
"prometheus.io/path": "/metrics",
"prometheus.io/port": "8000",
"prometheus.io/path": "/metrics",
"prometheus.io/port": "8000",
"serving.knative.dev/progress-deadline": "30m",
},
Containers: []corev1.Container{
{Env: []corev1.EnvVar{
Expand Down

0 comments on commit e705bf9

Please sign in to comment.