Skip to content

Commit

Permalink
Merge branch 'support-4.15' into devel
Browse files Browse the repository at this point in the history
  • Loading branch information
mijaros committed Mar 7, 2024
2 parents b4e36c2 + 14f1f77 commit d610916
Show file tree
Hide file tree
Showing 5 changed files with 46 additions and 5 deletions.
23 changes: 23 additions & 0 deletions osia/installer/clouds/base.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,9 +17,14 @@
creation.
It also implements logic to obtain correct specification
for specified installation platform"""

import logging

from abc import abstractmethod, ABC
from subprocess import run
from typing import ClassVar, Optional
from jinja2 import Environment, PackageLoader
from semantic_version import Version, SimpleSpec


class AbstractInstaller(ABC):
Expand Down Expand Up @@ -60,6 +65,8 @@ def __init__(self,
self.skip_clean = skip_clean
self.installer = installer
self.enable_fips = enable_fips
self.ocp_version = None
self.network_type = "OVNKubernetes"

@abstractmethod
def acquire_resources(self):
Expand All @@ -86,13 +93,29 @@ def get_apps_ip(self):
"""Returns apps ip if dns is supported, None otherwise
"""

def _resolve_version(self):
if self.ocp_version is None:
capture = run([self.installer, "version"], capture_output=True, check=False)
ver_string = capture.stdout.decode("utf-8").splitlines()[0].split(' ')[1]
self.ocp_version = ver_string
logging.info("Resolved installed version as %s", self.ocp_version)

def _resolve_network_type(self):
self._resolve_version()
ver = Version(self.ocp_version)
spec = SimpleSpec('<4.15')
if ver in spec:
logging.debug("Older version of openshift, falling back to OpenShiftSDN")
self.network_type = 'OpenShiftSDN'

def check_clean(self):
"""Method returns if installation is configured to clean resources
on failure."""
return not self.skip_clean

def process_template(self):
"""Method executes creation of install-config.yaml"""
self._resolve_network_type()
with open(self.pull_secret_file) as ps_file:
self.pull_secret = ps_file.read()
with open(self.ssh_key_file) as key_file:
Expand Down
2 changes: 1 addition & 1 deletion osia/installer/templates/install-config-base.yaml.jinja2
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ networking:
- cidr: 10.128.0.0/14
hostPrefix: 23
machineCIDR: {% block networkIp %}{% endblock %}
networkType: OpenShiftSDN
networkType: {{ network_type }}
serviceNetwork:
- 172.30.0.0/16
platform:{% block platform %}{% endblock %}
Expand Down
18 changes: 17 additions & 1 deletion poetry.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

7 changes: 4 additions & 3 deletions pylintrc
Original file line number Diff line number Diff line change
Expand Up @@ -73,7 +73,8 @@ disable=raw-checker-failed,
unused-private-member,
missing-timeout,
unnecessary-dunder-call,
use-dict-literal
use-dict-literal,
broad-exception-raised #TODO fix this in next release

# Enable the message, report, category or checker with the given id(s). You can
# either give multiple identifier separated by comma (,) or put this option
Expand Down Expand Up @@ -506,5 +507,5 @@ valid-metaclass-classmethod-first-arg=cls

# Exceptions that will emit a warning when being caught. Defaults to
# "BaseException, Exception".
overgeneral-exceptions=BaseException,
Exception
overgeneral-exceptions=builtins.BaseException,
builtins.Exception
1 change: 1 addition & 0 deletions pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@ gitpython = "*"
beautifulsoup4 = "*"
coloredlogs = "*"
urllib3 = "<2" # add temporarily to enable dependency resolution in real time
semantic-version = "^2.10.0"

[tool.poetry.dev-dependencies]
flake8 = "*"
Expand Down

0 comments on commit d610916

Please sign in to comment.