Skip to content

UI: Display an error message and disable salt actions when salt is unavailable #3118

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

Closed
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 6 additions & 0 deletions buildchain/buildchain/image.py
Original file line number Diff line number Diff line change
Expand Up @@ -240,6 +240,12 @@ def _operator_image(name: str, **kwargs: Any) -> targets.OperatorImage:
name="salt-master",
build_args={"SALT_VERSION": versions.SALT_VERSION},
),
_local_image(
name="shell-ui",
build_context=ROOT / "shell-ui",
dockerfile=ROOT / "shell-ui" / "Dockerfile",
file_dep=(list(coreutils.ls_files_rec(ROOT / "shell-ui"))),
),
_local_image(
name="metalk8s-ui",
build_context=config.BUILD_ROOT,
Expand Down
24 changes: 15 additions & 9 deletions buildchain/buildchain/salt_tree.py
Original file line number Diff line number Diff line change
Expand Up @@ -191,7 +191,7 @@ def _get_parts(self) -> Iterator[str]:
SCALITY_LOGO: Path = constants.UI_ASSETS / "login/logo.png"
SCALITY_FAVICON: Path = constants.UI_ASSETS / "login/favicon.png"
LOGIN_STYLE: Path = constants.UI_ASSETS / "login/styles.css"
UI_THEME_OPTIONS: Path = constants.UI_BRANDING / "theme.json"
UI_THEME_OPTIONS: Path = constants.ROOT / "shell-ui" / "theme.json"

# List of salt files to install.
SALT_FILES: Tuple[Union[Path, targets.AtomicTarget], ...] = (
Expand Down Expand Up @@ -362,16 +362,17 @@ def _get_parts(self) -> Iterator[str]:
"salt/metalk8s/addons/prometheus-operator/deployed/",
"service-configuration.sls",
),
Path("salt/metalk8s/addons/ui/deployed/dependencies.sls"),
Path("salt/metalk8s/addons/ui/deployed/ingress.sls"),
Path("salt/metalk8s/addons/ui/deployed/init.sls"),
Path("salt/metalk8s/addons/ui/deployed/files/metalk8s-ui-deployment.yaml"),
Path("salt/metalk8s/addons/ui/deployed/namespace.sls"),
Path("salt/metalk8s/addons/shell-ui/deployed/ingress.sls"),
Path("salt/metalk8s/addons/shell-ui/deployed/init.sls"),
Path("salt/metalk8s/addons/shell-ui/deployed/files/shell-ui-deployment.yaml"),
Path("salt/metalk8s/addons/shell-ui/deployed/namespace.sls"),
targets.TemplateFile(
task_name="salt/metalk8s/addons/ui/deployed/ui.sls",
source=constants.ROOT.joinpath("salt/metalk8s/addons/ui/deployed/ui.sls.in"),
task_name="salt/metalk8s/addons/shell-ui/deployed/shell-ui.sls",
source=constants.ROOT.joinpath(
"salt/metalk8s/addons/shell-ui/deployed/shell-ui.sls.in"
),
destination=constants.ISO_ROOT.joinpath(
"salt/metalk8s/addons/ui/deployed/ui.sls"
"salt/metalk8s/addons/shell-ui/deployed/shell-ui.sls"
),
context={
"ThemeConfig": textwrap.indent(
Expand All @@ -380,6 +381,11 @@ def _get_parts(self) -> Iterator[str]:
},
file_dep=[UI_THEME_OPTIONS],
),
Path("salt/metalk8s/addons/ui/deployed/dependencies.sls"),
Path("salt/metalk8s/addons/ui/deployed/ingress.sls"),
Path("salt/metalk8s/addons/ui/deployed/init.sls"),
Path("salt/metalk8s/addons/ui/deployed/files/metalk8s-ui-deployment.yaml"),
Path("salt/metalk8s/addons/ui/deployed/ui.sls"),
Path("salt/metalk8s/addons/solutions/deployed/configmap.sls"),
Path("salt/metalk8s/addons/solutions/deployed/init.sls"),
Path("salt/metalk8s/addons/solutions/deployed/namespace.sls"),
Expand Down
5 changes: 5 additions & 0 deletions buildchain/buildchain/versions.py
Original file line number Diff line number Diff line change
Expand Up @@ -202,6 +202,11 @@ def _version_prefix(version: str, prefix: str = "v") -> str:
version=VERSION,
digest=None,
),
Image(
name="shell-ui",
version=VERSION,
digest=None,
),
Image(
name="metalk8s-utils",
version=VERSION,
Expand Down
5 changes: 4 additions & 1 deletion eve/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -1176,6 +1176,9 @@ stages:
application:
context: 'ui'
dockerfile: eve/workers/pod-integration-tests/ui/app.Dockerfile
shell-ui:
context: 'shell-ui'
dockerfile: eve/workers/pod-integration-tests/ui/shell-ui.Dockerfile
steps:
- Git: *git_pull
- ShellCommand:
Expand All @@ -1189,7 +1192,7 @@ stages:
name: Install Cypress and its dependencies
workdir: build/ui
command: |
PKGS="cypress cypress-cucumber-preprocessor cypress-wait-until"
PKGS="cypress cypress-cucumber-preprocessor cypress-wait-until @testing-library/cypress"
for pkg in $PKGS; do
npm install --no-save --no-package-lock $pkg@$(node -p \
-e "require('./package-lock.json').dependencies['$pkg'].version" \
Expand Down
53 changes: 51 additions & 2 deletions eve/workers/pod-integration-tests/ui/pod.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,39 @@ kind: Pod
metadata:
name: "metalk8s-integration-tests-ui"
spec:
initContainers:
- name: shell-ui
image: {{ images['shell-ui'] }}
resources:
requests:
cpu: 250m
memory: 200Mi
limits:
cpu: 350m
memory: 300Mi
command: ["/bin/sh"]
args:
- -c
- |
mkdir -p /etc/metalk8s/shell-ui
cat > /etc/metalk8s/shell-ui/config.json <<EOF
{
"docUrl": "/docs",
"oidc": {
"providerUrl": "/oidc",
"redirectUrl": "/",
"clientId": "metalk8s-ui",
"responseType": "id_token",
"scopes": "openid profile email groups offline_access audience:server:client_id:oidc-auth-client"
}
}
EOF
cd /usr/share/nginx/html
/entrypoint.sh echo 'entrypoint'
cp -r /usr/share/nginx/html/ /tmp/shell-ui-files
volumeMounts:
- name: shell-ui-files
mountPath: /tmp/shell-ui-files
containers:
- name: worker
image: {{ images['worker'] }}
Expand All @@ -18,6 +51,9 @@ spec:
volumeMounts:
- name: worker-workspace
mountPath: /home/eve/workspace
- name: debug
mountPath: /tmp/debug

- name: application
image: {{ images['application'] }}
resources:
Expand All @@ -27,12 +63,25 @@ spec:
limits:
cpu: 350m
memory: 300Mi
command: ["nginx"]
args: ["-g", "daemon off;"]
command: ["/bin/sh"]
args:
- -c
- |
cp -r /tmp/shell-ui-files/html/shell/ /usr/share/nginx/html/
nginx -g 'daemon off;' 2>&1 > /tmp/debug/nginx.logs
ports:
- containerPort: 80
name: http
protocol: TCP
volumeMounts:
- name: shell-ui-files
mountPath: /tmp/shell-ui-files
- name: debug
mountPath: /tmp/debug
volumes:
- name: debug
emptyDir: {}
- name: worker-workspace
emptyDir: {}
- name: shell-ui-files
emptyDir: {}
48 changes: 48 additions & 0 deletions eve/workers/pod-integration-tests/ui/shell-ui.Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,48 @@
FROM centos:7

ENV LANG=en_US.utf8

RUN curl -sL https://rpm.nodesource.com/setup_12.x | bash -
RUN yum install -y --setopt=skip_missing_names_on_install=False \
epel-release \
&& \
yum install -y --setopt=skip_missing_names_on_install=False \
git \
nginx \
nodejs

COPY shell-ui-docker-entrypoint.sh /docker-entrypoint.sh
RUN chmod +x /docker-entrypoint.sh

COPY entrypoint.sh /entrypoint.sh
RUN chmod +x /entrypoint.sh

ENTRYPOINT [ "/entrypoint.sh" ]

COPY conf/nginx.conf /etc/nginx/conf.d/default.conf
RUN rm -rf /usr/share/nginx/html/*

# UI build (cannot use build stages for now) {{{

RUN adduser -u 1000 --home /home/node node

USER node
WORKDIR /home/node

COPY package.json package-lock.json /home/node/

RUN npm ci

COPY webpack.*.js babel.config.js .flowconfig /home/node/
COPY src /home/node/src/

RUN npm run build

USER root

# }}}

RUN mkdir -p /usr/share/nginx/html/shell
RUN cp -r dist/* /usr/share/nginx/html/shell

CMD ["nginx", "-g", "daemon off;"]
2 changes: 1 addition & 1 deletion images/metalk8s-ui/conf/nginx.conf
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ server {
alias /etc/metalk8s/ui/config/config.json;
}

# Use the theme provided by the customer
# Use the theme provided by the customer TODO discards this once it is managed by the navbar
location ~ /brand/(.+) {
alias /;
try_files /etc/metalk8s/ui/brand/$1 /usr/share/nginx/html/brand/$1 =404;
Expand Down
2 changes: 1 addition & 1 deletion salt/metalk8s/addons/dex/config/dex.yaml.j2
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@ spec:
- id: metalk8s-ui
name: MetalK8s UI
redirectURIs:
- https://{{ grains.metalk8s.control_plane_ip }}:8443/oauth2/callback
- https://{{ grains.metalk8s.control_plane_ip }}:8443/
secret: ybrMJpVMQxsiZw26MhJzCjA2ut
- id: grafana-ui
name: Grafana UI
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,70 @@
{%- from "metalk8s/repo/macro.sls" import build_image_name with context -%}
apiVersion: apps/v1
kind: Deployment
metadata:
name: shell-ui
namespace: metalk8s-ui
labels:
app: shell-ui
heritage: metalk8s
app.kubernetes.io/name: shell-ui
app.kubernetes.io/component: shell-ui
app.kubernetes.io/part-of: metalk8s
app.kubernetes.io/managed-by: salt
spec:
selector:
matchLabels:
app: shell-ui
template:
metadata:
labels:
app: shell-ui
spec:
tolerations:
- key: "node-role.kubernetes.io/bootstrap"
operator: "Exists"
effect: "NoSchedule"
- key: "node-role.kubernetes.io/infra"
operator: "Exists"
effect: "NoSchedule"
nodeSelector:
kubernetes.io/os: linux
node-role.kubernetes.io/infra: ''
containers:
- name: shell-ui
image: {{ build_image_name('shell-ui') }}
imagePullPolicy: IfNotPresent
resources:
limits:
memory: 170Mi
requests:
cpu: 100m
memory: 70Mi
ports:
- containerPort: 80
name: http
protocol: TCP
livenessProbe:
httpGet:
path: /shell/health
port: http
scheme: HTTP
readinessProbe:
httpGet:
path: /shell/health
port: http
scheme: HTTP
volumeMounts:
- name: shell-ui-volume
mountPath: /etc/metalk8s/shell-ui
readOnly: true
- name: ui-branding-volume
mountPath: /etc/metalk8s/shell-ui/brand
readOnly: true
volumes:
- name: shell-ui-volume
configMap:
name: shell-ui
- name: ui-branding-volume
configMap:
name: ui-branding
25 changes: 25 additions & 0 deletions salt/metalk8s/addons/shell-ui/deployed/ingress.sls
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
#! metalk8s_kubernetes
---
apiVersion: networking.k8s.io/v1beta1
kind: Ingress
metadata:
name: shell-ui
namespace: metalk8s-ui
labels:
app: shell-ui
app.kubernetes.io/managed-by: salt
app.kubernetes.io/name: shell-ui
app.kubernetes.io/part-of: metalk8s
heritage: metalk8s
annotations:
nginx.ingress.kubernetes.io/backend-protocol: "HTTP"
nginx.ingress.kubernetes.io/rewrite-target: /shell/$2
kubernetes.io/ingress.class: "nginx-control-plane"
spec:
rules:
- http:
paths:
- path: /shell(/|$)(.*)
backend:
serviceName: shell-ui
servicePort: 80
4 changes: 4 additions & 0 deletions salt/metalk8s/addons/shell-ui/deployed/init.sls
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
include:
- .namespace
- .shell-ui
- .ingress
Loading