Skip to content

Commit

Permalink
openshift: use openshift-install from path when internet is missing
Browse files Browse the repository at this point in the history
  • Loading branch information
karmab committed Jan 14, 2025
1 parent 0e60f41 commit f36d3e0
Showing 1 changed file with 13 additions and 2 deletions.
15 changes: 13 additions & 2 deletions kvirt/cluster/openshift/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
import re
from random import choice
from shutil import copy2, move, rmtree, which
from socket import gethostbyname
from socket import gethostbyname, create_connection
from string import ascii_letters, digits
from subprocess import call
import sys
Expand Down Expand Up @@ -203,6 +203,14 @@ def get_installer_version():
return installer_version


def internet_connected():
try:
create_connection(('mirror.openshift.com', 443), 5)
return True
except Exception:
return False


def offline_image(version='stable', tag=OPENSHIFT_TAG, pull_secret='openshift_pull.json'):
tag = str(tag).split(':')[-1]
for arch in ['x86_64', 'amd64', 'arm64', 'ppc64le', 's390x', 'x86_64']:
Expand Down Expand Up @@ -926,7 +934,10 @@ def create(config, plandir, cluster, overrides, dnsconfig=None):
tag = f'registry.ci.openshift.org/{basetag}/release:{tag}'
which_openshift = which('openshift-install')
openshift_dir = os.path.dirname(which_openshift) if which_openshift is not None else '.'
if upstream:
if which_openshift is not None and not internet_connected():
pprint("Using existing openshift-install found in your PATH")
warning("Not checking version")
elif upstream:
run = get_upstream_installer(tag, version=version)
elif not same_release_images(version=version, tag=tag, pull_secret=pull_secret, path=openshift_dir):
if version in ['ci', 'nightly'] or '/' in str(tag):
Expand Down

0 comments on commit f36d3e0

Please sign in to comment.