Skip to content

feat: support to deploy oblogservice and oceanbase.ai#933

Open
Junkrat77 wants to merge 34 commits into
oceanbase:masterfrom
Junkrat77:feature/shared-storage-support
Open

feat: support to deploy oblogservice and oceanbase.ai#933
Junkrat77 wants to merge 34 commits into
oceanbase:masterfrom
Junkrat77:feature/shared-storage-support

Conversation

@Junkrat77

Copy link
Copy Markdown
Collaborator

Summary

Solution Description

Junkrat77 added 30 commits June 11, 2026 11:43
This commit adds complete support for OceanBase shared-storage deployment
mode and LogService cluster management via a three-layer CRD architecture.

LogService (new):
- Three-layer CRD: OBLogServiceCluster → OBLogServiceZone → OBLogServiceNode
- Declarative topology with automatic cascade create/delete
- Auto bootstrap via ls_ctrl after all nodes ready
- Node failure recovery (Pod lost/failed → auto rebuild)
- Configurable resource requests, affinity, tolerations per zone
- Deletion protection via ignore-deletion annotation
- Immutability checks for objectStoreUrl and storage in ValidateUpdate

Shared Storage OBCluster (extended):
- New spec fields: deploymentMode, sharedStorageInfo, logServiceRef
- Bootstrap with LOGSERVICE_ACCESS_POINT + SHARED_STORAGE_INFO
- Observer starts with -m shared_storage, enable_logservice=True
- No redoLog PVC in shared storage mode
- Webhook validates SS-specific required fields and immutability

Security & robustness:
- Shell injection fix: user-supplied BucketURL/Region/Zone passed via env vars
- RBAC markers for Zone/Node CRDs
- DeepCopy pointer aliasing fix
- Nil pointer guards in UpdateStatus and CreatePod
- Finalizer safety: transition to Deleting instead of skipping cleanup
- AlreadyExists handling for idempotent zone/node creation
- Deterministic node deletion ordering (newest first)

Build & deployment:
- SS image build scripts (oblogservice + observer-ss Dockerfiles)
- Non-root USER in Dockerfile.oblogservice
- Pinned base image for observer-ss
- Example manifests with placeholder credentials and endpoints
Remove access_id/access_key from operator logs by:
- Not logging the full bootstrap SQL in BootstrapSharedStorage
- Not including ls_ctrl Job output in error messages or success logs
Rename image, namespace, and resource names from ss to ai across
build scripts and example manifests.
…en formatting.

Remove local-only RPM image build helpers from version control and revert
accidental column-alignment churn in unrelated resource manager task name files.
- Merge LogService DeepCopy methods into api/types/deepcopy.go with proper
  handling of Resource, Affinity, Tolerations, and StorageSpec fields
- Delete redundant api/types/zz_generated_deepcopy.go
- Add Affinity/Tolerations fields to OBLogServiceNodeSpec and propagate
  from Zone topology through to Pod spec
- Set container resource Limits equal to Requests (Guaranteed QoS)
- Regenerate CRD manifests via controller-gen
- Fix obcluster_webhook RedoLogStorage indent and obcluster_test pointer type
- Fix observer_task.go switch-case indentation (gofmt)
Propagate user-defined parameters through the Cluster→Zone→Node
hierarchy and inject them into the oblogservice startup command
via the -g flag.
…OBCluster

- Add required resource field (cpu/memory) to OBLogServiceCluster and
  OBLogServiceZone specs with webhook validation and propagation
- Remove hardcoded resource defaults in Pod creation, use spec values
- Auto-calculate log_disk_size from storeStorage PVC size (95%)
- Auto-calculate memory_limit from resource.memory (90%) via webhook
  Defaulter, matching OBCluster's Default() pattern
