Skip to content

Commit

Permalink
Merge branch 'release' into 'master'
Browse files Browse the repository at this point in the history
RELEASE 2.4.0

See merge request arenadata/development/adcm!4120
  • Loading branch information
a-alferov committed Oct 24, 2024
2 parents 7a1db76 + 6ef9359 commit bdf928c
Show file tree
Hide file tree
Showing 305 changed files with 13,862 additions and 7,447 deletions.
8 changes: 5 additions & 3 deletions .dockerignore
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
**/*.git*
**/.*
.*
go/**/.*
python/**/.*
**/tests/
data
venv
adcm-web
dev
venv
91 changes: 64 additions & 27 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -1,19 +1,29 @@
FROM golang:1.23 AS go_builder
COPY ./go /code
WORKDIR /code
RUN sh -c "make"


FROM node:20.9.0-alpine AS ui_builder
ARG ADCM_VERSION
ENV ADCM_VERSION=$ADCM_VERSION
COPY ./adcm-web/app /code
WORKDIR /code
RUN . build.sh


FROM python:3.10-alpine
ENV PATH="/root/.local/bin:$PATH"
RUN apk update && \
apk upgrade && \
apk add --virtual .build-deps \
build-base \
linux-headers && \
apk add \
apk add --no-cache \
bash \
curl \
git \
gnupg \
libc6-compat \
libffi \
libstdc++ \
libxslt \
logrotate \
musl-dev \
nginx \
openldap-dev \
Expand All @@ -23,27 +33,54 @@ RUN apk update && \
rsync \
runit \
sshpass && \
curl -sSL https://install.python-poetry.org | python -
ENV PATH="/root/.local/bin:$PATH"
COPY pyproject.toml /adcm/
COPY poetry.lock /adcm/
RUN python -m venv /adcm/venv/2.9 && \
poetry config virtualenvs.create false && \
poetry -C /adcm install --no-root && \
cp -r /usr/local/lib/python3.10/site-packages /adcm/venv/2.9/lib/python3.10 && \
. /adcm/venv/2.9/bin/activate && \
pip install git+https://github.com/arenadata/ansible.git@v2.9.27-p1 && \
deactivate
RUN apk del .build-deps
COPY . /adcm
RUN mkdir -p /adcm/data/log && \
mkdir -p /usr/share/ansible/plugins/modules && \
cp -r /adcm/os/* / && \
cp /adcm/os/etc/crontabs/root /var/spool/cron/crontabs/root && \
cp -r /adcm/python/ansible/* /usr/local/lib/python3.10/site-packages/ansible/ && \
cp -r /adcm/python/ansible/* /adcm/venv/2.9/lib/python3.10/site-packages/ansible/ && \
python /adcm/python/manage.py collectstatic --noinput && \
cp -r /adcm/wwwroot/static/rest_framework/css/* /adcm/wwwroot/static/rest_framework/docs/css/
apk cache clean --purge

ENV PYTHONDONTWRITECODE=1
ENV PYTHONBUFFERED=1

ENV POETRY_VERSION=1.8.3
ENV POETRY_HOME=/opt/poetry
ENV POETRY_VENV=/opt/poetry-venv
ENV POETRY_CACHE_DIR=/opt/poetry-cache
ENV POETRY_VIRTUALENVS_CREATE=0

COPY poetry.lock pyproject.toml /adcm/

RUN apk add --no-cache --virtual .build-deps \
build-base \
linux-headers \
libffi-dev && \
# remove python links (3.12) from /usr/bin and link python to local one (3.10)
rm /usr/bin/python /usr/bin/python3 && \
ln -s /usr/local/bin/python3 /usr/bin/python3 && \
ln -s /usr/bin/python3 /usr/bin/python && \
python -m venv $POETRY_VENV && \
$POETRY_VENV/bin/pip install --no-cache-dir -U pip setuptools && \
$POETRY_VENV/bin/pip install --no-cache-dir poetry==$POETRY_VERSION && \
$POETRY_VENV/bin/poetry --no-cache --directory=/adcm install --no-root && \
python -m venv /adcm/venv/2.9 --system-site-packages && \
/adcm/venv/2.9/bin/pip install --no-cache-dir git+https://github.com/arenadata/ansible.git@v2.9.27-p1 && \
$POETRY_VENV/bin/poetry cache clear pypi --all && \
apk del .build-deps && \
apk cache clean --purge && \
rm -rf $POETRY_HOME && \
rm -rf $POETRY_VENV && \
rm -rf $POETRY_CACHE_DIR

RUN rm /adcm/poetry.lock /adcm/pyproject.toml

COPY os/etc /etc
COPY os/etc/crontabs/root /var/spool/cron/crontabs/root
COPY --from=go_builder /code/bin/runstatus /adcm/go/bin/runstatus
COPY --from=ui_builder /wwwroot /adcm/wwwroot
COPY conf /adcm/conf
COPY python/ansible/plugins /usr/share/ansible/plugins
COPY python /adcm/python

RUN mkdir -p /adcm/data/log

RUN python /adcm/python/manage.py collectstatic --noinput

ARG ADCM_VERSION
ENV ADCM_VERSION=$ADCM_VERSION
EXPOSE 8000
Expand Down
19 changes: 4 additions & 15 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -3,26 +3,14 @@ APP_IMAGE ?= hub.adsw.io/adcm/adcm
APP_TAG ?= $(subst /,_,$(BRANCH_NAME))
SELENOID_HOST ?= 10.92.2.65
SELENOID_PORT ?= 4444
ADCM_VERSION = "2.3.0"
ADCM_VERSION = "2.4.0"
PY_FILES = python dev/linters conf/adcm/python_scripts

.PHONY: help
.PHONY: build unittests_sqlite unittests_postgresql pretty lint version

help:
@grep -E '^[a-zA-Z_-]+:.*?## .*$$' $(MAKEFILE_LIST) | sort | awk 'BEGIN {FS = ":.*?## "}; {printf "\033[36m%-30s\033[0m %s\n", $$1, $$2}'

buildss:
@docker run -i --rm -v $(CURDIR)/go:/code -w /code golang sh -c "make"

buildjs:
@docker run -i --rm -v $(CURDIR)/wwwroot:/wwwroot -v $(CURDIR)/adcm-web/app:/code -e ADCM_VERSION=$(ADCM_VERSION) -w /code node:18.16-alpine ./build.sh

build_base:
build:
@docker build . -t $(APP_IMAGE):$(APP_TAG) --build-arg ADCM_VERSION=$(ADCM_VERSION)

# build ADCM_v2
build: buildss buildjs build_base

unittests_sqlite:
poetry install --no-root --with unittests
poetry run python/manage.py test python -v 2 --parallel
Expand All @@ -45,6 +33,7 @@ lint:
poetry install --no-root --with lint
poetry run ruff check $(PY_FILES)
poetry run ruff format --check $(PY_FILES)
poetry run pyright --project pyproject.toml
poetry run python dev/linters/license_checker.py --folders $(PY_FILES) go
poetry run python dev/linters/migrations_checker.py python

Expand Down
6 changes: 3 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ git clone https://github.com/arenadata/adcm

cd adcm

# Run build process
# Run build process for current architecture
make build
```

Expand All @@ -64,7 +64,7 @@ clean Cleanup. Just a cleanup.
describe Create .version file with output of describe
help Shows that help
build2js For new design and api v2: Build client side js/html/css in directory wwwroot
build2 For new design and api v2: Build final docker image and all depended targets except baseimage.
build2 For new design and api v2: Build final docker image and all depended targets except baseimage
```
And check out the description for every operation available.
Expand Down Expand Up @@ -152,4 +152,4 @@ _PostgreSQL must be version 11 or newer - JSONB field used_

valid choices are: `DEBUG`, `INFO`, `WARNING`, `ERROR`, `CRITICAL`

defaults to `ERROR`
defaults to `ERROR`
11 changes: 8 additions & 3 deletions adcm-web/app/.husky/pre-commit
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,11 @@
. "$(dirname "$0")/_/husky.sh"

cd adcm-web/app
yarn lint
yarn tsc
echo "lint"

echo "Start lint check";

yarn lint-staged;

echo "Start TS check";

yarn tsc;
28 changes: 28 additions & 0 deletions adcm-web/app/.lintstagedrc.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
import { ESLint } from 'eslint'

const eslintCheck = (filenames) => `eslint ${filenames.join(' ')} --ext ts,tsx --report-unused-disable-directives --max-warnings 0`;

/**
* lint-stage don't understand .eslintignore file
* https://www.curiouslychase.com/posts/eslint-error-file-ignored-because-of-a-matching-ignore-pattern/
*/
const removeIgnoredFiles = async (files) => {
const eslint = new ESLint()
const isIgnored = await Promise.all(
files.map((file) => {
return eslint.isPathIgnored(file)
})
)
return files.filter((_, i) => !isIgnored[i]);
}

