Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Sync 2025-01-07 #35

Open
wants to merge 82 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
82 commits
Select commit Hold shift + click to select a range
1ee2412
OS-8018. Not skip cleaning events and resources if profiling token mi…
nk-hystax Dec 3, 2024
b354bed
OS-8036. Add check for BOOK_ENVIRONMENTS for environment booking action
ek-hystax Dec 3, 2024
092a9bc
OS-3172. Improved env_properties messages in slack
nk-hystax Dec 3, 2024
f29e46b
Feature/notification settings
nk-hystax Dec 3, 2024
2422ad1
Pull request update/241204
stanfra Dec 4, 2024
936dc52
OS-8003. inactive_users for gcp
nk-hystax Dec 4, 2024
daaa7da
OS-8043. Add the GCP service to the "Inactive IAM users" recommendation
ek-hystax Dec 4, 2024
7bb6652
Pull request update/241205
stanfra Dec 5, 2024
f88aa20
OS-8047. Fixed invalid reason for gcp inactive_users archive
nk-hystax Dec 5, 2024
696f3dc
OS-8040. Changed regions for discovering RDS + new region on Alibaba
nk-hystax Dec 5, 2024
c65660c
OS-7996. GCP s3_public_buckets support
nk-hystax Dec 5, 2024
3a33687
OS-8046. Add the GCP service to the "Public S3 buckets" recommendation
ek-hystax Dec 5, 2024
aab38e0
Pull request update/241206
stanfra Dec 6, 2024
949a8a8
OS-7831: Reimplemented error boundary (#1210)
v-hx Dec 6, 2024
2a5490b
OS-7988. Archived recommendation, checklist, webhook collections clea…
nk-hystax Dec 6, 2024
261ef1f
OS-7921 [Community Documentation] Add tips for Assignment Rules page …
alis-hx Dec 6, 2024
eb9ceb0
OS-8051. Fix assignment-rules.md file name
ek-hystax Dec 6, 2024
ea05125
Pull request update/241209
stanfra Dec 9, 2024
4686d76
OS-8048. Support token param for get layout and list artifacts
nk-hystax Dec 9, 2024
a758676
OS-3430. Fixed incorrect status of env in email
nk-hystax Dec 9, 2024
1af6c92
OS-8050. Update express
ek-hystax Dec 9, 2024
532a0ca
Pull request update/241210
stanfra Dec 10, 2024
8461af9
OS-7993. abandoned_images for gcp
nk-hystax Dec 10, 2024
21aa278
OS-8053. Add the GCP service to the "Abandoned Images" recommendation
ek-hystax Dec 10, 2024
3323495
Pull request update/241211
stanfra Dec 11, 2024
3bc0ca1
OS-5865. Unify spacing between elements and their descriptions
ek-hystax Dec 11, 2024
469be46
OS-8058. Added md5_token param to profiling_token get api
nk-hystax Dec 11, 2024
1139bee
OS-7414. Publicly available run page
ek-hystax Dec 11, 2024
f1f5d66
Pull request update/241212
stanfra Dec 12, 2024
96e35d2
OS-2372. Not send slack message to channels the bot is removed from
nk-hystax Dec 12, 2024
680a2aa
OS-1663. Use short cloud_resource_id in slack message
nk-hystax Dec 12, 2024
624b375
OS-2587. Show env_properties in resource_details slack message
nk-hystax Dec 12, 2024
fb691e0
OS-3856. Fixed incorrect constraints in resource_details msg
nk-hystax Dec 12, 2024
37346f4
OS-1714. Changed error text for slacker
nk-hystax Dec 12, 2024
0027a14
OS-2371. Fixed 500 on constraint_alert msg if user added to several s…
nk-hystax Dec 12, 2024
3ca3bda
Pull request update/241213
stanfra Dec 13, 2024
8ee0fdd
OS-4897. Discover SGs as strings in AWS
nk-hystax Dec 13, 2024
3f6b6b7
OS-4038. Not raise error in available_filters on missing cloud accounts
nk-hystax Dec 13, 2024
4110cb9
OS-8059. [Dependabot] Infinite loop in nanoid
ek-hystax Dec 13, 2024
7b324d5
OS-8056. Relocate the "Add" Power Schedule button to the table action…
ek-hystax Dec 13, 2024
a268330
Pull request update/241216
stanfra Dec 16, 2024
8c1e23e
OS-4103. Return limit_hits param if hit_days=0 in list org constraints
nk-hystax Dec 16, 2024
a01d42a
OS-5155. Added OE0455 to swagger
nk-hystax Dec 16, 2024
873eeb9
OS-8026. Fixed swagger in patch user
nk-hystax Dec 16, 2024
73762fc
OS-5101. Fixed showing deleted resources in env cloud account
nk-hystax Dec 16, 2024
52f7e8a
OS-8055. Updated description for token param in swagger
nk-hystax Dec 16, 2024
3cc7d78
OS-8063. Remove undefined exports
ek-hystax Dec 16, 2024
c5a9e52
Pull request update/241217
stanfra Dec 17, 2024
0222966
OS-5101. Fixed showing deleted env resources in pool api
nk-hystax Dec 17, 2024
ad8ab1e
OS-4548. Fixed missing organization_id field in saving_spike task
nk-hystax Dec 17, 2024
cddcc0a
OS-4151. Re-request resources after applying force assignment rules
ek-hystax Dec 17, 2024
d9dc929
OS-3669. Update booking labels
ek-hystax Dec 17, 2024
f0fb8b9
Pull request update/241218
stanfra Dec 18, 2024
ac14897
Pull request update/241219
stanfra Dec 19, 2024
802783a
OS-8060. Add public_ip to user_template.yml
nk-hystax Dec 19, 2024
91c2e96
OS-2570. Improved validation for env_properties_collector api
nk-hystax Dec 19, 2024
beb534b
OS-8062. Fix forms validation
ek-hystax Dec 19, 2024
cbbfec7
OS-8064. Fix unique keys warning on resource details page
ek-hystax Dec 19, 2024
ce5e43e
Pull request update/241220
stanfra Dec 20, 2024
55226ab
feature/app_initialization
ek-hystax Dec 20, 2024
627c2c8
OS-8080. Remove logs
ek-hystax Dec 23, 2024
62f1d6c
Pull request update/241223
stanfra Dec 23, 2024
c6c6442
OS-8019. GCP optimization & gcp tenant cloud accounts
sd-hystax Dec 23, 2024
c84413c
OS-8054. [UI] Add support for gcp_tenant
ek-hystax Dec 23, 2024
807d7c1
OS-8085. Display pool and organization names in the roles section on …
ek-hystax Dec 23, 2024
ed1f380
OS-8086. Fix gcp tenant connection and update forms
ek-hystax Dec 23, 2024
82266e3
OS-8087. Add project_id to GcpBillingDataConfigInput scheme
ek-hystax Dec 24, 2024
2d4578a
OS-8087. Fix data source connection issues
ek-hystax Dec 24, 2024
ba54625
Pull request update/241225
stanfra Dec 25, 2024
c6be6eb
OS-2765. Add support for the "Default resource owner" field in the "A…
ek-hystax Dec 25, 2024
6fbfc57
OS-2767. Add tooltips to environment and cluster resource type icons
ek-hystax Dec 25, 2024
c121220
OS-7309. Add TODO type
ek-hystax Dec 25, 2024
9203864
OS-2854. Hide the action columns if no recommendation can be dismissed
ek-hystax Dec 25, 2024
c1a6c3e
OS-2765. Populate default resource owner field for new pools
ek-hystax Dec 25, 2024
3fabf2a
Pull request update/241226
stanfra Dec 26, 2024
26a4fe5
OS-4346. Update translation keys for Expenses Breakdown table widget
ek-hystax Dec 26, 2024
7b51a05
OS-3011. Update read-only input styles
ek-hystax Dec 26, 2024
694f16a
OS-2840. Add default ascending sorting by the Name column for recomme…
ek-hystax Dec 26, 2024
ee5bdc7
OS-4903. Fixed cluster cost
nk-hystax Dec 26, 2024
d9c9fac
OS-5132. Return traffic expenses for clusters in clean_expenses api
nk-hystax Dec 26, 2024
1f656e5
Pull request update/241227
stanfra Dec 27, 2024
5694966
Update README.md for easy deployment
daviftorres Jan 3, 2025
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
The table of contents is too big for display.
Diff view
Diff view
  •  
  •  
  •  
10 changes: 4 additions & 6 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -88,7 +88,7 @@ _The current installation process does not work on Ubuntu 22.04_
Run the following commands:

```
sudo apt update; sudo apt install python3-pip sshpass git python3-virtualenv python3.9
sudo apt update; sudo apt install python3-pip sshpass git python3.9-venv python3.9-dev python3.9 -y
```

#### Pulling optscale-deploy scripts
Expand Down Expand Up @@ -125,13 +125,11 @@ ansible-playbook -e "ansible_ssh_user=<user>" -k -K -i "<ip address>," ansible/k
```

where `<user>` - actual username; `<ip address>` - host ip address,
ip address should be private address of the machine, you can check it with
ip address should be private address of the machine, you can check it with the command `ip a`.

```
ip a
```
**Note:** do not use `127.0.0.1` or `localhost` as the hostname. Instead, prefer providing the server's hostname (check with the command `hostname`) and make sure it is resolveable from host that the Ansible Playbooks ran from (if needed, add to the ``/etc/hosts`` files).

If your deployment server is the service-host server, add `"ansible_connection=local"` to the ansible command.
If your deployment server is the service-host server, add `-e "ansible_connection=local"` to the ansible command.

#### Creating user overlay

Expand Down
1 change: 0 additions & 1 deletion auth/auth_server/handlers/v2/signin.py
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,6 @@ async def post(self, **url_params):
data = self._request_body()
data.update(url_params)
data.update({'ip': self.get_ip_addr()})
data.update({'redirect_uri': self.request.headers.get('Origin')})
await self._validate_params(**data)
res = await run_task(self.controller.signin, **data)
self.set_status(201)
Expand Down
2 changes: 1 addition & 1 deletion auth/auth_server/handlers/v2/users.py
Original file line number Diff line number Diff line change
Expand Up @@ -101,7 +101,7 @@ async def patch(self, user_id, **kwargs):
Required permission: EDIT_USER_INFO or ACTIVATE_USER or
RESET_USER_PASSWORD
parameters:
- name: id
- name: user_id
in: path
description: ID of user to modify
required: true
Expand Down
4 changes: 3 additions & 1 deletion bumiworker/bumiworker/modules/archive/inactive_users.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,8 @@
import logging

from bumiworker.bumiworker.consts import ArchiveReason
from bumiworker.bumiworker.modules.inactive_users_base import ArchiveInactiveUsersBase
from bumiworker.bumiworker.modules.inactive_users_base import (
ArchiveInactiveUsersBase)
from bumiworker.bumiworker.modules.recommendations.inactive_users import (
InactiveUsers as InactiveUsersRecommendation)

Expand All @@ -12,6 +13,7 @@
class InactiveUsers(ArchiveInactiveUsersBase, InactiveUsersRecommendation):
SUPPORTED_CLOUD_TYPES = [
'aws_cnr',
'gcp_cnr',
'nebius'
]

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
DEFAULT_DAYS_THRESHOLD = 7
BULK_SIZE = 1000
SUPPORTED_CLOUD_TYPES = [
'nebius'
'gcp_cnr', 'nebius'
]


Expand Down Expand Up @@ -90,7 +90,7 @@ def _get(self):
'cloud_account_id': image['cloud_account_id'],
'cloud_account_name': account['name'],
'cloud_type': account['type'],
'folder_id': image['meta']['folder_id'],
'folder_id': image['meta'].get('folder_id'),
'last_used': last_used_map.get(
image['cloud_resource_id'], 0),
'first_seen': image['first_seen'],
Expand Down
45 changes: 39 additions & 6 deletions bumiworker/bumiworker/modules/recommendations/inactive_users.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,13 +5,16 @@


DEFAULT_DAYS_THRESHOLD = 90
INTERVAL = 300
GCP_METRIC_NAME = 'iam.googleapis.com/service_account/authn_events_count'
MSEC_IN_SEC = 1000
LOG = logging.getLogger(__name__)


class InactiveUsers(InactiveUsersBase):
SUPPORTED_CLOUD_TYPES = [
'aws_cnr',
'gcp_cnr',
'nebius'
]

Expand All @@ -28,6 +31,8 @@ def list_users(self, cloud_adapter):
result = []
for folder_id in cloud_adapter.folders:
result.extend(cloud_adapter.service_accounts_list(folder_id))
elif cloud_type == 'gcp_cnr':
result = cloud_adapter.service_accounts_list()
else:
result = cloud_adapter.list_users()
return result
Expand Down Expand Up @@ -56,6 +61,33 @@ def is_outdated(last_used_):
'last_used': int(last_used.timestamp())
}

def handle_gcp_user(self, user, now, cloud_adapter, days_threshold):
last_used = 0
service_account_id = user.unique_id
inactive_threshold = self._get_inactive_threshold(days_threshold)
end_date = now
# there is no created_at for service account, so extend dates range to
# try to get last_used
start_date = now - inactive_threshold - inactive_threshold
service_account_usage = cloud_adapter.get_metric(
GCP_METRIC_NAME, [service_account_id], INTERVAL, start_date,
end_date, id_field='unique_id'
)
used_dates = [
point.interval.end_time for data in service_account_usage
for point in data.points if point.value.double_value != 0
]
if used_dates:
last_used_dt = max(used_dates)
last_used = int(last_used_dt.timestamp())
if not self._is_outdated(now, last_used_dt, inactive_threshold):
return
return {
'user_name': user.display_name,
'user_id': service_account_id,
'last_used': last_used
}

def handle_nebius_user(self, user, now, cloud_adapter, days_threshold):
service_account_id = user['id']
folder_id = user['folderId']
Expand Down Expand Up @@ -99,12 +131,13 @@ def handle_nebius_user(self, user, now, cloud_adapter, days_threshold):

def handle_user(self, user, now, cloud_adapter, days_threshold):
cloud_type = cloud_adapter.config['type']
if cloud_type == 'aws_cnr':
return self.handle_aws_user(user, now, cloud_adapter,
days_threshold)
else:
return self.handle_nebius_user(user, now, cloud_adapter,
days_threshold)
cloud_func_map = {
"aws_cnr": self.handle_aws_user,
"gcp_cnr": self.handle_gcp_user,
"nebius": self.handle_nebius_user,
}
func = cloud_func_map[cloud_type]
return func(user, now, cloud_adapter, days_threshold)


def main(organization_id, config_client, created_at, **kwargs):
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -159,8 +159,7 @@ def _get_aws_insecure(self, config, resources, excluded_pools,
if s_groups is None:
continue
security_groups_map = region_sg_map[region]
for group in s_groups:
group_id = group['GroupId']
for group_id in s_groups:
instances = security_groups_map.get(group_id, [])
instances.append(instance)
security_groups_map[group_id] = instances
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@

SUPPORTED_CLOUD_TYPES = [
'aws_cnr',
'gcp_cnr',
'nebius'
]

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -64,6 +64,7 @@ def _get(self):
modules_data.sort(key=lambda x: x['saving'], reverse=True)
task = {
"object_id": self.organization_id,
"organization_id": self.organization_id,
"object_type": "organization",
"action": "saving_spike",
"meta": {"previous_total": previous_total,
Expand Down
2 changes: 1 addition & 1 deletion diworker/diworker/importers/gcp.py
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ def detect_period_start(self):
if last_exp_date:
self.period_start = last_exp_date.replace(
hour=0, minute=0, second=0, microsecond=0) - timedelta(
days=1)
days=3)
if not self.period_start:
super().detect_period_start()

Expand Down
22 changes: 17 additions & 5 deletions docker_images/cleanmongodb/clean-mongo-db.py
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,11 @@ def __init__(self):
# linked to cloud_account_id
self.mongo_client.restapi.raw_expenses: ROWS_LIMIT,
self.mongo_client.restapi.resources: ROWS_LIMIT,
# linked to organization_id
self.mongo_client.restapi.archived_recommendations: ROWS_LIMIT,
self.mongo_client.restapi.checklists: ROWS_LIMIT,
self.mongo_client.restapi.webhook_observer: ROWS_LIMIT,
self.mongo_client.restapi.webhook_logs: ROWS_LIMIT,
# linked to run_id
self.mongo_client.arcee.console: ROWS_LIMIT,
self.mongo_client.arcee.log: ROWS_LIMIT,
Expand Down Expand Up @@ -318,14 +323,17 @@ def split_chunk_by_files(self, chunk, available_rows_count, filename,
return result

def _delete_by_organization(self, org_id, token, infra_token):
if not token:
self.update_cleaned_at(organization_id=org_id)
return
restapi_collections = [
self.mongo_client.restapi.archived_recommendations,
self.mongo_client.restapi.checklists,
# delete clusters resources
self.mongo_client.restapi.resources,
self.mongo_client.restapi.webhook_observer,
self.mongo_client.restapi.webhook_logs
]
keeper_collections = [
self.mongo_client.keeper.event
]
# delete clusters resources
restapi_collections = [self.mongo_client.restapi.resources]
# delete ml objects
arcee_collections = [self.mongo_client.arcee.dataset,
self.mongo_client.arcee.metric,
Expand All @@ -342,6 +350,10 @@ def _delete_by_organization(self, org_id, token, infra_token):
for collection in restapi_collections:
self.limits[collection] = self.delete_in_chunks(
collection, 'organization_id', org_id)

if not token:
self.update_cleaned_at(organization_id=org_id)
return
for collection in arcee_collections:
self.limits[collection] = self.delete_in_chunks(
collection, 'token', token)
Expand Down
Loading