From 6e4222e6637f2b4c2f84e6f6de9d51706301c175 Mon Sep 17 00:00:00 2001 From: Zhamilya Abikenova Date: Wed, 12 Aug 2026 10:45:36 +0200 Subject: [PATCH] feat(RHINENG-29493): add Satellite workload --- base/inventory/inventory.go | 6 ++++++ base/models/models.go | 1 + .../migrations/164_add_satellite_workload.down.sql | 2 ++ .../migrations/164_add_satellite_workload.up.sql | 2 ++ database_admin/schema/create_schema.sql | 3 ++- dev/test_data.sql | 6 +++--- listener/common_test.go | 7 +++++++ listener/upload.go | 2 ++ listener/upload_test.go | 4 ++++ manager/controllers/systems_test.go | 11 +++++++++++ manager/controllers/utils.go | 1 + 11 files changed, 41 insertions(+), 4 deletions(-) create mode 100644 database_admin/migrations/164_add_satellite_workload.down.sql create mode 100644 database_admin/migrations/164_add_satellite_workload.up.sql diff --git a/base/inventory/inventory.go b/base/inventory/inventory.go index 16b5acad3..e7e5a867e 100644 --- a/base/inventory/inventory.go +++ b/base/inventory/inventory.go @@ -92,6 +92,7 @@ type Workloads struct { Intersystems IntersystemsWorkload `json:"intersystems,omitempty"` OracleDb OracleDbWorkload `json:"oracle_db,omitempty"` RhelAi RhelAiWorkload `json:"rhel_ai,omitempty"` + Satellite SatelliteWorkload `json:"satellite,omitempty"` } type SapWorkload struct { @@ -126,3 +127,8 @@ type OracleDbWorkload struct { type RhelAiWorkload struct { Variant string `json:"variant,omitempty"` } + +type SatelliteWorkload struct { + Type string `json:"type,omitempty"` + Version string `json:"version,omitempty"` +} diff --git a/base/models/models.go b/base/models/models.go index a5303282a..d8f87e514 100644 --- a/base/models/models.go +++ b/base/models/models.go @@ -106,6 +106,7 @@ type SystemInventory struct { IntersystemsWorkload bool `gorm:"column:intersystems_workload"` OracleDbWorkload bool `gorm:"column:oracle_db_workload"` RhelAiWorkload bool `gorm:"column:rhel_ai_workload"` + SatelliteWorkload bool `gorm:"column:satellite_workload"` } func (SystemInventory) TableName() string { diff --git a/database_admin/migrations/164_add_satellite_workload.down.sql b/database_admin/migrations/164_add_satellite_workload.down.sql new file mode 100644 index 000000000..e6c7f1767 --- /dev/null +++ b/database_admin/migrations/164_add_satellite_workload.down.sql @@ -0,0 +1,2 @@ +ALTER TABLE system_inventory + DROP COLUMN IF EXISTS satellite_workload; diff --git a/database_admin/migrations/164_add_satellite_workload.up.sql b/database_admin/migrations/164_add_satellite_workload.up.sql new file mode 100644 index 000000000..e93ecc6c9 --- /dev/null +++ b/database_admin/migrations/164_add_satellite_workload.up.sql @@ -0,0 +1,2 @@ +ALTER TABLE system_inventory + ADD COLUMN IF NOT EXISTS satellite_workload BOOLEAN NOT NULL DEFAULT false; diff --git a/database_admin/schema/create_schema.sql b/database_admin/schema/create_schema.sql index 635ada438..b8ac90d18 100644 --- a/database_admin/schema/create_schema.sql +++ b/database_admin/schema/create_schema.sql @@ -7,7 +7,7 @@ CREATE TABLE IF NOT EXISTS schema_migrations INSERT INTO schema_migrations -VALUES (163, false); +VALUES (164, false); -- --------------------------------------------------------------------------- -- Functions @@ -661,6 +661,7 @@ CREATE TABLE IF NOT EXISTS system_inventory intersystems_workload BOOLEAN NOT NULL DEFAULT false, oracle_db_workload BOOLEAN NOT NULL DEFAULT false, rhel_ai_workload BOOLEAN NOT NULL DEFAULT false, + satellite_workload BOOLEAN NOT NULL DEFAULT false, PRIMARY KEY (rh_account_id, id), UNIQUE (rh_account_id, inventory_id) ) PARTITION BY HASH (rh_account_id); diff --git a/dev/test_data.sql b/dev/test_data.sql index f04e1529a..ceb152bdf 100644 --- a/dev/test_data.sql +++ b/dev/test_data.sql @@ -67,9 +67,9 @@ INSERT INTO system_patch (system_id, rh_account_id, last_evaluation, packages_in (14, 3, '2018-09-22 12:00:00-04', 0), (15, 3, '2018-09-22 12:00:00-04', 0); -INSERT INTO system_inventory (id, inventory_id, rh_account_id, vmaas_json, json_checksum, last_upload, display_name, tags, created, stale_timestamp, stale_warning_timestamp, workspace_id, workspace_name, os_name, os_major, os_minor, rhsm_version, ansible_workload, ansible_workload_controller_version, mssql_workload, mssql_workload_version, crowdstrike_workload, ibm_db2_workload, intersystems_workload, oracle_db_workload, rhel_ai_workload) VALUES -(16, '00000000-0000-0000-0000-000000000016', 3, '{ "package_list": [ "kernel-2.6.32-696.20.1.el6.x86_64" ], "repository_list": [ "rhel-6-server-rpms" ] }', '1', '2018-01-22 12:00:00-04', '00000000-0000-0000-0000-000000000016', '[]', '2018-08-26 12:00:00-04', '2018-08-26 12:00:00-04', '2018-09-02 12:00:00-04', '00000000-0000-0000-0000-999999999999', 'root-ws', 'RHEL', 8, 2, '8.2', false, NULL, false, NULL, false, true, true, true, false), -(17, '00000000-0000-0000-0000-000000000017', 1, '{ "package_list": [ "kernel-2.6.32-696.20.1.el6.x86_64" ], "repository_list": [ "rhel-6-server-rpms" ] }', '1', '2018-01-22 12:00:00-04', '00000000-0000-0000-0000-000000000017', '[]', '2018-08-26 12:00:00-04', '2018-08-26 12:00:00-04', '2018-09-02 12:00:00-04', '00000000-0000-0000-0000-999999999999', 'root-ws', 'RHEL', 8, 1, '8.1', true, '1.0', true, '15.3.0', true, false, false, false, true); +INSERT INTO system_inventory (id, inventory_id, rh_account_id, vmaas_json, json_checksum, last_upload, display_name, tags, created, stale_timestamp, stale_warning_timestamp, workspace_id, workspace_name, os_name, os_major, os_minor, rhsm_version, ansible_workload, ansible_workload_controller_version, mssql_workload, mssql_workload_version, crowdstrike_workload, ibm_db2_workload, intersystems_workload, oracle_db_workload, rhel_ai_workload, satellite_workload) VALUES +(16, '00000000-0000-0000-0000-000000000016', 3, '{ "package_list": [ "kernel-2.6.32-696.20.1.el6.x86_64" ], "repository_list": [ "rhel-6-server-rpms" ] }', '1', '2018-01-22 12:00:00-04', '00000000-0000-0000-0000-000000000016', '[]', '2018-08-26 12:00:00-04', '2018-08-26 12:00:00-04', '2018-09-02 12:00:00-04', '00000000-0000-0000-0000-999999999999', 'root-ws', 'RHEL', 8, 2, '8.2', false, NULL, false, NULL, false, true, true, true, false, true), +(17, '00000000-0000-0000-0000-000000000017', 1, '{ "package_list": [ "kernel-2.6.32-696.20.1.el6.x86_64" ], "repository_list": [ "rhel-6-server-rpms" ] }', '1', '2018-01-22 12:00:00-04', '00000000-0000-0000-0000-000000000017', '[]', '2018-08-26 12:00:00-04', '2018-08-26 12:00:00-04', '2018-09-02 12:00:00-04', '00000000-0000-0000-0000-999999999999', 'root-ws', 'RHEL', 8, 1, '8.1', true, '1.0', true, '15.3.0', true, false, false, false, true, false); INSERT INTO system_patch (system_id, rh_account_id, last_evaluation, packages_installed, packages_installable, packages_applicable, template_id) VALUES (16, 3, '2018-09-22 12:00:00-04', 1, 1, 1, 4), (17, 1, '2018-09-22 12:00:00-04', 2, 2, 2, NULL); diff --git a/listener/common_test.go b/listener/common_test.go index a50535abf..c4606bf23 100644 --- a/listener/common_test.go +++ b/listener/common_test.go @@ -178,6 +178,9 @@ func assertSystemInventoryProfileMatchesHost(t *testing.T, inventoryID uuid.UUID assert.Nil(t, inv.MssqlWorkloadVersion) } + expSatellite := host.SystemProfile.Workloads.Satellite.Type != "" + assert.Equal(t, expSatellite, inv.SatelliteWorkload) + if host.SystemProfile.OwnerID != nil { require.NotNil(t, inv.SubscriptionManagerID) assert.Equal(t, *host.SystemProfile.OwnerID, *inv.SubscriptionManagerID) @@ -246,6 +249,10 @@ func createTestUploadEvent(orgID string, inventoryID uuid.UUID, reporter string, Mssql: inventory.MssqlWorkload{ Version: "15.0", }, + Satellite: inventory.SatelliteWorkload{ + Type: "server", + Version: "6.17.6.1", + }, }, }, }, diff --git a/listener/upload.go b/listener/upload.go index 412decc15..eee481220 100644 --- a/listener/upload.go +++ b/listener/upload.go @@ -353,6 +353,7 @@ func updateSystemPlatform(tx *gorm.DB, accountID int, host *Host, "intersystems_workload", "oracle_db_workload", "rhel_ai_workload", + "satellite_workload", } displayName := inventoryID.String() @@ -421,6 +422,7 @@ func updateSystemPlatform(tx *gorm.DB, accountID int, host *Host, IntersystemsWorkload: host.SystemProfile.Workloads.Intersystems.IsIntersystems, OracleDbWorkload: host.SystemProfile.Workloads.OracleDb.IsRunning, RhelAiWorkload: host.SystemProfile.Workloads.RhelAi.Variant != "", + SatelliteWorkload: host.SystemProfile.Workloads.Satellite.Type != "", }, Patch: models.SystemPatch{ RhAccountID: accountID, diff --git a/listener/upload_test.go b/listener/upload_test.go index 918eb5067..b701c8f78 100644 --- a/listener/upload_test.go +++ b/listener/upload_test.go @@ -503,6 +503,7 @@ func TestStoreOrUpdateSysPlatform(t *testing.T) { AnsibleWorkloadControllerVersion: utils.EmptyToNil(&hostEvent.Host.SystemProfile.Workloads.Ansible.ControllerVersion), // nolint:lll MssqlWorkload: hostEvent.Host.SystemProfile.Workloads.Mssql.Version != "", MssqlWorkloadVersion: utils.EmptyToNil(&hostEvent.Host.SystemProfile.Workloads.Mssql.Version), + SatelliteWorkload: hostEvent.Host.SystemProfile.Workloads.Satellite.Type != "", }, Patch: models.SystemPatch{RhAccountID: 1}, } @@ -558,6 +559,8 @@ func TestStoreOrUpdateSysPlatform(t *testing.T) { assert.Equal(t, true, inventoryAfterInsert.MssqlWorkload) assert.Equal(t, hostEvent.Host.SystemProfile.Workloads.Mssql.Version, *inventoryAfterInsert.MssqlWorkloadVersion) + assert.Equal(t, true, inventoryAfterInsert.SatelliteWorkload) + updateJSON := "updated_json" reporter := 2 var patchAfterInsert models.SystemPatch @@ -588,6 +591,7 @@ func TestStoreOrUpdateSysPlatform(t *testing.T) { AnsibleWorkloadControllerVersion: utils.EmptyToNil(&hostEvent.Host.SystemProfile.Workloads.Ansible.ControllerVersion), // nolint:lll MssqlWorkload: hostEvent.Host.SystemProfile.Workloads.Mssql.Version != "", MssqlWorkloadVersion: utils.EmptyToNil(&hostEvent.Host.SystemProfile.Workloads.Mssql.Version), + SatelliteWorkload: hostEvent.Host.SystemProfile.Workloads.Satellite.Type != "", }, Patch: models.SystemPatch{ RhAccountID: outStore.RhAccountID, diff --git a/manager/controllers/systems_test.go b/manager/controllers/systems_test.go index dad2852d1..ab263216e 100644 --- a/manager/controllers/systems_test.go +++ b/manager/controllers/systems_test.go @@ -495,6 +495,17 @@ func TestRhelAiFilter(t *testing.T) { assert.Equal(t, testMap, output.Meta.Filter) } +func TestSatelliteFilter(t *testing.T) { + output := testSystems(t, `?filter[system_profile][satellite]=true`, 3) + testMap := map[string]FilterData{ + "system_profile][satellite": {Operator: "eq", Values: []string{"true"}}, + "stale": {Operator: "eq", Values: []string{"false"}}, + } + assert.Equal(t, 1, output.Meta.TotalItems) + assert.Equal(t, uuid.MustParse("00000000-0000-0000-0000-000000000016"), output.Data[0].ID) + assert.Equal(t, testMap, output.Meta.Filter) +} + func TestWorkloadOrLogic(t *testing.T) { output := testSystems(t, `?filter[system_profile][rhel_ai]=true&filter[system_profile][sap_sids]=ABC`, 1) diff --git a/manager/controllers/utils.go b/manager/controllers/utils.go index a94c67d81..ded7ae11b 100644 --- a/manager/controllers/utils.go +++ b/manager/controllers/utils.go @@ -82,6 +82,7 @@ var workloadFilters = NestedFilterMap{ "system_profile][intersystems": "(si.intersystems_workload)", "system_profile][oracle_db": "(si.oracle_db_workload)", "system_profile][rhel_ai": "(si.rhel_ai_workload)", + "system_profile][satellite": "(si.satellite_workload)", } var inventoryFilters = NestedFilterMap{