export default {
'*.(js|jsx|ts|tsx)': async (filenames) => {
// Run ESLint on entire repo if more than 10 staged files
if (filenames.length > 10) {
return 'yarn lint'
}
const filesToLint = await removeIgnoredFiles(filenames);
return eslintCheck(filesToLint);
}
}
4 changes: 2 additions & 2 deletions adcm-web/app/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,8 @@ This is documentation for ADCM Frontend project part
## Development

### Requirements
1. Node > v18.16.x (recommend use [NVM](https://github.com/nvm-sh/nvm))
2. yarn > v3.5.x ([yarn v3 install](https://yarnpkg.com/getting-started/install))
1. Node > 20.9.x (recommend use [NVM](https://github.com/nvm-sh/nvm))
2. yarn > v4.5.x ([yarn v4 install](https://yarnpkg.com/getting-started/install))

### Start local Backend
```
Expand Down
6 changes: 5 additions & 1 deletion adcm-web/app/build.sh
Original file line number Diff line number Diff line change
@@ -1,5 +1,9 @@
#!/bin/sh

yarn set version berry
# Set Yarn version
YARN_VERSION=4.5.0

corepack enable && corepack prepare yarn@$YARN_VERSION
#yarn set version $YARN_VERSION
yarn install
yarn build --mode production --outDir /wwwroot
7 changes: 4 additions & 3 deletions adcm-web/app/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
"build": "tsc && vite build",
"lint": "eslint src --ext ts,tsx --report-unused-disable-directives --max-warnings 0",
"tsc": "tsc --noEmit",
"postinstall": "[ -z \"`git --version`\" ] && echo \"git dont install\" || (frontSubDir=$(pwd) && cd $(git rev-parse --show-toplevel) && npx husky install \"$frontSubDir/.husky\")",
"postinstall": "[ -z \"`git --version`\" ] && echo \"git dont install\" || (frontSubDir=$(pwd) && cd $(git rev-parse --show-toplevel) && husky \"$frontSubDir/.husky\")",
"preview": "vite preview",
"storybook": "storybook dev -p 6006",
"build-storybook": "storybook build",
Expand Down Expand Up @@ -76,11 +76,12 @@
"eslint-plugin-react-refresh": "0.4.5",
"eslint-plugin-spellcheck": "0.0.20",
"eslint-plugin-storybook": "0.8.0",
"husky": "9.0.11",
"husky": "9.1.6",
"identity-obj-proxy": "3.0.0",
"jest": "29.7.0",
"jest-environment-jsdom": "29.7.0",
"json-schema": "0.4.0",
"lint-staged": "15.2.10",
"prettier": "3.2.5",
"prop-types": "15.8.1",
"sass": "1.71.1",
Expand All @@ -93,5 +94,5 @@
"vite-plugin-svgr": "3.2.0",
"vite-tsconfig-paths": "4.2.0"
},
"packageManager": "yarn@4.0.2"
"packageManager": "yarn@4.5.0"
}
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ import {
type AdcmMappingComponent,
type AdcmMappingComponentService,
type HostId,
AdcmMaintenanceMode,
} from '@models/adcm';
import type {
ComponentAvailabilityErrors,
Expand Down Expand Up @@ -66,5 +67,8 @@ export const checkHostActionsMappingAvailability = (
disabledHosts: Set<HostId> = new Set(),
): string | undefined => {
const isDisabled = !allowActions.has(AdcmHostComponentMapRuleAction.Remove) && disabledHosts.has(host.id);
return isDisabled ? 'Removing host is not allowed in the action configuration' : undefined;
const isHostInMaintenanceMode = host.maintenanceMode === AdcmMaintenanceMode.On;

if (isDisabled) return 'Removing host is not allowed in the action configuration';
if (isHostInMaintenanceMode) return 'The host is in the maintenance mode';
};
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ import ClusterDynamicActionsIcon from '@pages/ClustersPage/ClustersTable/Cluster
import MultiStateCell from '@commonComponents/Table/Cells/MultiStateCell';
import { openClusterUpgradeDialog } from '@store/adcm/clusters/clusterUpgradesSlice';
import { isShowSpinner } from '@uikit/Table/Table.utils';
import { isBlockingConcernPresent } from '@utils/concernUtils.ts';

const ClustersTable = () => {
const dispatch = useDispatch();
Expand Down Expand Up @@ -76,7 +77,7 @@ const ClustersTable = () => {
<IconButton
icon="g1-upgrade"
size={32}
disabled={!cluster.isUpgradable}
disabled={!cluster.isUpgradable || isBlockingConcernPresent(cluster.concerns)}
onClick={() => handleUpgradeClick(cluster)}
title={cluster.isUpgradable ? 'Upgrade' : 'No upgrades'}
/>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ export const useHostProviderConfigGroupConfiguration = () => {
const isVersionsLoading = useStore(({ adcm }) => adcm.entityConfiguration.isVersionsLoading);

useEffect(() => {
if (hostProvider && hostProviderConfigGroup) {
if (hostProvider?.id && hostProviderConfigGroup?.id) {
// load all configurations for current HostProvider
dispatch(
getConfigurationsVersions({
Expand All @@ -34,15 +34,15 @@ export const useHostProviderConfigGroupConfiguration = () => {
return () => {
dispatch(cleanup());
};
}, [hostProvider, hostProviderConfigGroup, dispatch]);
}, [hostProvider?.id, hostProviderConfigGroup?.id, dispatch]);

const configurationsOptions = useConfigurations({
configVersions,
});
const { selectedConfigId, onReset } = configurationsOptions;

useEffect(() => {
if (hostProvider && hostProviderConfigGroup && selectedConfigId) {
if (hostProvider?.id && hostProviderConfigGroup?.id && selectedConfigId) {
// load full config for selected configuration
dispatch(
getConfiguration({
Expand All @@ -55,7 +55,7 @@ export const useHostProviderConfigGroupConfiguration = () => {
}),
);
}
}, [dispatch, hostProvider, hostProviderConfigGroup, selectedConfigId]);
}, [dispatch, hostProvider?.id, hostProviderConfigGroup?.id, selectedConfigId]);

const selectedConfiguration = selectedConfigId === 0 ? configurationsOptions.draftConfiguration : loadedConfiguration;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,23 +18,23 @@ export const useHostProviderPrimaryConfiguration = () => {
const accessCheckStatus = useStore(({ adcm }) => adcm.entityConfiguration.accessCheckStatus);

useEffect(() => {
if (hostProvider) {
if (hostProvider?.id) {
// load all configurations for current HostProvider
dispatch(getConfigurationsVersions({ entityType: 'host-provider', args: { hostProviderId: hostProvider.id } }));
}

return () => {
dispatch(cleanup());
};
}, [hostProvider, dispatch]);
}, [hostProvider?.id, dispatch]);

const configurationsOptions = useConfigurations({
configVersions,
});
const { selectedConfigId, onReset } = configurationsOptions;

useEffect(() => {
if (hostProvider && selectedConfigId) {
if (hostProvider?.id && selectedConfigId) {
// load full config for selected configuration
dispatch(
getConfiguration({
Expand All @@ -43,7 +43,7 @@ export const useHostProviderPrimaryConfiguration = () => {
}),
);
}
}, [dispatch, hostProvider, selectedConfigId]);
}, [dispatch, hostProvider?.id, selectedConfigId]);

const selectedConfiguration = selectedConfigId === 0 ? configurationsOptions.draftConfiguration : loadedConfiguration;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ export const columns: TableColumn[] = [
{
label: 'State',
name: 'state',
isSortable: true,
},
{
label: 'Description',
Expand Down
Loading

0 comments on commit bdf928c

Please sign in to comment.