Skip to content

Commit 728ed5f

Browse files
Use LLS version endpoint in Status (#110)
This commit introduces changes to set LLS version using endpoint `/v1/version` Resolves #86 #### Testing Resultant Status - <img width="1072" height="91" alt="Screenshot 2025-07-16 at 22 58 37" src="https://github.com/user-attachments/assets/0ae0a1f8-f6c3-4734-9a17-f2a0b90df01b" /> Approved-by: leseb
1 parent 040f557 commit 728ed5f

File tree

7 files changed

+55
-15
lines changed

7 files changed

+55
-15
lines changed

Makefile

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -433,7 +433,6 @@ release: yq kustomize yamlfmt ## Prepare release files with VERSION and LLAMASTA
433433
# Update environment variables in manager.yaml and format with our preferred YAML style
434434
# using YQ because Kustomize doesn't support setting environment variables
435435
$(call yq-fmt,'(select(.kind == "Deployment") | .spec.template.spec.containers[].env[] | select(.name == "OPERATOR_VERSION") | .value) = "$(VERSION)"',config/manager/manager.yaml)
436-
$(call yq-fmt,'(select(.kind == "Deployment") | .spec.template.spec.containers[].env[] | select(.name == "LLAMA_STACK_VERSION") | .value) = "$(LLAMASTACK_VERSION)"',config/manager/manager.yaml)
437436

438437
# Generate manifests and build installer
439438
$(MAKE) manifests generate

api/v1alpha1/llamastackdistribution_types.go

Lines changed: 2 additions & 2 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

config/crd/bases/llamastack.io_llamastackdistributions.yaml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2155,8 +2155,8 @@ spec:
21552155
format: date-time
21562156
type: string
21572157
llamaStackServerVersion:
2158-
description: DeploymentVersion is the version of the LlamaStack
2159-
deployment
2158+
description: LlamaStackServerVersion is the version of the LlamaStack
2159+
server
21602160
type: string
21612161
operatorVersion:
21622162
description: OperatorVersion is the version of the operator managing

config/manager/manager.yaml

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -41,8 +41,6 @@ spec:
4141
env:
4242
- name: OPERATOR_VERSION
4343
value: "latest"
44-
- name: LLAMA_STACK_VERSION
45-
value: "latest"
4644
image: controller:latest
4745
name: manager
4846
securityContext:

controllers/llamastackdistribution_controller.go

Lines changed: 48 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -758,6 +758,44 @@ func (r *LlamaStackDistributionReconciler) getProviderInfo(ctx context.Context,
758758
return response.Data, nil
759759
}
760760

761+
// getVersionInfo makes an HTTP request to the version endpoint.
762+
func (r *LlamaStackDistributionReconciler) getVersionInfo(ctx context.Context, instance *llamav1alpha1.LlamaStackDistribution) (string, error) {
763+
u := r.getServerURL(instance, "/v1/version")
764+
765+
client := &http.Client{
766+
Timeout: 5 * time.Second,
767+
}
768+
769+
req, err := http.NewRequestWithContext(ctx, http.MethodGet, u.String(), nil)
770+
if err != nil {
771+
return "", fmt.Errorf("failed to create version request: %w", err)
772+
}
773+
774+
resp, err := client.Do(req)
775+
if err != nil {
776+
return "", fmt.Errorf("failed to make version request: %w", err)
777+
}
778+
defer resp.Body.Close()
779+
780+
if resp.StatusCode != http.StatusOK {
781+
return "", fmt.Errorf("failed to query version endpoint: returned status code %d", resp.StatusCode)
782+
}
783+
784+
body, err := io.ReadAll(resp.Body)
785+
if err != nil {
786+
return "", fmt.Errorf("failed to read version response: %w", err)
787+
}
788+
789+
var response struct {
790+
Version string `json:"version"`
791+
}
792+
if err := json.Unmarshal(body, &response); err != nil {
793+
return "", fmt.Errorf("failed to unmarshal version response: %w", err)
794+
}
795+
796+
return response.Version, nil
797+
}
798+
761799
// updateStatus refreshes the LlamaStack status.
762800
func (r *LlamaStackDistributionReconciler) updateStatus(ctx context.Context, instance *llamav1alpha1.LlamaStackDistribution, reconcileErr error) error {
763801
// Initialize OperatorVersion if not set
@@ -826,9 +864,6 @@ func (r *LlamaStackDistributionReconciler) updateDeploymentStatus(ctx context.Co
826864
instance.Status.Phase = llamav1alpha1.LlamaStackDistributionPhaseReady
827865
deploymentReady = true
828866
SetDeploymentReadyCondition(&instance.Status, true, MessageDeploymentReady)
829-
if instance.Status.Version.LlamaStackVersion == "" {
830-
instance.Status.Version.LlamaStackVersion = os.Getenv("LLAMA_STACK_VERSION")
831-
}
832867
}
833868
instance.Status.AvailableReplicas = deployment.Status.ReadyReplicas
834869
return deploymentReady, nil
@@ -904,6 +939,16 @@ func (r *LlamaStackDistributionReconciler) performHealthChecks(ctx context.Conte
904939
} else {
905940
instance.Status.DistributionConfig.Providers = providers
906941
}
942+
943+
// Get version information from the API endpoint
944+
version, err := r.getVersionInfo(ctx, instance)
945+
if err != nil {
946+
logger.Error(err, "failed to get version info from API endpoint")
947+
// Don't clear the version if we cant fetch it - keep the existing one
948+
} else {
949+
instance.Status.Version.LlamaStackServerVersion = version
950+
logger.V(1).Info("Updated LlamaStack version from API endpoint", "version", version)
951+
}
907952
}
908953

909954
// reconcileNetworkPolicy manages the NetworkPolicy for the LlamaStack server.

docs/api-overview.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -214,5 +214,5 @@ _Appears in:_
214214
| Field | Description | Default | Validation |
215215
| --- | --- | --- | --- |
216216
| `operatorVersion` _string_ | OperatorVersion is the version of the operator managing this distribution | | |
217-
| `llamaStackServerVersion` _string_ | DeploymentVersion is the version of the LlamaStack deployment | | |
217+
| `llamaStackServerVersion` _string_ | LlamaStackServerVersion is the version of the LlamaStack server | | |
218218
| `lastUpdated` _[Time](https://kubernetes.io/docs/reference/generated/kubernetes-api/v1.31/#time-v1-meta)_ | LastUpdated represents when the version information was last updated | | |

release/operator.yaml

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -2164,8 +2164,8 @@ spec:
21642164
format: date-time
21652165
type: string
21662166
llamaStackServerVersion:
2167-
description: DeploymentVersion is the version of the LlamaStack
2168-
deployment
2167+
description: LlamaStackServerVersion is the version of the LlamaStack
2168+
server
21692169
type: string
21702170
operatorVersion:
21712171
description: OperatorVersion is the version of the operator managing
@@ -2479,8 +2479,6 @@ spec:
24792479
env:
24802480
- name: OPERATOR_VERSION
24812481
value: latest
2482-
- name: LLAMA_STACK_VERSION
2483-
value: latest
24842482
image: quay.io/llamastack/llama-stack-k8s-operator:latest
24852483
livenessProbe:
24862484
httpGet:

0 commit comments

Comments
 (0)