Skip to content
Open
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
11 changes: 6 additions & 5 deletions kvirt/baseconfig.py
Original file line number Diff line number Diff line change
Expand Up @@ -996,7 +996,7 @@ def create_app_openshift(self, app, overrides={}, outputdir=None):
app_data['hypershift'] = True
return common.create_app_generic(self, app, appdir, overrides=overrides, outputdir=outputdir)
else:
name, catalog, channel, csv, description, namespace, channels, crds = common.olm_app(app, overrides)
name, catalog, channel, csv, description, namespace, channels, crds, installmode = common.olm_app(app, overrides)
if name is None:
error(f"Couldn't find any app matching {app}. Skipping...")
return 1
Expand All @@ -1009,7 +1009,7 @@ def create_app_openshift(self, app, overrides={}, outputdir=None):
channel = overrides_channel
if 'namespace' in overrides:
namespace = overrides['namespace']
app_data = {'catalog': catalog, 'channel': channel, 'namespace': namespace, 'csv': csv}
app_data = {'catalog': catalog, 'channel': channel, 'namespace': namespace, 'csv': csv, 'installmode': installmode}
app_data.update(overrides)
return common.create_app_openshift(self, app, appdir, app_data, outputdir)

Expand Down Expand Up @@ -1038,11 +1038,11 @@ def delete_app_openshift(self, app, overrides={}):
app_data['hypershift'] = True
return common.delete_app_generic(self, app, appdir, app_data)
else:
name, catalog, channel, csv, description, namespace, channels, crds = common.olm_app(app, overrides)
name, catalog, channel, csv, description, namespace, channels, crds, installmode = common.olm_app(app, overrides)
if name is None:
error(f"Couldn't find any app matching {app}. Skipping...")
return 1
app_data = {'catalog': catalog, 'channel': channel, 'namespace': namespace, 'crds': crds}
app_data = {'catalog': catalog, 'channel': channel, 'namespace': namespace, 'crds': crds, 'installmode': installmode}
app_data.update(overrides)
return common.delete_app_openshift(self, app, appdir, app_data)

Expand Down Expand Up @@ -1074,7 +1074,7 @@ def info_app_eks(self, app):
def info_app_openshift(self, app, overrides={}):
plandir = os.path.dirname(openshift.create.__code__.co_filename)
if app not in kdefaults.LOCAL_OPENSHIFT_APPS:
name, catalog, defaultchannel, csv, description, target_namespace, channels, crds = olm_app(app, overrides)
name, catalog, defaultchannel, csv, description, target_namespace, channels, crds, installmode = olm_app(app, overrides)
if name is None:
warning(f"Couldn't find any app matching {app}")
else:
Expand All @@ -1084,6 +1084,7 @@ def info_app_openshift(self, app, overrides={}):
print(f"channel: {defaultchannel}")
print(f"target namespace: {target_namespace}")
print(f"csv: {csv}")
print(f"installmode: {installmode}")
print(f"description:\n{description}")
app = name
appdir = f"{plandir}/apps/{app}"
Expand Down
8 changes: 4 additions & 4 deletions kvirt/cluster/hypershift/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -418,8 +418,8 @@ def create(config, plandir, cluster, overrides):
kubevirt_crd_cmd = 'oc get crd hyperconvergeds.hco.kubevirt.io -o yaml 2>/dev/null'
if kubevirt and safe_load(os.popen(kubevirt_crd_cmd).read()) is None:
warning("Kubevirt not fully installed. Installing it for you")
app_name, source, channel, csv, description, x_namespace, channels, crds = olm_app('kubevirt-hyperconverged')
app_data = {'name': app_name, 'source': source, 'channel': channel, 'namespace': x_namespace, 'csv': csv}
app_name, source, channel, csv, description, x_namespace, channels, crds, installmode = olm_app('kubevirt-hyperconverged')
app_data = {'name': app_name, 'source': source, 'channel': channel, 'namespace': x_namespace, 'csv': csv, 'installmode': installmode}
result = config.create_app_openshift(app_name, app_data)
if result != 0:
return {'result': 'failure', 'reason': "Couldnt install kubevirt properly"}
Expand All @@ -437,10 +437,10 @@ def create(config, plandir, cluster, overrides):
warning("Hypershift needed. Installing it for you")
if need_assisted:
warning("Assisted needed. Installing it for you")
app_name, source, channel, csv, description, x_namespace, channels, crds = olm_app('multicluster-engine')
app_name, source, channel, csv, description, x_namespace, channels, crds, installmode = olm_app('multicluster-engine')
app_data = {'name': app_name, 'source': source, 'channel': channel, 'namespace': x_namespace, 'csv': csv,
'mce_hypershift': mce_hypershift, 'assisted': need_assisted, 'version': version, 'tag': tag,
'pull_secret': pull_secret}
'pull_secret': pull_secret, 'installmode': installmode}
result = config.create_app_openshift(app_name, app_data)
if result != 0:
return {'result': 'failure', 'reason': "Couldnt install mce properly"}
Expand Down
2 changes: 2 additions & 0 deletions kvirt/cluster/openshift/apps/install.yml.j2
Original file line number Diff line number Diff line change
Expand Up @@ -12,8 +12,10 @@ metadata:
name: {{ name }}-operatorgroup
namespace: {{ namespace }}
spec:
{% if installmode = 'namespaced' %}
targetNamespaces:
- {{ namespace }}
{% endif %}
---
{% endif %}
apiVersion: operators.coreos.com/v1alpha1
Expand Down
17 changes: 8 additions & 9 deletions kvirt/common/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -2020,27 +2020,26 @@ def olm_app(package, overrides={}):
catalog = status['catalogSource']
defaultchannel = status['defaultChannel']
channels = []
own = True
for channel in status['channels']:
channels.append(channel['name'])
if channel['name'] == defaultchannel:
csv = channel['currentCSV']
description = channel['currentCSVDesc']['description']
installmodes = channel['currentCSVDesc']['installModes']
for mode in installmodes:
if mode['type'] == 'OwnNamespace' and not mode['supported']:
target_namespace = 'openshift-operators'
own = False
break
installmodes = {mode['type']: mode['supported'] for mode in channel['currentCSVDesc']['installModes']}
csvdesc = channel['currentCSVDesc']
csvdescannotations = csvdesc['annotations']
if own and 'operatorframework.io/suggested-namespace' in csvdescannotations:
if not installmodes['OwnNamespace']:
target_namespace = 'openshift-operators'
elif 'operatorframework.io/suggested-namespace' in csvdescannotations:
target_namespace = csvdescannotations['operatorframework.io/suggested-namespace']

installmode = 'all' if installmodes['AllNamespaces'] else 'namespaced'

crds = []
if 'customresourcedefinitions' in csvdesc and 'owned' in csvdesc['customresourcedefinitions']:
for crd in csvdesc['customresourcedefinitions']['owned']:
crds.append(crd['name'])
return name, catalog, defaultchannel, csv, description, target_namespace, channels, crds
return name, catalog, defaultchannel, csv, description, target_namespace, channels, crds, installmode


def need_fake():
Expand Down