Skip to content
This repository has been archived by the owner on Oct 23, 2024. It is now read-only.

Commit

Permalink
Quota backward compatibility (#311)
Browse files Browse the repository at this point in the history
* Add backwards compatibility for pre 1.14 clusters for Quota support.

* Maintain minDcosVersion=1.10 as with existing releases.
  • Loading branch information
kaiwalyajoshi authored Oct 24, 2019
1 parent 8d2eae5 commit 722dbc2
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 12 deletions.
30 changes: 19 additions & 11 deletions scripts/bootstrap.py
Original file line number Diff line number Diff line change
Expand Up @@ -106,18 +106,8 @@ def populate_known_hosts(hosts, dest_file):

def main():
try:
mesos_allocation_role=os.environ['MESOS_ALLOCATION_ROLE']
jenkins_agent_role=os.environ['JENKINS_AGENT_ROLE']
if _str2bool(os.environ['MARATHON_APP_ENFORCE_GROUP_ROLE']):
if mesos_allocation_role != jenkins_agent_role:
print("WARN: JENKINS_AGENT_ROLE:'{}' not the same as MESOS_ALLOCATION_ROLE:'{}'. "
"enforceRole detected on top-level group, using '{}' as agent-role.".format(
jenkins_agent_role, mesos_allocation_role, mesos_allocation_role))
jenkins_agent_role = mesos_allocation_role
print("INFO: using enforced group role '{}' for agents.".format(jenkins_agent_role))
else:
print("INFO: using non-enforced group role '{}' for agents".format(jenkins_agent_role))
jenkins_agent_user = os.environ['JENKINS_AGENT_USER']
jenkins_agent_role=os.environ['JENKINS_AGENT_ROLE']
jenkins_home_dir = os.environ['JENKINS_HOME']
jenkins_framework_name = os.environ['JENKINS_FRAMEWORK_NAME']
jenkins_app_context = os.environ['JENKINS_CONTEXT']
Expand All @@ -134,6 +124,24 @@ def main():
print("ERROR: missing required environment variable {}.".format(e.args[0]))
return 1

# Determine if we're in a cluster that supports Quota enforcement via the two
# Environment variables MESOS_ALLOCATION_ROLE annd MARATHON_APP_ENFORCE_GROUP_ROLE
# Otherwise continue to use legacy semantics.
try:
mesos_allocation_role=os.environ['MESOS_ALLOCATION_ROLE']
marathon_enforce_group_role=os.environ['MARATHON_APP_ENFORCE_GROUP_ROLE']
if _str2bool(marathon_enforce_group_role):
if mesos_allocation_role != jenkins_agent_role:
print("WARN: JENKINS_AGENT_ROLE:'{}' not the same as MESOS_ALLOCATION_ROLE:'{}'. "
"enforceRole detected on top-level group, using '{}' as agent-role.".format(
jenkins_agent_role, mesos_allocation_role, mesos_allocation_role))
jenkins_agent_role = mesos_allocation_role
print("INFO: using enforced group role '{}' for agents.".format(jenkins_agent_role))
else:
print("INFO: using non-enforced group role '{}' for agents".format(jenkins_agent_role))
except KeyError as e:
print("INFO: This cluster does not have {} env-var defined. Using legacy non-quota enforcement aware semantics".format(e.args[0]))

# optional environment variables
jenkins_root_url = os.getenv(
'JENKINS_ROOT_URL',
Expand Down
2 changes: 1 addition & 1 deletion universe/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
"packagingVersion": "3.0",
"name": "jenkins",
"version": "{{package-version}}",
"minDcosReleaseVersion": "1.14",
"minDcosReleaseVersion": "1.10",
"scm": "https://github.com/mesosphere/dcos-jenkins-service.git",
"maintainer": "[email protected]",
"website": "https://jenkins.io",
Expand Down

0 comments on commit 722dbc2

Please sign in to comment.