Skip to content

Commit

Permalink
Minor changes pre-release
Browse files Browse the repository at this point in the history
* extend global services svc table columns
* fix cluster health chip
  • Loading branch information
michaeljguarino committed Dec 6, 2024
1 parent 437000b commit 772a292
Show file tree
Hide file tree
Showing 8 changed files with 49 additions and 14 deletions.
6 changes: 5 additions & 1 deletion assets/src/components/cd/clusters/ClusterHealthChip.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -26,16 +26,19 @@ export function ClusterHealth({

return (
<ClusterHealthChip
cluster={cluster}
pingedAt={cluster.pingedAt}
size={size}
/>
)
}

function ClusterHealthChip({
cluster,
pingedAt,
size = 'medium',
}: {
cluster?: ClustersRowFragment
pingedAt?: string | null
size?: 'small' | 'medium' | 'large'
}) {
Expand All @@ -49,7 +52,8 @@ function ClusterHealthChip({

const pinged = pingedAt !== null
const healthy =
pingedAt && now.clone().subtract(10, 'minutes').isBefore(pingedAt)
cluster?.healthy ||
(pingedAt && now.clone().subtract(10, 'minutes').isBefore(pingedAt))

return (
<TooltipTime
Expand Down
13 changes: 12 additions & 1 deletion assets/src/components/cd/globalServices/details/columns.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,9 @@ import DecoratedName from '../../services/DecoratedName.tsx'
import {
ColCluster,
ColLastActivity,
ColRef,
ColRepo,
ColErrors,
ColStatus,
} from '../../services/ServicesColumns.tsx'

Expand All @@ -31,4 +34,12 @@ const ColDeployment = columnHelper.accessor(({ node }) => node, {
},
})

export const columns = [ColDeployment, ColCluster, ColLastActivity, ColStatus]
export const columns = [
ColDeployment,
ColCluster,
ColRepo,
ColRef,
ColLastActivity,
ColStatus,
ColErrors,
]
27 changes: 15 additions & 12 deletions assets/src/generated/graphql.ts

Large diffs are not rendered by default.

1 change: 1 addition & 0 deletions assets/src/graph/cdClusters.graphql
Original file line number Diff line number Diff line change
Expand Up @@ -171,6 +171,7 @@ fragment ClustersRow on Cluster {
currentVersion
id
self
healthy
protect
name
handle
Expand Down
2 changes: 2 additions & 0 deletions go/client/models_gen.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 4 additions & 0 deletions lib/console/graphql/deployments/cluster.ex
Original file line number Diff line number Diff line change
Expand Up @@ -302,6 +302,10 @@ defmodule Console.GraphQl.Deployments.Cluster do
field :settings, :cloud_settings, description: "the cloud settings for this cluster (for instance its aws region)"
field :upgrade_plan, :cluster_upgrade_plan, description: "Checklist of tasks to complete to safely upgrade this cluster"

field :healthy, :boolean, description: "Whether this cluster was recently pinged", resolve: fn
cluster, _, _ -> {:ok, Cluster.healthy?(cluster)}
end

field :kas_url, :string, description: "the url of the kas server you can access this cluster from", resolve: fn
_, _, _ -> {:ok, Console.Deployments.Clusters.kas_proxy_url()}
end
Expand Down
7 changes: 7 additions & 0 deletions lib/console/schema/cluster.ex
Original file line number Diff line number Diff line change
Expand Up @@ -144,6 +144,13 @@ defmodule Console.Schema.Cluster do
timestamps()
end

def healthy?(%__MODULE__{pinged_at: nil}), do: false
def healthy?(%__MODULE__{pinged_at: pinged}) do
Timex.now()
|> Timex.shift(minutes: -20)
|> Timex.before?(pinged)
end

defp upgrade_plan_fields(), do: __MODULE__.UpgradePlan.__schema__(:fields) -- [:id]

def search(query \\ __MODULE__, sq) do
Expand Down
3 changes: 3 additions & 0 deletions schema/schema.graphql
Original file line number Diff line number Diff line change
Expand Up @@ -4622,6 +4622,9 @@ type Cluster {
"Checklist of tasks to complete to safely upgrade this cluster"
upgradePlan: ClusterUpgradePlan

"Whether this cluster was recently pinged"
healthy: Boolean

"the url of the kas server you can access this cluster from"
kasUrl: String

Expand Down

0 comments on commit 772a292

Please sign in to comment.