Skip to content

Commit

Permalink
add upgrade insights client info and runtime services count (#1436)
Browse files Browse the repository at this point in the history
  • Loading branch information
michaeljguarino authored Oct 3, 2024
1 parent 37fe0ac commit c53158f
Show file tree
Hide file tree
Showing 8 changed files with 145 additions and 19 deletions.
19 changes: 18 additions & 1 deletion assets/src/generated/graphql-plural.ts
Original file line number Diff line number Diff line change
Expand Up @@ -385,6 +385,11 @@ export enum CloudProvider {
Aws = 'AWS'
}

export type CloudRegions = {
__typename?: 'CloudRegions';
aws?: Maybe<Array<Maybe<Scalars['String']['output']>>>;
};

export type CloudShell = {
__typename?: 'CloudShell';
aesKey: Scalars['String']['output'];
Expand Down Expand Up @@ -2208,6 +2213,17 @@ export type PlatformSubscriptionLineItems = {
quantity: Scalars['Int']['output'];
};

export type PluralCloudRegions = {
__typename?: 'PluralCloudRegions';
dedicated: CloudRegions;
shared: CloudRegions;
};

export type PluralCloudSettings = {
__typename?: 'PluralCloudSettings';
regions?: Maybe<PluralCloudRegions>;
};

export type PluralConfiguration = {
__typename?: 'PluralConfiguration';
gitCommit?: Maybe<Scalars['String']['output']>;
Expand Down Expand Up @@ -3408,7 +3424,7 @@ export type RootMutationTypeLinkPublisherArgs = {


export type RootMutationTypeLoginArgs = {
captcha?: InputMaybe<Scalars['String']['input']>;
captcha: Scalars['String']['input'];
deviceToken?: InputMaybe<Scalars['String']['input']>;
email: Scalars['String']['input'];
password: Scalars['String']['input'];
Expand Down Expand Up @@ -3733,6 +3749,7 @@ export type RootQueryType = {
charts?: Maybe<ChartConnection>;
chat?: Maybe<ChatMessage>;
closure?: Maybe<Array<Maybe<ClosureItem>>>;
cloudSettings?: Maybe<PluralCloudSettings>;
/** Get a cluster by its ID. */
cluster?: Maybe<Cluster>;
/** Get a list of clusters owned by the current account. */
Expand Down
21 changes: 21 additions & 0 deletions assets/src/generated/graphql.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2444,6 +2444,19 @@ export type IngressTls = {
hosts?: Maybe<Array<Maybe<Scalars['String']['output']>>>;
};

export type InsightClientInfo = {
__typename?: 'InsightClientInfo';
count?: Maybe<Scalars['String']['output']>;
lastRequestAt?: Maybe<Scalars['DateTime']['output']>;
userAgent?: Maybe<Scalars['String']['output']>;
};

export type InsightClientInfoAttributes = {
count?: InputMaybe<Scalars['String']['input']>;
lastRequestAt?: InputMaybe<Scalars['DateTime']['input']>;
userAgent?: InputMaybe<Scalars['String']['input']>;
};

export type Installation = {
__typename?: 'Installation';
id: Scalars['ID']['output'];
Expand Down Expand Up @@ -7040,6 +7053,8 @@ export type RuntimeService = {
addonVersion?: Maybe<AddonVersion>;
id: Scalars['ID']['output'];
insertedAt?: Maybe<Scalars['DateTime']['output']>;
/** the number of instances of this service we've detected */
instanceCount?: Maybe<Scalars['Int']['output']>;
/** add-on name */
name: Scalars['String']['output'];
/** the plural service it came from */
Expand All @@ -7050,6 +7065,8 @@ export type RuntimeService = {
};

export type RuntimeServiceAttributes = {
/** the number of instances of this service we've found */
instanceCount?: InputMaybe<Scalars['Int']['input']>;
name: Scalars['String']['input'];
version: Scalars['String']['input'];
};
Expand Down Expand Up @@ -8204,6 +8221,8 @@ export type UpgradeInsightAttributes = {

export type UpgradeInsightDetail = {
__typename?: 'UpgradeInsightDetail';
/** information about the HTTP clients triggering this insight */
clientInfo?: Maybe<Array<Maybe<InsightClientInfo>>>;
id: Scalars['ID']['output'];
insertedAt?: Maybe<Scalars['DateTime']['output']>;
lastUsedAt?: Maybe<Scalars['DateTime']['output']>;
Expand All @@ -8218,6 +8237,8 @@ export type UpgradeInsightDetail = {
};

export type UpgradeInsightDetailAttributes = {
/** descriptions of the HTTP clients triggering this insight */
clientInfo?: InputMaybe<Array<InputMaybe<InsightClientInfoAttributes>>>;
/** the latest timestamp this insight has been observed */
lastUsedAt?: InputMaybe<Scalars['DateTime']['input']>;
removedIn?: InputMaybe<Scalars['String']['input']>;
Expand Down
34 changes: 27 additions & 7 deletions go/client/models_gen.go

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

32 changes: 24 additions & 8 deletions lib/console/graphql/deployments/cluster.ex
Original file line number Diff line number Diff line change
Expand Up @@ -167,8 +167,9 @@ defmodule Console.GraphQl.Deployments.Cluster do
end

input_object :runtime_service_attributes do
field :name, non_null(:string)
field :version, non_null(:string)
field :name, non_null(:string)
field :version, non_null(:string)
field :instance_count, :integer, description: "the number of instances of this service we've found"
end

input_object :agent_migration_attributes do
Expand Down Expand Up @@ -212,13 +213,20 @@ defmodule Console.GraphQl.Deployments.Cluster do
field :status, :upgrade_insight_status
field :used, :string, description: "a possibly deprecated API"
field :replacement, :string, description: "the replacement for this API"
field :client_info, list_of(:insight_client_info_attributes), description: "descriptions of the HTTP clients triggering this insight"

field :replaced_in, :string
field :removed_in, :string

field :last_used_at, :datetime, description: "the latest timestamp this insight has been observed"
end

input_object :insight_client_info_attributes do
field :user_agent, :string
field :count, :string
field :last_request_at, :datetime
end

@desc "a CAPI provider for a cluster, cloud is inferred from name if not provided manually"
object :cluster_provider do
field :id, non_null(:id), description: "the id of this provider"
Expand Down Expand Up @@ -527,12 +535,13 @@ defmodule Console.GraphQl.Deployments.Cluster do

@desc "a service encapsulating a controller like istio/ingress-nginx/etc that is meant to extend the kubernetes api"
object :runtime_service do
field :id, non_null(:id)
field :name, non_null(:string), description: "add-on name"
field :version, non_null(:string), description: "add-on version, should be semver formatted"
field :addon, :runtime_addon, description: "the full specification of this kubernetes add-on"
field :addon_version, :addon_version, description: "the version of the add-on you've currently deployed"
field :service, :service_deployment,
field :id, non_null(:id)
field :name, non_null(:string), description: "add-on name"
field :version, non_null(:string), description: "add-on version, should be semver formatted"
field :instance_count, :integer, description: "the number of instances of this service we've detected"
field :addon, :runtime_addon, description: "the full specification of this kubernetes add-on"
field :addon_version, :addon_version, description: "the version of the add-on you've currently deployed"
field :service, :service_deployment,
resolve: dataloader(Deployments),
description: "the plural service it came from"

Expand Down Expand Up @@ -640,6 +649,7 @@ defmodule Console.GraphQl.Deployments.Cluster do
field :status, :upgrade_insight_status
field :used, :string, description: "a possibly deprecated API"
field :replacement, :string, description: "the replacement for this API"
field :client_info, list_of(:insight_client_info), description: "information about the HTTP clients triggering this insight"

field :replaced_in, :string
field :removed_in, :string
Expand All @@ -648,6 +658,12 @@ defmodule Console.GraphQl.Deployments.Cluster do
timestamps()
end

object :insight_client_info do
field :user_agent, :string
field :count, :string
field :last_request_at, :datetime
end

connection node_type: :cluster
connection node_type: :cluster_provider
connection node_type: :cluster_revision
Expand Down
7 changes: 4 additions & 3 deletions lib/console/schema/runtime_service.ex
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,9 @@ defmodule Console.Schema.RuntimeService do
alias Console.Schema.{Service, Cluster}

schema "runtime_services" do
field :name, :string
field :version, :string
field :name, :string
field :version, :string
field :instance_count, :integer, default: 1

field :addon, :map, virtual: true
field :addon_version, :map, virtual: true
Expand All @@ -27,7 +28,7 @@ defmodule Console.Schema.RuntimeService do
from(rs in query, order_by: ^order)
end

@valid ~w(name version service_id cluster_id)a
@valid ~w(name version instance_count service_id cluster_id)a

def changeset(model, attrs \\ %{}) do
model
Expand Down
13 changes: 13 additions & 0 deletions lib/console/schema/upgrade_insight_detail.ex
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,12 @@ defmodule Console.Schema.UpgradeInsightDetail do
field :used, :string
field :replacement, :string

embeds_many :client_info, ClientInfo, on_replace: :delete do
field :user_agent, :string
field :count, :string
field :last_request_at, :utc_datetime_usec
end

field :replaced_in, :string
field :removed_in, :string

Expand All @@ -20,7 +26,14 @@ defmodule Console.Schema.UpgradeInsightDetail do
def changeset(model, attrs \\ %{}) do
model
|> cast(attrs, ~w(status used replacement replaced_in removed_in insight_id last_used_at)a)
|> cast_embed(:client_info, with: &client_info_changeset/2)
|> foreign_key_constraint(:insight_id)
|> validate_required(~w(status used replacement)a)
end

defp client_info_changeset(model, attrs) do
model
|> cast(attrs, ~w(user_agent count last_request_at)a)
|> validate_required(~w(user_agent last_request_at)a)
end
end
13 changes: 13 additions & 0 deletions priv/repo/migrations/20241003160915_insight_detail.exs
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
defmodule Console.Repo.Migrations.InsightDetail do
use Ecto.Migration

def change do
alter table(:upgrade_insight_details) do
add :client_info, :map
end

alter table(:runtime_services) do
add :instance_count, :integer, default: 1
end
end
end
25 changes: 25 additions & 0 deletions schema/schema.graphql
Original file line number Diff line number Diff line change
Expand Up @@ -3725,7 +3725,11 @@ input AzureSettingsAttributes {

input RuntimeServiceAttributes {
name: String!

version: String!

"the number of instances of this service we've found"
instanceCount: Int
}

input AgentMigrationAttributes {
Expand Down Expand Up @@ -3781,6 +3785,9 @@ input UpgradeInsightDetailAttributes {
"the replacement for this API"
replacement: String

"descriptions of the HTTP clients triggering this insight"
clientInfo: [InsightClientInfoAttributes]

replacedIn: String

removedIn: String
Expand All @@ -3789,6 +3796,12 @@ input UpgradeInsightDetailAttributes {
lastUsedAt: DateTime
}

input InsightClientInfoAttributes {
userAgent: String
count: String
lastRequestAt: DateTime
}

"a CAPI provider for a cluster, cloud is inferred from name if not provided manually"
type ClusterProvider {
"the id of this provider"
Expand Down Expand Up @@ -4217,6 +4230,9 @@ type RuntimeService {
"add-on version, should be semver formatted"
version: String!

"the number of instances of this service we've detected"
instanceCount: Int

"the full specification of this kubernetes add-on"
addon: RuntimeAddon

Expand Down Expand Up @@ -4348,6 +4364,9 @@ type UpgradeInsightDetail {
"the replacement for this API"
replacement: String

"information about the HTTP clients triggering this insight"
clientInfo: [InsightClientInfo]

replacedIn: String

removedIn: String
Expand All @@ -4359,6 +4378,12 @@ type UpgradeInsightDetail {
updatedAt: DateTime
}

type InsightClientInfo {
userAgent: String
count: String
lastRequestAt: DateTime
}

type ClusterConnection {
pageInfo: PageInfo!
edges: [ClusterEdge]
Expand Down

0 comments on commit c53158f

Please sign in to comment.