BlueKing Standard Operations (SOPS)

repository·release_humming_bird·Indexed 23 days ago

https://github.com/tencentblueking/bk-sops

A lightweight SaaS product for task workflow orchestration and execution via a visual interface. It features a Workflow Orchestration Service for automated scheduling and a Self-Service Service for delegating routine tasks. The system includes a BlueKing Standard Plugin Service integration SDK for Django-based projects, supporting visual workflow composition, parameter engines, and interactive task execution using the bamboo-engine SDK.

Tokens
210.4K
Snippets
411
Records
911
Agent score
79%

What's inside bk-sops

  1. Overview of BlueKing Standard Operations (SOPS)

    release_humming_bird

    BlueKing Standard Operations (SOPS) is a lightweight SaaS product within the Tencent BlueKing ecosystem designed for task workflow orchestration and execution via a visual graphical interface.

    It consists of two core services:

    1. Workflow Orchestration Service: An API gateway service based on the BlueKing PaaS platform that integrates capabilities from various internal enterprise systems, allowing for automated scheduling across multiple systems.
    2. Self-Service Service: Abstracts the differences between underlying systems, enabling operations personnel to delegate routine tasks (like business releases or changes) to product, development, or testing teams. It integrates deeply with the BlueKing PaaS platform to provide 'light applications' and 'functionalization' to increase self-service rates.

    Technical Stack:

    • Backend: Python with the Django framework.
    • Frontend: Vue.js for pages and jQuery for standard plugin development (using a configuration-based pattern to simplify form development).
    • Engine: Uses the bamboo-engine SDK for underlying workflow processing.
  2. Overview of SOPS Flow Schedule Engine

    release_humming_bird

    SOPS is a SaaS product within the Tencent Blueking system designed for cross-system automated scheduling of operation and maintenance (O&M) demands. It uses a flow scheduling engine and the Blueking PaaS API Gateway to connect various enterprise system APIs into unified task flows.

    Key capabilities include:

    • Integration: Connects Blueking services (CMDB, JOB, Notification Service, etc.) and supports custom plugins.
    • Cross-system Automation: Orchestrates complex scenarios (like version releases) that require tasks to be performed in a specific order across multiple different systems.
    • Standardization: Allows users to create reusable flow templates to standardize business processes and enable self-service operations for developers and testers.
  3. Overview of the Plugin Gateway Subsystem

    release_humming_bird
    The gcloud.plugin_gateway subsystem provides a unified plugin consumption protocol for external platforms. It allows external systems to discover plugin categories, fetch plugin details using uniform_api v4.0.0 metadata, register plugin executions, query run status/details, and receive execution results via callbacks. All external interfaces are converged under the /apigw/plugin-gateway/ prefix.
  4. Overview of Standard Operations (bk-sops)

    release_humming_bird

    Standard Operations (bk-sops) is a workflow orchestration and scheduling engine within the Tencent BlueKing ecosystem. It enables cross-system automation by integrating various APIs into unified, automated workflows.

    Key Capabilities:

    • Workflow Orchestration: Uses a mature engine to sequence complex operations across multiple systems.
    • System Integration: Connects BlueKing PaaS services (such as Configuration Platform, Job Platform, and Notification Service) with your enterprise's internal proprietary systems.
    • Custom Plugin Development: Provides the ability to develop custom plugins to bridge unique internal systems into the automated orchestration flow.
    • Self-Service Operations: By abstracting underlying system differences, it allows non-operations personnel (Product, Dev, QA) to execute standardized business releases and changes via automated templates.
  5. Overview of Standard Plugin Development

    release_humming_bird
    Standard plugins are a core component of the BlueKing Standard Plugin Service (bk-plugin-service). This guide outlines the development lifecycle for creating and integrating these plugins. For a high-level understanding of what standard plugins are and how they are used within the ecosystem, refer to the About standard plugins documentation.
  6. Implementation Plan for Plugin Gateway Full Capability

    release_humming_bird

    The goal of this plan is to expose both built-in and third-party plugins to BKFlow via the uniform_api v4.0.0. This is achieved using a 'Component Execution Shell (Scheme B)' that allows real operators and business contexts to execute tasks via synchronous, polling, or callback mechanisms.

    Architecture Overview

    • Directory Layer: Unifies built-in plugins (traversed via ComponentLibrary) and third-party plugins (PluginServiceApiClient) into a single v4 directory.
    • Execution Layer: Located in gcloud/plugin_gateway/services/runner.py. It instantiates the component bound_service and drives execute/schedule directly without creating a PipelineModel engine instance.
    • Context Parsing: Parses sops Project and writes operator information into parent_data.
    • State Machine: Follows the lifecycle CREATED → RUNNING → (WAITING_CALLBACK) → SUCCEEDED/FAILED/CANCELLED.
    • Infrastructure: Utilizes 3 independent Celery queues and existing callback bridges.

    Tech Stack

    • Django, DRF, Celery
    • bamboo-pipeline (ComponentLibrary, Service, DataObject, FancyDict)
    • API Gateway
    • pytest / Django TestCase
  7. Implementation Plan for Stuck Process Governance Console

    release_humming_bird

    The 'Stuck Process Governance Console' is a new administrative feature for bk-sops located under /admin/. It allows super-administrators to associate DiagnosticCase objects (from bamboo-engine) back to specific tasks, templates, businesses, and nodes, providing status management and the ability to run diagnostic or recovery actions.

    Architecture Overview

    • Scope: Pure bk-sops side changes; no modifications to bamboo-engine.
    • Backend: Adds a reverse mapping layer, a status writing layer, and three new views in gcloud/contrib/admin. Existing list/detail views are enhanced.
    • Frontend: Uses an independent Django template with native JavaScript (fetching JSON endpoints) rather than integrating into the main Vue SPA.
    • Resilience: All references to pipeline.contrib.diagnostics must be wrapped in try/except ImportError to ensure the system degrades gracefully with readable errors if the engine package is missing.

    Key Constraints

    • Access Control: Restricted to platform super-administrators via @check_is_superuser() and @iam_intercept() (using AdminViewViewInterceptor for reads and AdminEditViewInterceptor for writes).
    • Status Management: DiagnosticCase statuses are limited to three states: open (STATUS_OPEN), resolved (STATUS_RESOLVED), and ignored (STATUS_IGNORED).
    • Data Integrity: Due to a unique_together constraint on (root_pipeline_id, node_id, stuck_type, status), status updates must follow a "merge + delete duplicates" pattern rather than a direct update(status=...) call.
    • Data Mapping: Reverse mapping uses TaskFlowInstance.objects.filter(pipeline_instance__instance_id__in=ids) where pipeline_instance.instance_id == root_pipeline_id.
  8. Find Blueking Open Source Projects

    release_humming_bird

    The following are key Blueking open-source projects:

  9. Plugin Gateway current capabilities and limitations

    release_humming_bird

    The current implementation of the Plugin Gateway has specific functional boundaries. Use this to determine if the gateway meets your current requirements.

    Supported Features

    • Third-party Plugin Discovery: Discovery is currently limited to third-party plugins only.
    • Synchronous Scheduling: Supports synchronous scheduling for third-party plugins.
    • Execution Management: Includes execution registration, idempotency, source governance, status/detail retrieval, cancellation, and callback bridging.

    Unsupported/Planned Features

    • Built-in Plugins: Directory exposure and execution scheduling for built-in plugins are not yet implemented.
    • Asynchronous Modes: Asynchronous execution modes (such as polling or callback-based recovery for RUNNING states) are not yet implemented.
    • Consistency: Consistency between categories and plugins lists regarding builtin status is pending.
  10. Identify use cases for BlueKing Standard Plugin Service

    release_humming_bird

    The BlueKing Standard Plugin Service (bk-plugin-service) is designed for operational execution and system integration.

    Primary Operational Use Cases:

    • Business releases (业务发布)
    • Configuration changes (变更)
    • New zone/region creation (开区)
    • Scaling (扩缩容)
    • Fault handling (故障处理)

    Integration Use Cases: By implementing custom plugins, you can connect the service to other enterprise systems to extend its capabilities into:

    • Monitoring and alerting (监控告警)
    • Configuration management (配置管理)
    • Development tools (开发工具)
    • Enterprise IT and office applications (企业IT、办公应用)
    • Document/Ticket systems (单据系统)
    • Version control systems (版本管理系统)
  11. New features in V3.28.0

    release_humming_bird

    The following features were introduced in version 3.28.0:

    • Automatic Task Pausing: The system automatically pauses a task when task parameters are modified to ensure changes only apply to nodes that are not currently running.
    • Historical Time-Cost Visibility: You can now view the historical time-cost of a node during task execution.
    • Plugin Categorization: Third-party plug-ins can now be searched by category.
    • Parameter Change Tracking: Changes made to parameters are now recorded in the task operation record.
  12. Understand the bk-sops code structure

    release_humming_bird

    The bk-sops codebase is organized into four primary architectural layers: the development framework, the pipeline engine, the business logic layer, and the frontend presentation layer.

    1. Framework Layer (framework)

    Built as a secondary encapsulation of the Django framework, this layer provides foundational SaaS operations and PaaS configurations.

    • config: Environment-specific configurations (local, test, production) and routing.
    • blueapps: Core modules for the new development framework, including unified login, authentication, middleware, and common functions.
    • packages: The BlueKing API Gateway SDK, providing access to APIs from the Configuration Platform, Job Platform, etc.

    2. Pipeline Engine Layer (pipeline, pipeline_web, pipeline_plugins)

    A self-developed workflow engine framework responsible for task orchestration and execution.

    • pipeline: Contains the core engine logic. Key sub-directories include:
      • core: Core elements defined following BPMN 2.0 specifications (e.g., Activity, gateways, events, Data objects).
      • engine: Runtime execution logic and task state management.
      • component_framework: The plugin framework and plugin definitions.
      • validators: Data validation (e.g., circular structure detection).
    • pipeline_web: The frontend data adaptation layer that supports workflow data generated by the frontend canvas.
    • pipeline_plugins: The official standard operations plugin library and global custom variables.

    3. Business Logic Layer (gcloud)

    A business adaptation layer built on top of the pipeline engine. It handles business permissions, template management, and task management.

    • core: Core business logic, permission control, and business homepages.
    • tasktmpl3: Workflow template management.
    • taskflow3: Task management.
    • webservice3: Data resource API management.
    • apigw: External-facing API modules.

    4. Frontend Layer (web)

    Contains frontend resources and static assets.

    • frontend: Includes the workflow orchestration desktop module, implemented using Vue.
    • static: Contains frontend definitions for plugin components and variables. These are located within their respective module directories.
    • templates: Pages required for the homepage and Django admin.