dashboard icon indicating copy to clipboard operation
dashboard copied to clipboard

fix: preserve message format when resource is not ready

Open enneitex opened this issue 4 weeks ago • 3 comments

Summary

Fixes https://github.com/rancher/dashboard/issues/16110 Fix the way messages are displayed in the list view when a resource is unavailable. This preserves the format, similar to what is shown in the detail view or with kubectl

Occurred changes and/or fixed issues

Technical notes summary

Areas or cases that should be tested

To reproduce, create a CRD and a few custom resources:

apiVersion: apiextensions.k8s.io/v1
kind: CustomResourceDefinition
metadata:
  name: shirts.stable.example.com
spec:
  group: stable.example.com
  scope: Namespaced
  names:
    plural: shirts
    singular: shirt
    kind: Shirt
  versions:
  - name: v1
    served: true
    storage: true
    schema:
      openAPIV3Schema:
        type: object
        properties:
          spec:
            type: object
            properties:
              color:
                type: string
              size:
                type: string
          status:
            type: object
            properties:
              conditions:
                type: array
                items:
                  type: object
                  properties:
                    type:
                      type: string
                    status:
                      type: string
                    reason:
                      type: string
                    message:
                      type: string
                    lastTransitionTime:
                      type: string
                      format: date-time
    subresources:
      status: {}
    selectableFields:
    - jsonPath: .spec.color
    - jsonPath: .spec.size
    additionalPrinterColumns:
    - jsonPath: .spec.color
      name: Color
      type: string
    - jsonPath: .spec.size
      name: Size
      type: string
    - jsonPath: .status.conditions[?(@.type == "Ready")].status
      name: Ready
      type: string
    - jsonPath: .metadata.creationTimestamp
      name: Age
      type: date
---
apiVersion: stable.example.com/v1
kind: Shirt
metadata:
  name: my-shirt-1
spec:
  color: blue
  size: large
---
apiVersion: stable.example.com/v1
kind: Shirt
metadata:
  name: my-shirt-2
spec:
  color: red
  size: small
---
apiVersion: stable.example.com/v1
kind: Shirt
metadata:
  name: my-shirt-3
spec:
  color: dark
  size: medium
---
apiVersion: stable.example.com/v1
kind: Shirt
metadata:
  name: my-shirt-4
spec:
  color: yellow
  size: medium

Patch the resources to inject a status

kubectl patch shirt my-shirt-1 --type=merge --subresource=status -p '{
  "status": {
    "conditions": [{
      "type": "Ready",
      "status": "True",
      "reason": "Available",
      "message": "Shirt is ready",
      "lastTransitionTime": "2025-12-07T10:00:00Z"
    }]
  }
}'

kubectl patch shirt my-shirt-2 --type=merge --subresource=status -p '{
  "status": {
    "conditions": [{
      "type": "Ready",
      "status": "False",
      "reason": "ConfigurationError",
      "message": "Invalid size configuration",
      "lastTransitionTime": "2025-12-07T10:00:00Z"
    }]
  }
}'
kubectl patch shirt my-shirt-3 --type=merge --subresource=status -p '{
  "status": {
    "conditions": [{
      "type": "Ready",
      "status": "False",
      "reason": "ValidationFailed",
      "message": "Multiple errors detected:\n   - Color validation failed\n   - Size out of range\n   - Missing required labels",
      "lastTransitionTime": "2025-12-07T10:00:00Z"
    }]
  }
}'
kubectl patch shirt my-shirt-4 --type=merge --subresource=status -p '{
  "status": {
    "conditions": [{
      "type": "Ready",
      "status": "True",
      "reason": "Available",
      "message": "Shirt is ready",
      "lastTransitionTime": "2025-12-07T10:00:00Z"
    }]
  }
}'

Areas which could experience regressions

Screenshot/Video

Before: image

After: image

the after is similar to the detail view image

Checklist

  • [ ] The PR is linked to an issue and the linked issue has a Milestone, or no issue is needed
  • [ ] The PR has a Milestone
  • [ ] The PR template has been filled out
  • [ ] The PR has been self reviewed
  • [ ] The PR has a reviewer assigned
  • [ ] The PR has automated tests or clear instructions for manual tests and the linked issue has appropriate QA labels, or tests are not needed
  • [ ] The PR has reviewed with UX and tested in light and dark mode, or there are no UX changes
  • [ ] The PR has been reviewed in terms of Accessibility
  • [ ] The PR has considered, and if applicable tested with, the three Global Roles Admin, Standard User and User Base

enneitex avatar Dec 07 '25 15:12 enneitex

@enneitex can you create a gh issue and link it to this PR?

Dev side we need to test this with large messages (long strings, big objects), and if multi-line condition messages are officially supported

UX side we need to discuss if this is something worth the increase in vertical space (if there are 100 rows with similar errors that's an additional 300 lines of text)

richard-cox avatar Dec 08 '25 07:12 richard-cox

Hi, I created https://github.com/rancher/dashboard/pull/16106.

My use-case is a some CRDs with messages on a few lines, similar to what I tested in this PR.

I can add screenshot that cover more cases.

enneitex avatar Dec 08 '25 08:12 enneitex

Thanks @enneitex . I'll review your PR ASAP, the change looks pretty simple but I'm wondering how the messages from Steve API will look - we need to be careful not to increase the row's height to much

torchiaf avatar Dec 10 '25 09:12 torchiaf