Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[policies] add Container-Optimized OS support #1419

Closed
wants to merge 2 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
36 changes: 36 additions & 0 deletions sos/policies/cos.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
# Copyright (C) Red Hat, Inc. 2020

# This file is part of the sos project: https://github.com/sosreport/sos
#
# This copyrighted material is made available to anyone wishing to use,
# modify, copy, or redistribute it subject to the terms and conditions of
# version 2 of the GNU General Public License.
#
# See the LICENSE file in the source distribution for further information.

from sos.report.plugins import CosPlugin
from sos.policies import LinuxPolicy


class CosPolicy(LinuxPolicy):
distro = "Container-Optimized OS"
vendor = "Google Cloud Platform"
vendor_url = "https://cloud.google.com/container-optimized-os/"
valid_subclasses = [CosPlugin]
PATH = "/usr/local/bin:/usr/local/sbin:/usr/bin:/usr/sbin:/bin:/sbin"

@classmethod
def check(cls, remote=''):

if remote:
return cls.distro in remote

try:
with open('/etc/os-release', 'r') as fp:
os_release = dict(line.strip().split('=') for line in fp)
id = os_release.get('ID')
return id == 'cos'
except IOError:
return False

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You seem to have some missing bits here: you're importing PackageManager, but then not using it anywhere. This means that package name triggers and package verification for plugins won't work with this policy. Normally this is initialised inside the policy __init__() method so that policy -> package manager callbacks from plugin code work correctly.

Setting a name_pattern will also allow you to control default report naming templates.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Good catch. Yeah I should not import PackageManager, because COS actually do not have a package manager, similar to what CoreOS does.

# vim: set et ts=4 sw=4 :
5 changes: 5 additions & 0 deletions sos/report/plugins/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -1995,6 +1995,11 @@ class SuSEPlugin(object):
pass


class CosPlugin(object):
"""Tagging class for Container-Optimized OS"""
pass


class IndependentPlugin(object):
"""Tagging class for plugins that can run on any platform"""
pass
Expand Down
5 changes: 3 additions & 2 deletions sos/report/plugins/cgroups.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,10 +6,11 @@
#
# See the LICENSE file in the source distribution for further information.

from sos.report.plugins import Plugin, RedHatPlugin, DebianPlugin, UbuntuPlugin
from sos.report.plugins import (Plugin, RedHatPlugin, DebianPlugin,
UbuntuPlugin, CosPlugin)


class Cgroups(Plugin, DebianPlugin, UbuntuPlugin):
class Cgroups(Plugin, DebianPlugin, UbuntuPlugin, CosPlugin):

short_desc = 'Control groups subsystem'

Expand Down
5 changes: 3 additions & 2 deletions sos/report/plugins/devices.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,10 +6,11 @@
#
# See the LICENSE file in the source distribution for further information.

from sos.report.plugins import Plugin, RedHatPlugin, DebianPlugin, UbuntuPlugin
from sos.report.plugins import (Plugin, RedHatPlugin, DebianPlugin,
UbuntuPlugin, CosPlugin)


class Devices(Plugin, RedHatPlugin, DebianPlugin, UbuntuPlugin):
class Devices(Plugin, RedHatPlugin, DebianPlugin, UbuntuPlugin, CosPlugin):

short_desc = 'devices specific commands'

Expand Down
5 changes: 3 additions & 2 deletions sos/report/plugins/docker.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,10 +8,11 @@
#
# See the LICENSE file in the source distribution for further information.

from sos.report.plugins import Plugin, RedHatPlugin, UbuntuPlugin, SoSPredicate
from sos.report.plugins import (Plugin, RedHatPlugin, UbuntuPlugin,
SoSPredicate, CosPlugin)


class Docker(Plugin):
class Docker(Plugin, CosPlugin):

short_desc = 'Docker containers'
plugin_name = 'docker'
Expand Down
5 changes: 3 additions & 2 deletions sos/report/plugins/filesys.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,10 +6,11 @@
#
# See the LICENSE file in the source distribution for further information.

from sos.report.plugins import Plugin, RedHatPlugin, DebianPlugin, UbuntuPlugin
from sos.report.plugins import (Plugin, RedHatPlugin, DebianPlugin,
UbuntuPlugin, CosPlugin)


class Filesys(Plugin, DebianPlugin, UbuntuPlugin):
class Filesys(Plugin, DebianPlugin, UbuntuPlugin, CosPlugin):

short_desc = 'Local file systems'

Expand Down
5 changes: 3 additions & 2 deletions sos/report/plugins/kernel.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,12 +6,13 @@
#
# See the LICENSE file in the source distribution for further information.

from sos.report.plugins import Plugin, RedHatPlugin, DebianPlugin, UbuntuPlugin
from sos.report.plugins import (Plugin, RedHatPlugin, DebianPlugin,
UbuntuPlugin, CosPlugin)
import os
import glob


class Kernel(Plugin, RedHatPlugin, DebianPlugin, UbuntuPlugin):
class Kernel(Plugin, RedHatPlugin, DebianPlugin, UbuntuPlugin, CosPlugin):

short_desc = 'Linux kernel'

Expand Down
5 changes: 3 additions & 2 deletions sos/report/plugins/logs.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,10 +8,11 @@

import os
import glob
from sos.report.plugins import Plugin, RedHatPlugin, DebianPlugin, UbuntuPlugin
from sos.report.plugins import (Plugin, RedHatPlugin, DebianPlugin,
UbuntuPlugin, CosPlugin)


class Logs(Plugin, RedHatPlugin, DebianPlugin, UbuntuPlugin):
class Logs(Plugin, RedHatPlugin, DebianPlugin, UbuntuPlugin, CosPlugin):

short_desc = 'System logs'

Expand Down
5 changes: 3 additions & 2 deletions sos/report/plugins/memory.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,10 +6,11 @@
#
# See the LICENSE file in the source distribution for further information.

from sos.report.plugins import Plugin, RedHatPlugin, DebianPlugin, UbuntuPlugin
from sos.report.plugins import (Plugin, RedHatPlugin, DebianPlugin,
UbuntuPlugin, CosPlugin)


class Memory(Plugin, RedHatPlugin, DebianPlugin, UbuntuPlugin):
class Memory(Plugin, RedHatPlugin, DebianPlugin, UbuntuPlugin, CosPlugin):

short_desc = 'Memory configuration and use'

Expand Down
5 changes: 3 additions & 2 deletions sos/report/plugins/process.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,10 +6,11 @@
#
# See the LICENSE file in the source distribution for further information.

from sos.report.plugins import Plugin, RedHatPlugin, DebianPlugin, UbuntuPlugin
from sos.report.plugins import (Plugin, RedHatPlugin, DebianPlugin,
UbuntuPlugin, CosPlugin)


class Process(Plugin, RedHatPlugin, DebianPlugin, UbuntuPlugin):
class Process(Plugin, RedHatPlugin, DebianPlugin, UbuntuPlugin, CosPlugin):

short_desc = 'process information'

Expand Down
5 changes: 3 additions & 2 deletions sos/report/plugins/systemd.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,10 +8,11 @@
#
# See the LICENSE file in the source distribution for further information.

from sos.report.plugins import Plugin, RedHatPlugin, DebianPlugin, UbuntuPlugin
from sos.report.plugins import (Plugin, RedHatPlugin, DebianPlugin,
UbuntuPlugin, CosPlugin)


class Systemd(Plugin, RedHatPlugin, DebianPlugin, UbuntuPlugin):
class Systemd(Plugin, RedHatPlugin, DebianPlugin, UbuntuPlugin, CosPlugin):

short_desc = 'System management daemon'

Expand Down