- Add mutating webhook for OBLogServiceCluster to fill memory_limit
- Add LogServiceReservedParameters to filter log_disk_size/percentage
- Extract LogService mount paths and volume names to constants
- Validate memory_limit does not exceed resource.memory in webhook
Single-quote user-supplied parameter values in the oblogservice -g flag,
aligned with OBCluster's observer startup pattern. Restructure command
construction to use a parameter slice joined by commas for clarity.
Add CNI detection and static IP support for LogService nodes. Nodes on
Calico/KubeOvn recover in-place with pinned IP; others are marked
unrecoverable and replaced by the zone manager.
Cluster Controller now detects replica changes in spec topology and
propagates them to child Zone specs, matching the OBCluster pattern.
Zone now registers new nodes via ls_ctrl add ln after pod is running,
and unregisters nodes via ls_ctrl delete ln before deletion. This makes
LogService replica scaling actually effective at the cluster level.
…n tracking

Use annotation oceanbase.oceanbase.com/logservice-node-registered to track
which nodes have been registered via ls_ctrl add ln. Skip already-registered
nodes to avoid non-idempotent add ln failures. Use client.Patch (MergeFrom)
for annotation updates to avoid resourceVersion conflicts. Mark bootstrap
nodes as registered after successful cluster bootstrap.
LogService does not support dynamic zone topology changes. Add webhook
ValidateUpdate check to reject zone additions and removals, and remove
the now-unreachable AddZone/DeleteZone reconciliation code paths.
Fix revive and staticcheck findings reported by CI on new code:
- remove redundant v1alpha1 import aliases
- flatten promoted embedded field selectors (ObjectMeta, VolumeSource, OBClusterExtra)
- add package doc comments for new packages
- add default cases to switches, folding empty Pause branch into default
- merge identical CNI switch branches
- lowercase error string per ST1005
Region has no practical meaning for LogService at this stage. Remove the
region field from LogServiceZoneTopology and OBLogServiceNodeSpec so
users no longer need to fill it in. Bootstrap now uses a hardcoded
default "region1" via the LogServiceDefaultRegion constant.
Move oceanbase-ai wallet setup into oceanbase-helper so observer images no longer need a prestart wrapper script.
Regenerate deploy/operator.yaml so OBLogServiceCluster, Zone and Node CRDs include resource and parameters fields required by shared storage deployments.
…erviceCluster

Group node-level config (image/resource/storage) into a new
LogServiceTemplate under spec.logService, mirroring OBCluster's
spec.observer pattern. Parameters stay at spec top level (matching
OBCluster). Zone/Node internal CRDs keep their flat structure.

The whole logService template is immutable after creation; only
topology[].replica is mutable (via ModifyZoneReplica). There is no
resource-reconcile flow, so the previous permissiveness on Resource
was a silent no-op.
… advertise

oblogservice 1.3.0 changed its config schema and network behavior:
- config keys renamed: port -> rpc_port, http_ip_addr=<ip>:<port> ->
  http_port=<port> (old keys are now ignored as 'unknown global config')
- default ports changed: rpc 50031 -> 50051, http mgmt 50051 -> 50052
- net_frame (rpc_port) and HTTP mgmt server (http_port) now bind 0.0.0.0,
  so local_ip becomes advertise/identity only (no longer a bind address)

This makes ServiceIP viable as the advertised address, aligning
LogService with OBCluster's service mode: node identity is now the
stable per-pod ServiceIP instead of PodIP, surviving pod restarts
without depending on static-IP CNI.

Changes:
- Update LogServiceRpcPort/LogServiceHttpPort constants to 50051/50052.
- Start command uses rpc_port/http_port keys; local_ip = GetConnectAddr()
  (ServiceIP), aligned with how OBCluster uses GetConnectAddr for the
  observer advertise address; error out if no address is available yet.
- Robust ServiceIP retrieval via the Create response with a Get fallback.
- bootstrap/add-ln/delete-ln use GetConnectAddr() (ServiceIP) for the
  SERVER addr and ls_ctrl --host; guard against empty addresses.
- Example image bumped to oblogservice:1.3.0.

Verified end-to-end: cluster reaches running; ls_ctrl show ln shows 3
Active nodes registered at ServiceIP:50051.
The LogService bootstrap job (ls_ctrl, one-shot with BackoffLimit=0)
intermittently failed with 'Connection refused': it connects to the
peers' ServiceIP:50051 right after the per-node Services are created,
before kube-proxy has installed the DNAT rules.

