Exemple #1
0
 def _get_cpu_info() -> CPUInfo:
     cpu_info = get_cpu_info()
     if cpu_info.error is not None:
         logging.error('Failed to get cpu info: %s', cpu_info.error)
     return CPUInfo(
         core_count=cpu_info.core_count,
         threads_per_core=cpu_info.threads_per_core,
         architecture=cpu_info.architecture,
         model_name=cpu_info.model_name,
     )
Exemple #2
0
    def __init__(self, service, service_poller):
        super().__init__(max(5, service.mconfig.checkin_interval),
                         service.loop)

        self._service = service
        self._service_poller = service_poller

        # Number of consecutive failed checkins before we check for an outdated
        # cert
        self.CHECKIN_FAIL_THRESHOLD = 10
        # Current number of consecutive failed checkins
        self.num_failed_checkins = 0
        self._checkin_failure_cb = None

        # cloud controller's client stub
        self._checkin_client = None
        self.MAX_CLIENT_REUSE = 60

        # skip checkin based on missing status meta
        self.num_skipped_checkins = 0

        # Initially set status to 1, otherwise on first checkin we report
        # a failure. This is particularly an issue if magmad restarts frequenty.
        CHECKIN_STATUS.set(1)

        # One time status info
        self._boot_time = psutil.boot_time()
        self._kernel_version = platform.uname().release
        cpu_info = get_cpu_info()
        if cpu_info.error is not None:
            logging.error('Failed to get cpu info: %s', cpu_info.error)
        self._cpu_info = CPUInfo(
            core_count=cpu_info.core_count,
            threads_per_core=cpu_info.threads_per_core,
            architecture=cpu_info.architecture,
            model_name=cpu_info.model_name,
        )
        self.native_gw_status_generator = GatewayStatusNative(service)

        self._kernel_versions_installed = []
        self._periodically_check_kernel_versions = \
            service.config.get('enable_kernel_version_checking', False)
        # Save for the state manager to also send to the state service
        self.gw_status_json = None
        # set initial checkin timeout to "large" since no checkins occur until
        #   bootstrap succeeds.
        self.set_timeout(60 * 60 * 2)
        # initially set task as alive to wait for bootstrap, where try_checkin()
        #   will recheck alive status
        self.heartbeat()

        # Start try_checkin loop
        self.start()
Exemple #3
0
 def __init__(self, service: MagmaService):
     self._service = service
     self._kernel_version = platform.uname().release
     self._boot_time = psutil.boot_time()
     cpu_info = get_cpu_info()
     if cpu_info.error is not None:
         logging.error('Failed to get cpu info: %s', cpu_info.error)
     self._cpu_info = CPUInfo(
         core_count=cpu_info.core_count,
         threads_per_core=cpu_info.threads_per_core,
         architecture=cpu_info.architecture,
         model_name=cpu_info.model_name,
     )