From 1c68abc12114a9931aecc6cfd474454aa41b0bca Mon Sep 17 00:00:00 2001 From: Mike Bonnet Date: Feb 15 2019 23:38:23 +0000 Subject: [PATCH 1/5] deploy the UMB with more resources --- diff --git a/resources/openshift/templates/umb.yaml b/resources/openshift/templates/umb.yaml index c8fdeb1..80e7d9c 100644 --- a/resources/openshift/templates/umb.yaml +++ b/resources/openshift/templates/umb.yaml @@ -173,8 +173,8 @@ objects: setenv: | - JAVA_MIN_MEM=256m - JAVA_MAX_MEM=1024m + JAVA_MIN_MEM=512m + JAVA_MAX_MEM=1280m - apiVersion: v1 kind: Secret metadata: @@ -253,8 +253,8 @@ objects: memory: 512Mi cpu: 300m limits: - memory: 1024Mi - cpu: 500m + memory: 1536Mi + cpu: 1000m ports: - containerPort: 1099 name: rmi-management From 1c62ea8690dcb706bfe211969e04e475a3f6ea30 Mon Sep 17 00:00:00 2001 From: Mike Bonnet Date: Feb 15 2019 23:38:33 +0000 Subject: [PATCH 2/5] mount the CA certs in the proper location --- diff --git a/resources/openshift/templates/koji.yaml b/resources/openshift/templates/koji.yaml index 08c31e6..2984b3d 100644 --- a/resources/openshift/templates/koji.yaml +++ b/resources/openshift/templates/koji.yaml @@ -313,7 +313,7 @@ objects: name: koji-volume - mountPath: /etc/pki/koji/certs name: koji-hub-certs-vol - - mountPath: /etc/pki/tls/certs/ca-bundle.crt + - mountPath: /etc/pki/tls/cert.pem name: koji-hub-certs-vol subPath: kojica.crt - mountPath: /etc/httpd/conf.d/ssl.conf diff --git a/resources/openshift/templates/mbs.yaml b/resources/openshift/templates/mbs.yaml index 5bc27f0..ef3d4ec 100644 --- a/resources/openshift/templates/mbs.yaml +++ b/resources/openshift/templates/mbs.yaml @@ -352,7 +352,7 @@ objects: service: frontend environment: test-${TEST_ID} data: - ca-bundle.crt: |- + cert-bundle: |- ${CA_CERTS} - apiVersion: v1 kind: Secret @@ -475,7 +475,8 @@ objects: mountPath: /etc/koji-certs readOnly: true - name: cacerts-vol - mountPath: /etc/pki/tls/certs + mountPath: /etc/pki/tls/cert.pem + subPath: cert-bundle readOnly: true resources: limits: @@ -831,7 +832,8 @@ objects: mountPath: /etc/koji-certs readOnly: true - name: cacerts-vol - mountPath: /etc/pki/tls/certs + mountPath: /etc/pki/tls/cert.pem + subPath: cert-bundle readOnly: true resources: limits: From ea212e31719c1e9f88141a2a232c1046df524781 Mon Sep 17 00:00:00 2001 From: Mike Bonnet Date: Feb 15 2019 23:38:33 +0000 Subject: [PATCH 3/5] rename the run method to not conflict with a builtin method --- diff --git a/vars/koji.groovy b/vars/koji.groovy index 4484cb9..4125622 100644 --- a/vars/koji.groovy +++ b/vars/koji.groovy @@ -57,7 +57,7 @@ def setConfig(huburl, topurl, cert, key, cacerts) { "cacerts": cacerts] } -def run(cmd, String... args) { +def runCmd(cmd, String... args) { _writeConfig() def kojicmd = "${_kojicmd} ${cmd}" for (arg in args) { @@ -71,7 +71,7 @@ def addTag(name, String... args) { for (arg in args) { newargs.add(arg) } - run("add-tag", newargs as String[]) + runCmd("add-tag", newargs as String[]) } def _runScript(name, String... args) { From 014295fca177cabca67861d41ca1915fbd5b355d Mon Sep 17 00:00:00 2001 From: Mike Bonnet Date: Feb 15 2019 23:38:33 +0000 Subject: [PATCH 4/5] return the output of runCmd() --- diff --git a/vars/koji.groovy b/vars/koji.groovy index 4125622..67354dd 100644 --- a/vars/koji.groovy +++ b/vars/koji.groovy @@ -71,7 +71,7 @@ def addTag(name, String... args) { for (arg in args) { newargs.add(arg) } - runCmd("add-tag", newargs as String[]) + return runCmd("add-tag", newargs as String[]) } def _runScript(name, String... args) { From 0fa213b194c7130006672c3b82ab44621085f98f Mon Sep 17 00:00:00 2001 From: Mike Bonnet Date: Feb 15 2019 23:38:33 +0000 Subject: [PATCH 5/5] add a mechanism to call arbitrary API methods --- diff --git a/resources/python/callMethod.py b/resources/python/callMethod.py new file mode 100644 index 0000000..f5cc718 --- /dev/null +++ b/resources/python/callMethod.py @@ -0,0 +1,45 @@ +#!/usr/bin/python3 + +import sys +import koji +import json + + +def convert_args(args): + newargs = [] + newkws = {} + for arg in args: + if '=' in arg: + key, val = arg.split('=', 1) + newkws[key] = convert_arg(val) + else: + newargs.append(convert_arg(arg)) + return newargs, newkws + +def convert_arg(arg): + if arg.lower() == 'true': + return True + elif arg.lower() == 'false': + return False + elif arg.lower() in ['nil', 'null', 'none']: + return None + elif arg.isdigit(): + return int(arg) + else: + return arg + + +opts = koji.read_config(sys.argv[2], user_config=sys.argv[1] + '/config') +session_opts = koji.grab_session_options(opts) +session = koji.ClientSession(opts['server'], session_opts) + +login = convert_arg(sys.argv[3]) +if login: + session.ssl_login(cert=opts['cert'], serverca=opts['serverca']) + +name = sys.argv[4] +method = getattr(session, name) +args, kws = convert_args(sys.argv[5:]) +output = method(*args, **kws) + +json.dump(output, sys.stdout) diff --git a/vars/koji.groovy b/vars/koji.groovy index 67354dd..4b0cf43 100644 --- a/vars/koji.groovy +++ b/vars/koji.groovy @@ -57,7 +57,7 @@ def setConfig(huburl, topurl, cert, key, cacerts) { "cacerts": cacerts] } -def runCmd(cmd, String... args) { +def runCmd(cmd, Object... args) { _writeConfig() def kojicmd = "${_kojicmd} ${cmd}" for (arg in args) { @@ -66,15 +66,15 @@ def runCmd(cmd, String... args) { return sh(script: kojicmd, returnStdout: true).trim() } -def addTag(name, String... args) { +def addTag(name, Object... args) { def newargs = [name] for (arg in args) { newargs.add(arg) } - return runCmd("add-tag", newargs as String[]) + return runCmd("add-tag", newargs as Object[]) } -def _runScript(name, String... args) { +def _runScript(name, Object... args) { _writeConfig() def script = libraryResource "python/${name}.py" writeFile(file: "${_confdir}/cmd", text: script) @@ -109,3 +109,19 @@ def listTasks() { def listBuilds() { return _runScript("listBuilds") } + +def callMethod(name, Object... args) { + return _handleCall("false", name, args) +} + +def callMethodLogin(name, Object... args) { + return _handleCall("true", name, args) +} + +def _handleCall(login, name, args) { + def newargs = [login, name] + for (arg in args) { + newargs.add(arg) + } + return _runScript("callMethod", newargs as Object[]) +}