This profile will then be written to ``/etc/sysctl.d/`` on each host matching the
given placement and `sysctl --system` will be run on the host.
-.. note::
+.. note::
The exact filename the profile will be written to is within ``/etc/sysctl.d/`` is
``<profile-name>-cephadm-tuned-profile.conf`` where <profile-name>
These settings are applied only at the host level, and are not specific
to any certain daemon or container
+.. note::
+
+ Applying tuned profiles is idempotent when the ``--no-overwrite`` option is passed.
+ In this case existing profiles with the same name are not overwritten.
+
Viewing Profiles
----------------
self.profiles[k] = TunedProfileSpec.from_json(v)
self.profiles[k]._last_updated = datetime_to_str(datetime_now())
+ def exists(self, profile_name: str) -> bool:
+ return profile_name in self.profiles
+
def save(self) -> None:
profiles_json = {k: v.to_json() for k, v in self.profiles.items()}
self.mgr.set_store('tuned_profiles', json.dumps(profiles_json))
return self._apply_service_spec(cast(ServiceSpec, spec))
@handle_orch_error
- def apply_tuned_profiles(self, specs: List[TunedProfileSpec]) -> str:
+ def apply_tuned_profiles(self, specs: List[TunedProfileSpec], no_overwrite: bool = False) -> str:
outs = []
for spec in specs:
- self.tuned_profiles.add_profile(spec)
- outs.append(f'Saved tuned profile {spec.profile_name}')
+ if no_overwrite and self.tuned_profiles.exists(spec.profile_name):
+ outs.append(f"Tuned profile '{spec.profile_name}' already exists (--no-overwrite was passed)")
+ else:
+ self.tuned_profiles.add_profile(spec)
+ outs.append(f'Saved tuned profile {spec.profile_name}')
self._kick_serve_loop()
return '\n'.join(outs)
"""Update an existing snmp gateway service"""
raise NotImplementedError()
- def apply_tuned_profiles(self, specs: List[TunedProfileSpec]) -> OrchResult[str]:
+ def apply_tuned_profiles(self, specs: List[TunedProfileSpec], no_overwrite: bool) -> OrchResult[str]:
"""Add or update an existing tuned profile"""
raise NotImplementedError()
tuned_profile_spec = TunedProfileSpec(
profile_name=profile_name, placement=placement_spec, settings=settings_dict)
specs = [tuned_profile_spec]
- completion = self.apply_tuned_profiles(specs)
+ completion = self.apply_tuned_profiles(specs, no_overwrite)
res = raise_if_exception(completion)
return HandleCommandResult(stdout=res)