Skip to content

Commit

Permalink
openshift: handle single masters for 4.4+
Browse files Browse the repository at this point in the history
  • Loading branch information
karmab committed Apr 23, 2020
1 parent 36706e5 commit f809512
Show file tree
Hide file tree
Showing 2 changed files with 30 additions and 0 deletions.
28 changes: 28 additions & 0 deletions kvirt/common/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,17 @@
systemctl restart NetworkManager
fi"""

ceo_yaml = """apiVersion: operator.openshift.io/v1
kind: Etcd
metadata:
name: cluster
annotations:
release.openshift.io/create-only: "true"
spec:
managementState: Managed
unsupportedConfigOverrides:
useUnsupportedUnsafeNonHANonProductionUnstableEtcd: true"""


def url_exists(url):
try:
Expand Down Expand Up @@ -1055,11 +1066,28 @@ def ignition(name, keys=[], cmds=[], nets=[], gateway=None, dns=None, domain=Non
# remove duplicate files to please ignition v3
paths = []
storagefinal = []
fix_ceo = overrides.get('fix_ceo', False)
for fileentry in data['storage']['files']:
if fileentry['path'] not in paths:
if fix_ceo and 'bootstrap' in name and fileentry['path'] == '/usr/local/bin/bootkube.sh':
pprint("Patching bootkube in bootstrap ignition to handle single master", color='blue')
content = base64.b64decode(fileentry['contents']['source'].split(',')[1])
ceofix = """cp etcd-bootstrap/manifests/* manifests/
cp /root/ceo.yaml manifests/0000_12_etcd-operator_01_operator.cr.yaml"""
content = content.decode("utf-8")
newcontent = content.replace('cp etcd-bootstrap/manifests/* manifests/', ceofix)
newcontent = base64.b64encode(newcontent.encode()).decode("UTF-8")
newcontent = "data:text/plain;charset=utf-8;base64,%s" % newcontent
fileentry['contents']['source'] = newcontent
storagefinal.append(fileentry)
paths.append(fileentry['path'])
data['storage']['files'] = storagefinal
if fix_ceo and 'bootstrap' in name:
ceo_base64 = base64.b64encode(ceo_yaml.encode()).decode("UTF-8")
ceo_source = "data:text/plain;charset=utf-8;base64,%s" % ceo_base64
ceo_entry = {"filesystem": "root", "path": "/root/ceo.yaml",
"contents": {"source": ceo_source, "verification": {}}, "mode": 420}
data['storage']['files'].append(ceo_entry)
try:
result = json.dumps(data, sort_keys=True, indent=indent, separators=separators)
except:
Expand Down
2 changes: 2 additions & 0 deletions kvirt/openshift/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -477,6 +477,8 @@ def create(config, plandir, cluster, overrides):
sedcmd += '%s/master.ign' % clusterdir
sedcmd += ' > %s/bootstrap.ign' % clusterdir
call(sedcmd, shell=True)
if masters == 1 and (upstream or int(COS_VERSION) > 43):
overrides['fix_ceo'] = True
if platform in virtplatforms:
if disconnected_deploy:
disconnected_vm = "%s-disconnecter" % cluster
Expand Down

0 comments on commit f809512

Please sign in to comment.