Skip to content

Commit

Permalink
Merge pull request #344 from Cray-HPE/develop
Browse files Browse the repository at this point in the history
Release 2.22.0 for CSM 1.6
  • Loading branch information
mharding-hpe authored Jul 23, 2024
2 parents a4c125f + 6c02e1f commit 7b90ab2
Show file tree
Hide file tree
Showing 62 changed files with 621 additions and 514 deletions.
18 changes: 17 additions & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,23 @@ All notable changes to this project will be documented in this file.
The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/),
and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).

## Unreleased
## [Unreleased]

## [2.22.0]
### Added
- Add request timeouts to BOS reporter API calls
- Create new BOS v2 `max_component_batch_size` option to limit number of components a BOS operator
will work on at once.

### Changed
- Code linting (no functional changes)

### Fixed
- Handle case where no path value is set in boot set in `boot_image_metadata/factory.py`
- Raise exception when there is an error getting the service version

### Removed
- Removed redundant `duration_to_timedelta` function definition from BOS reporter source.

## [2.21.0]

Expand Down
4 changes: 2 additions & 2 deletions Jenkinsfile.github
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
*
* MIT License
*
* (C) Copyright 2021-2023 Hewlett Packard Enterprise Development LP
* (C) Copyright 2021-2024 Hewlett Packard Enterprise Development LP
*
* Permission is hereby granted, free of charge, to any person obtaining a
* copy of this software and associated documentation files (the "Software"),
Expand Down Expand Up @@ -33,7 +33,7 @@ pipeline {

options {
buildDiscarder(logRotator(numToKeepStr: "10"))
disableConcurrentBuilds()
disableConcurrentBuilds()
timeout(time: 90, unit: 'MINUTES')
timestamps()
}
Expand Down
4 changes: 2 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ next. Nodes consult BSS for their target artifacts and boot parameters when node
boot, reboot, or initially power on.

*Configuration Framework Service* (CFS) is a CRD-enabled API that launches and
aggregates status from one or more ansible instances against
aggregates status from one or more ansible instances against
nodes (Node Personalization) or Images (Image Customization).

## Terminology
Expand Down Expand Up @@ -147,7 +147,7 @@ $ ./regenerate_server.sh

## Build Helpers

This repository uses some build helper scripts from the
This repository uses some build helper scripts from the
[`cms-meta-tools`](https://github.com/Cray-HPE/cms-meta-tools) repository. See that repository for more details.

## Local Builds
Expand Down
10 changes: 9 additions & 1 deletion api/openapi.yaml.in
Original file line number Diff line number Diff line change
Expand Up @@ -1047,6 +1047,12 @@ components:
example: 1
minimum: 0
maximum: 1048576
max_component_batch_size:
type: integer
description: The maximum number of components that a BOS operator will process at once. 0 means no limit.
example: 1000
minimum: 0
maximum: 131071
additionalProperties: true

requestBodies:
Expand Down Expand Up @@ -1321,6 +1327,8 @@ paths:
type: array
items:
$ref: '#/components/schemas/Version'
500:
$ref: '#/components/responses/InternalError'

/v2:
get:
Expand All @@ -1335,7 +1343,7 @@ paths:
200:
$ref: '#/components/responses/Version'
500:
$ref: '#/components/responses/BadRequest'
$ref: '#/components/responses/InternalError'
/v2/healthz:
get:
summary: Get service health details
Expand Down
2 changes: 1 addition & 1 deletion config/uwsgi.ini
Original file line number Diff line number Diff line change
Expand Up @@ -14,4 +14,4 @@ virtualenv=/app/venv
# Added to try and help avoid OOM issues, based on
# CASMTRIAGE-5369/CASMTRIAGE-6993
max-requests=1024
harakiri=30
harakiri=30
2 changes: 1 addition & 1 deletion kubernetes/cray-bos/templates/NOTES.txt
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
Installation info for chart {{ include "cray-service.name" . }}:

Usage: Use the cray CLI to interface with BOS.
cray bos --help
cray bos --help
10 changes: 5 additions & 5 deletions kubernetes/cray-bos/templates/tests/test-trial.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -50,15 +50,15 @@ spec:
- name: "{{ .Release.Name }}-test"
image: {{ .Values.tests.image | quote }}
command:
- /usr/bin/curl
- /usr/bin/curl
- -v
- --connect-timeout
- --connect-timeout
- "5"
- --max-time
- --max-time
- "10"
- --retry
- --retry
- "5"
- --retry-delay
- --retry-delay
- "1"
- --retry-connrefused
- http://cray-bos/v2/version
2 changes: 1 addition & 1 deletion setup.cfg
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
[flake8]
max-line-length=110
ignore=F401,W291,W391
exclude =
exclude =
# Exclude the default controllers created by server autogeneration
default_controller.py
# Exclude packaging scripts
Expand Down
2 changes: 1 addition & 1 deletion sonar-project.properties
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ sonar.projectKey=CMS-bos
sonar.projectName=CMS:bos
sonar.projectVersion=1.0.0

sonar.language=py
sonar.language=py
sonar.python.pylint=/usr/local/bin/pylint
sonar.core.codeCoveragePlugin=cobertura

Expand Down
10 changes: 5 additions & 5 deletions src/bos/common/tenant_utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -22,19 +22,20 @@
# OTHER DEALINGS IN THE SOFTWARE.
#

import connexion
import functools
import logging
import hashlib

import connexion
from requests.exceptions import HTTPError
from bos.common.utils import exc_type_msg, requests_retry_session, PROTOCOL

LOGGER = logging.getLogger('bos.common.tenant_utils')

TENANT_HEADER = "Cray-Tenant-Name"
SERVICE_NAME = 'cray-tapms/v1alpha2'
BASE_ENDPOINT = "%s://%s" % (PROTOCOL, SERVICE_NAME)
TENANT_ENDPOINT = "%s/tenants" % BASE_ENDPOINT ## CASMPET-6433 changed this from tenant to tenants
BASE_ENDPOINT = f"{PROTOCOL}://{SERVICE_NAME}"
TENANT_ENDPOINT = f"{BASE_ENDPOINT}/tenants" # CASMPET-6433 changed this from tenant to tenants


class InvalidTenantException(Exception):
Expand Down Expand Up @@ -81,8 +82,7 @@ def get_tenant_data(tenant, session=None):
LOGGER.error("Failed getting tenant data from tapms: %s", exc_type_msg(e))
if response.status_code == 404:
raise InvalidTenantException(f"Data not found for tenant {tenant}") from e
else:
raise
raise
return response.json()


Expand Down
17 changes: 9 additions & 8 deletions src/bos/common/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@
from requests.packages.urllib3.util.retry import Retry

PROTOCOL = 'http'
TIME_DURATION_PATTERN = re.compile("^(\d+?)(\D+?)$", re.M|re.S)
TIME_DURATION_PATTERN = re.compile(r"^(\d+?)(\D+?)$", re.M|re.S)

# Common date and timestamps functions so that timezones and formats are handled consistently.
def get_current_time() -> datetime.datetime:
Expand Down Expand Up @@ -63,9 +63,9 @@ def duration_to_timedelta(timestamp: str):

class TimeoutHTTPAdapter(HTTPAdapter):
"""
An HTTP Adapter that allows a session level timeout for both read and connect attributes. This prevents interruption
to reads that happen as a function of time or istio resets that causes our applications to sit and wait forever on
a half open socket.
An HTTP Adapter that allows a session level timeout for both read and connect attributes.
This prevents interruption to reads that happen as a function of time or istio resets that
causes our applications to sit and wait forever on a half open socket.
"""
def __init__(self, *args, **kwargs):
if "timeout" in kwargs:
Expand Down Expand Up @@ -95,15 +95,15 @@ def requests_retry_session(retries=10, backoff_factor=0.5,
adapter = TimeoutHTTPAdapter(max_retries=retry, timeout=(connect_timeout, read_timeout))
# Must mount to http://
# Mounting to only http will not work!
session.mount("%s://" % protocol, adapter)
session.mount(f"{protocol}://", adapter)
return session


def compact_response_text(response_text: str) -> str:
"""
Often JSON is "pretty printed" in response text, which is undesirable for our logging.
This function transforms the response text into a single line, stripping leading and trailing whitespace from each line,
and then returns it.
This function transforms the response text into a single line, stripping leading and
trailing whitespace from each line, and then returns it.
"""
if response_text:
return ' '.join([ line.strip() for line in response_text.split('\n') ])
Expand All @@ -112,6 +112,7 @@ def compact_response_text(response_text: str) -> str:

def exc_type_msg(exc: Exception) -> str:
"""
Given an exception, returns a string of its type and its text (e.g. TypeError: 'int' object is not subscriptable)
Given an exception, returns a string of its type and its text
(e.g. TypeError: 'int' object is not subscriptable)
"""
return ''.join(traceback.format_exception_only(type(exc), exc))
4 changes: 2 additions & 2 deletions src/bos/common/values.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
#
# MIT License
#
# (C) Copyright 2022 Hewlett Packard Enterprise Development LP
# (C) Copyright 2022, 2024 Hewlett Packard Enterprise Development LP
#
# Permission is hereby granted, free of charge, to any person obtaining a
# copy of this software and associated documentation files (the "Software"),
Expand Down Expand Up @@ -70,4 +70,4 @@ class Status:
EMPTY_STAGED_STATE = {
"configuration": "",
"boot_artifacts": EMPTY_BOOT_ARTIFACTS
}
}
6 changes: 4 additions & 2 deletions src/bos/operators/actual_state_cleanup.py
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,9 @@ def filters(self):
return [
BOSQuery(),
ActualBootStateIsSet(),
ActualStateAge(seconds=duration_to_timedelta(options.component_actual_state_ttl).total_seconds())
ActualStateAge(
seconds=duration_to_timedelta(options.component_actual_state_ttl).total_seconds()
)
]

def _act(self, components):
Expand All @@ -65,7 +67,7 @@ def _act(self, components):
'actual_state': EMPTY_ACTUAL_STATE})
if data:
LOGGER.info('Found %d components that require updates', len(data))
LOGGER.debug('Calling to update with payload: %s' %(data))
LOGGER.debug('Calling to update with payload: %s', data)
self.bos_client.components.update_components(data)
return components

Expand Down
Loading

0 comments on commit 7b90ab2

Please sign in to comment.