OBCluster's Bootstrap already handles this by retrying its connection
up to GetConnectionMaxRetries x CheckConnectionInterval before
bootstrapping. Align LogService by wrapping the ls_ctrl bootstrap
command in a bash retry loop reusing the same config keys (floors of
6 / 5s). The transient failure occurs at prepare_bootstrap before any
state change, so retrying ls_ctrl is safe.

Verified end-to-end: attempt 1 hit Connection refused, attempt 2
succeeded; cluster running with 3 Active nodes at ServiceIP:50051.
…ervice start

Refactor OBLogServiceNode to mirror OBServer's bootstrap pattern:
- Add BootstrapReady intermediate status for two-phase cluster bootstrap
- Split monolithic CreatePod into re-entrant subtasks (CreateSvc/CreatePVC/CreatePod/WaitPodReady)
- Distinguish bootstrap vs scale-out flows based on parent cluster status
- Populate ServiceIP in UpdateStatus() to survive across reconcile cycles
- Add WaitClusterBootstrapped task with Failed-state circuit breaker

Introduce oceanbase-helper logservice start command:
- Prepare directories and persist etc/ config to store volume via symlink
- Detect config.toml presence to distinguish first-boot vs restart
- Monitor daemonized oblogservice process and forward signals for graceful shutdown
…ce mode

OBLogServiceNode now follows the same annotation-driven pattern as
OBServer for service mode selection. The mode annotation propagates
through Cluster → Zone → Node, and CreateSvc/LOCAL_IP injection
are conditioned on mode=service. Pod IP mode uses downward API.
… deletion

Align OBLogServiceNode recover flow with the OBServer pattern:
- DeletePod no longer clears Status.PodIP, so generateStaticIpAnnotation
  can pin the recreated pod to its old address (Calico/KubeOvn), keeping
  the ln registration and persisted config.toml local_ip valid
- insert WaitPodDeleted between DeletePod and CreatePod to avoid the
  IsAlreadyExists swallow racing a terminating pod
A failed/evicted pod can report an empty status.podIP; writing it into
OBLogServiceNode status right before setRecoveryStatus() would defeat
the static-IP pin that recovery relies on. WaitPodReady still refreshes
the IP from the recreated pod once it is running.
Junkrat77 added 3 commits July 8, 2026 14:56
B1: Redact credentials (access_id/access_key) in SQL execution logs.
B2: Add nil guards for storage pointers in telemetry transform.
B3: Use annotation-based protocol for deterministic scale-in node
    selection, preventing race between unregister and delete tasks.
B4: Make bootstrap idempotent (tolerate "already bootstrap"), split
    MarkNodesRegistered into its own task, use RetryFromCurrent
    strategy, and allow re-entry from Failed status.
…tion

- oblogservicenode UpdateStatus: refresh PodIP/phase unconditionally
  (not only when Status==Running) so Pod-IP mode bootstrap can read the
  node connect address. Preserves the B5 guard (empty PodIP does not
  overwrite last-known IP) and keeps recovery gating on Running.
- oblogservicezone: move sortDeleteCandidates to manager.go (no-return
  func crashes the task_register generator in _task.go); add name
  tiebreaker for deterministic deletion ordering.
- RunJob: timeout and empty-pod-list paths used errors.Wrapf(err, ...)
  which returns nil when err is nil, causing RunJob to return a nil
  error (false success) when job polling timed out with the last GetJob
  succeeding. This made LogService bootstrap falsely report "succeeded"
  while the job was still failing. Use errors.Errorf for the timeout
  path and split the pod-list condition so nil err is not wrapped.
- CreatePVC: snapshot StoreStorage/LogStorage into locals right after
  the nil checks and use them in PVC construction, defending against an
  intermittent nil-deref observed at the LogStorage.Size use despite the
  pre-existing nil checks.
@Junkrat77 Junkrat77 force-pushed the feature/shared-storage-support branch 2 times, most recently from e2d45f0 to a32dab0 Compare July 13, 2026 02:37
- Merge identical switch branches in SupportStaticIP (revive)
- Check fmt.Sscanf return value in getDaemonPid (errcheck)
- Add package doc comment for helper package (revive)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant