diff options
author | Clark Boylan <clark.boylan@gmail.com> | 2023-02-07 16:09:08 -0800 |
---|---|---|
committer | Clark Boylan <clark.boylan@gmail.com> | 2023-02-07 16:17:14 -0800 |
commit | 045bb270c0ab3e39eaab6462d77f6e9494a8fe3d (patch) | |
tree | 0508e8dcdd9dda1add36c6349e77b5f7df51f508 | |
parent | 26523d8e5673a624c1ba5ae8bff2db96431d4b5a (diff) | |
download | zuul-045bb270c0ab3e39eaab6462d77f6e9494a8fe3d.tar.gz |
Fix ResourceWarnings in the executor server
We have two open() calls in the executor server without matching
close() calls. Fix this by wrapping both in a with context manager.
Change-Id: I0e51c2b22ea1540484851f98749e648728b26406
-rw-r--r-- | zuul/executor/server.py | 6 |
1 files changed, 4 insertions, 2 deletions
diff --git a/zuul/executor/server.py b/zuul/executor/server.py index 82df57b77..72e5cf779 100644 --- a/zuul/executor/server.py +++ b/zuul/executor/server.py @@ -1888,7 +1888,8 @@ class AnsibleJob(object): logfile=json_output)) return try: - output = json.load(open(json_output, 'r')) + with open(json_output, 'r') as f: + output = json.load(f) last_playbook = output[-1] # Transform json to yaml - because it's easier to read and given # the size of the data it'll be extra-hard to read this as an @@ -2332,7 +2333,8 @@ class AnsibleJob(object): def prepareKubeConfig(self, jobdir, data): kube_cfg_path = jobdir.kubeconfig if os.path.exists(kube_cfg_path): - kube_cfg = yaml.safe_load(open(kube_cfg_path)) + with open(kube_cfg_path) as f: + kube_cfg = yaml.safe_load(f) else: kube_cfg = { 'apiVersion': 'v1', |