aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--man/en/sos-collect.116
-rw-r--r--sos/collector/__init__.py9
-rw-r--r--sos/collector/transports/oc.py2
-rw-r--r--sos/options.py20
4 files changed, 32 insertions, 15 deletions
diff --git a/man/en/sos-collect.1 b/man/en/sos-collect.1
index 9b0a5d7b..2f60332b 100644
--- a/man/en/sos-collect.1
+++ b/man/en/sos-collect.1
@@ -28,7 +28,7 @@ sos collect \- Collect sosreports from multiple (cluster) nodes
[\-\-no\-local]
[\-\-primary PRIMARY]
[\-\-image IMAGE]
- [\-\-force-pull-image]
+ [\-\-force-pull-image TOGGLE, --pull TOGGLE]
[\-\-registry-user USER]
[\-\-registry-password PASSWORD]
[\-\-registry-authfile FILE]
@@ -262,10 +262,16 @@ Specify an image to use for the temporary container created for collections on
containerized host, if you do not want to use the default image specifed by the
host's policy. Note that this should include the registry.
.TP
-\fB\-\-force-pull-image\fR
-Use this option to force the container runtime to pull the specified image (even
-if it is the policy default image) even if the image already exists on the host.
-This may be useful to update an older container image on containerized hosts.
+\fB\-\-force-pull-image TOGGLE, \-\-pull TOGGLE\fR
+When collecting an sos report from a containerized host, force the host to always
+pull the specified image, even if that image already exists on the host.
+This is useful to ensure that the latest version of that image is always in use.
+Disabling this option will use whatever version of the image is present on the node,
+and only attempt a pull if there is no copy of the image present at all.
+
+Enable with true/on/yes or disable with false/off/no
+
+Default: true
.TP
\fB\-\-registry-user USER\fR
Specify the username to authenticate to the registry with in order to pull the container
diff --git a/sos/collector/__init__.py b/sos/collector/__init__.py
index d898ca34..66c3d932 100644
--- a/sos/collector/__init__.py
+++ b/sos/collector/__init__.py
@@ -27,7 +27,7 @@ from pipes import quote
from textwrap import fill
from sos.cleaner import SoSCleaner
from sos.collector.sosnode import SosNode
-from sos.options import ClusterOption
+from sos.options import ClusterOption, str_to_bool
from sos.component import SoSComponent
from sos.utilities import bold
from sos import __version__
@@ -85,7 +85,7 @@ class SoSCollector(SoSComponent):
'encrypt_pass': '',
'group': None,
'image': '',
- 'force_pull_image': False,
+ 'force_pull_image': True,
'jobs': 4,
'keywords': [],
'keyword_file': None,
@@ -357,8 +357,9 @@ class SoSCollector(SoSComponent):
collect_grp.add_argument('--image',
help=('Specify the container image to use for'
' containerized hosts.'))
- collect_grp.add_argument('--force-pull-image', '--pull', default=False,
- action='store_true',
+ collect_grp.add_argument('--force-pull-image', '--pull',
+ default=True, choices=(True, False),
+ type=str_to_bool,
help='Force pull the container image even if '
'it already exists on the host')
collect_grp.add_argument('--registry-user', default=None,
diff --git a/sos/collector/transports/oc.py b/sos/collector/transports/oc.py
index 90a802b2..8f6aa9b4 100644
--- a/sos/collector/transports/oc.py
+++ b/sos/collector/transports/oc.py
@@ -147,6 +147,8 @@ class OCTransport(RemoteTransport):
"tty": True
}
],
+ "imagePullPolicy":
+ "Always" if self.opts.force_pull_image else "IfNotPresent",
"restartPolicy": "Never",
"nodeName": self.address,
"hostNetwork": True,
diff --git a/sos/options.py b/sos/options.py
index 4846a509..2d5a5135 100644
--- a/sos/options.py
+++ b/sos/options.py
@@ -18,6 +18,16 @@ def _is_seq(val):
return val_type is list or val_type is tuple
+def str_to_bool(val):
+ _val = val.lower()
+ if _val in ['true', 'on', 'yes']:
+ return True
+ elif _val in ['false', 'off', 'no']:
+ return False
+ else:
+ return None
+
+
class SoSOptions():
def _merge_opt(self, opt, src, is_default):
@@ -153,15 +163,13 @@ class SoSOptions():
if isinstance(self.arg_defaults[key], list):
return [v for v in val.split(',')]
if isinstance(self.arg_defaults[key], bool):
- _val = val.lower()
- if _val in ['true', 'on', 'yes']:
- return True
- elif _val in ['false', 'off', 'no']:
- return False
- else:
+ val = str_to_bool(val)
+ if val is None:
raise Exception(
"Value of '%s' in %s must be True or False or analagous"
% (key, conf))
+ else:
+ return val
if isinstance(self.arg_defaults[key], int):
try:
return int(val)