Skip to content
Open
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
2 changes: 1 addition & 1 deletion .github/workflows/go-build-and-test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ jobs:
cd workloadagentplatform
# this is the hash of the workloadagentplatform submodule
# get the hash by running: go list -m -json github.com/GoogleCloudPlatform/workloadagentplatform@main
git checkout f54e4d15148c638bd3cd1748cf21bfbc88a47593
git checkout 27b82f043534ca3dd5965f7ebd92b5317e19ecf6
cd ..
find workloadagentplatform/sharedprotos -type f -exec sed -i 's|"sharedprotos|"workloadagentplatform/sharedprotos|g' {} +
env:
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/go-build-protos.yml
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ jobs:
cd workloadagentplatform
# this is the hash of the workloadagentplatform submodule
# get the hash by running: go list -m -json github.com/GoogleCloudPlatform/workloadagentplatform@main
git checkout f54e4d15148c638bd3cd1748cf21bfbc88a47593
git checkout 27b82f043534ca3dd5965f7ebd92b5317e19ecf6
cd ..
find workloadagentplatform/sharedprotos -type f -exec sed -i 's|"sharedprotos|"workloadagentplatform/sharedprotos|g' {} +
env:
Expand Down
2 changes: 1 addition & 1 deletion build.sh
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,7 @@ if [ "${COMPILE_PROTOS}" == "TRUE" ] && [ ! -d "workloadagentplatform" ]; then
cd workloadagentplatform
# this is the hash of the workloadagentplatform submodule
# get the hash by running: go list -m -json github.com/GoogleCloudPlatform/workloadagentplatform@main
git checkout f54e4d15148c638bd3cd1748cf21bfbc88a47593
git checkout 27b82f043534ca3dd5965f7ebd92b5317e19ecf6
cd ..
# replace the proto imports in the platform that reference the platform
find workloadagentplatform/sharedprotos -type f -exec sed -i 's|"sharedprotos|"workloadagentplatform/sharedprotos|g' {} +
Expand Down
4 changes: 2 additions & 2 deletions go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -13,10 +13,10 @@ require (
github.com/DATA-DOG/go-sqlmock v1.5.0
// Get the version by running:
// go list -m -json github.com/GoogleCloudPlatform/workloadagentplatform/sharedlibraries@main
github.com/GoogleCloudPlatform/workloadagentplatform/sharedlibraries v0.0.0-20251121062745-f54e4d15148c
github.com/GoogleCloudPlatform/workloadagentplatform/sharedlibraries v0.0.0-20260109223652-27b82f043534
// Get the version by running:
// go list -m -json github.com/GoogleCloudPlatform/workloadagentplatform/sharedprotos@main
github.com/GoogleCloudPlatform/workloadagentplatform/sharedprotos v0.0.0-20251121062745-f54e4d15148c
github.com/GoogleCloudPlatform/workloadagentplatform/sharedprotos v0.0.0-20260109223652-27b82f043534
github.com/StackExchange/wmi v1.2.1
github.com/cenkalti/backoff/v4 v4.3.0
github.com/gammazero/workerpool v1.1.3
Expand Down
8 changes: 4 additions & 4 deletions go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -31,10 +31,10 @@ github.com/DATA-DOG/go-sqlmock v1.5.0 h1:Shsta01QNfFxHCfpW6YH2STWB0MudeXXEWMr20O
github.com/DATA-DOG/go-sqlmock v1.5.0/go.mod h1:f/Ixk793poVmq4qj/V1dPUg2JEAKC73Q5eFN3EC/SaM=
github.com/GoogleCloudPlatform/agentcommunication_client v0.0.0-20250227185639-b70667e4a927 h1:nn31d5gg+ysSNqWTqSOxsKBj17GJZBqsBx7biZAgYtI=
github.com/GoogleCloudPlatform/agentcommunication_client v0.0.0-20250227185639-b70667e4a927/go.mod h1:A1V05o309ZvTwy/FTBooYvvIhzM6mtsJcHJsAkeuAAM=
github.com/GoogleCloudPlatform/workloadagentplatform/sharedlibraries v0.0.0-20251121062745-f54e4d15148c h1:AHOi70kCuubweFKUVWpGgfCTtDC7MoMkAGjRCLWDi5g=
github.com/GoogleCloudPlatform/workloadagentplatform/sharedlibraries v0.0.0-20251121062745-f54e4d15148c/go.mod h1:WrwTr9HFkp+nbHba/tv36eCLkjKAeCx7mqiG/wL3PNU=
github.com/GoogleCloudPlatform/workloadagentplatform/sharedprotos v0.0.0-20251121062745-f54e4d15148c h1:K74cWj8vfONBD1bxWhQ/WLFc+oxDhRvf2RXhXrhOJ9o=
github.com/GoogleCloudPlatform/workloadagentplatform/sharedprotos v0.0.0-20251121062745-f54e4d15148c/go.mod h1:8Ea8vdBuPsWhhwzL9sNK7BFQE9qbkPLZUHxcucWHXaM=
github.com/GoogleCloudPlatform/workloadagentplatform/sharedlibraries v0.0.0-20260109223652-27b82f043534 h1:aNKg05es2YNDllzWmWmB6Yx9BYA9u3fouDrH/aarfZI=
github.com/GoogleCloudPlatform/workloadagentplatform/sharedlibraries v0.0.0-20260109223652-27b82f043534/go.mod h1:WrwTr9HFkp+nbHba/tv36eCLkjKAeCx7mqiG/wL3PNU=
github.com/GoogleCloudPlatform/workloadagentplatform/sharedprotos v0.0.0-20260109223652-27b82f043534 h1:p/dzu0l6Xnz+zK/bTcCrc2WFQFkxC36QMapIs4MMHm4=
github.com/GoogleCloudPlatform/workloadagentplatform/sharedprotos v0.0.0-20260109223652-27b82f043534/go.mod h1:8Ea8vdBuPsWhhwzL9sNK7BFQE9qbkPLZUHxcucWHXaM=
github.com/StackExchange/wmi v1.2.1 h1:VIkavFPXSjcnS+O8yTq7NI32k0R5Aj+v39y29VYDOSA=
github.com/StackExchange/wmi v1.2.1/go.mod h1:rcmrprowKIVzvc+NUiLncP2uuArMWLCbu9SBzvHz7e8=
github.com/bmizerany/assert v0.0.0-20160611221934-b7ed37b82869 h1:DDGfHa7BWjL4YnC6+E63dPcxHo2sUxDIu8g3QgEJdRY=
Expand Down
63 changes: 45 additions & 18 deletions internal/daemon/oracle/oracle.go
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ package oracle
import (
"context"
"runtime"
"strings"
"sync"
"time"

Expand All @@ -34,6 +35,7 @@ import (
"github.com/GoogleCloudPlatform/workloadagentplatform/sharedlibraries/recovery"

cpb "github.com/GoogleCloudPlatform/workloadagent/protos/configuration"
gpb "github.com/GoogleCloudPlatform/workloadagentplatform/sharedprotos/guestactions"
)

const (
Expand Down Expand Up @@ -74,8 +76,8 @@ type Service struct {
}

type runGuestActionsArgs struct {
s *Service
handlers map[string]guestactions.GuestActionHandler
s *Service
lroHandlers map[string]guestactions.GuestActionHandler
}

type runDiscoveryArgs struct {
Expand Down Expand Up @@ -137,24 +139,23 @@ func (s *Service) Start(ctx context.Context, a any) {
s.metricCollectionRoutine.StartRoutine(mcCtx)
}

oracleHandler := oraclehandlers.New()
handlers := map[string]guestactions.GuestActionHandler{
"oracle_run_discovery": oracleHandler.RunDiscovery,
"oracle_stop_database": oracleHandler.StopDatabase,
"oracle_disable_autostart": oracleHandler.DisableAutostart,
"oracle_start_database": oracleHandler.StartDatabase,
"oracle_run_datapatch": oracleHandler.RunDatapatch,
"oracle_disable_restricted_mode": oracleHandler.DisableRestrictedMode,
"oracle_start_listener": oracleHandler.StartListener,
"oracle_enable_autostart": oracleHandler.EnableAutostart,
"oracle_health_check": oracleHandler.HealthCheck,
"oracle_data_guard_switchover": oracleHandler.DataGuardSwitchover,
lroHandlers := map[string]guestactions.GuestActionHandler{
"oracle_data_guard_switchover": oraclehandlers.DataGuardSwitchover,
"oracle_disable_autostart": oraclehandlers.DisableAutostart,
"oracle_disable_restricted_mode": oraclehandlers.DisableRestrictedMode,
"oracle_enable_autostart": oraclehandlers.EnableAutostart,
"oracle_health_check": oraclehandlers.HealthCheck,
"oracle_run_datapatch": oraclehandlers.RunDatapatch,
"oracle_run_discovery": oraclehandlers.RunDiscovery,
"oracle_start_database": oraclehandlers.StartDatabase,
"oracle_start_listener": oraclehandlers.StartListener,
"oracle_stop_database": oraclehandlers.StopDatabase,
}

gaCtx := log.SetCtx(ctx, "context", "OracleGuestActions")
guestActionsRoutine := &recovery.RecoverableRoutine{
Routine: runGuestActions,
RoutineArg: runGuestActionsArgs{s: s, handlers: handlers},
RoutineArg: runGuestActionsArgs{s: s, lroHandlers: lroHandlers},
ErrorCode: usagemetrics.GuestActionsFailure,
UsageLogger: *usagemetrics.UsageLogger,
ExpectedMinDuration: 10 * time.Second,
Expand All @@ -178,13 +179,39 @@ func runGuestActions(ctx context.Context, a any) {
}
ga := &guestactions.GuestActions{}
gaOpts := guestactions.Options{
Channel: defaultChannel,
CloudProperties: convertCloudProperties(args.s.CloudProps),
Handlers: args.handlers,
Channel: defaultChannel,
CloudProperties: convertCloudProperties(args.s.CloudProps),
LROHandlers: args.lroHandlers,
CommandConcurrencyKey: oracleCommandKey,
}
ga.Start(ctx, gaOpts)
}

// oracleCommandKey returns the locking key and timeout for a given command and whether the command
// should be locked.
// The locking key is the Oracle SID.
func oracleCommandKey(cmd *gpb.Command) (key string, timeout time.Duration, lock bool) {
if cmd.GetAgentCommand().GetParameters() == nil {
return "", 0, false
}
sid, ok := cmd.GetAgentCommand().GetParameters()["oracle_sid"]
if !ok || sid == "" {
return "", 0, false
}

cmdName := strings.ToLower(cmd.GetAgentCommand().GetCommand())
switch cmdName {
case "oracle_start_database", "oracle_stop_database", "oracle_data_guard_switchover", "oracle_run_discovery", "oracle_start_listener":
return sid, 3 * time.Minute, true
case "oracle_run_datapatch":
return sid, 30 * time.Minute, true
case "oracle_disable_autostart", "oracle_disable_restricted_mode", "oracle_enable_autostart", "oracle_health_check":
return sid, 1 * time.Minute, true
default:
return sid, 10 * time.Minute, true
}
}

func runDiscovery(ctx context.Context, a any) {
log.CtxLogger(ctx).Info("Running Oracle Discovery")
args, ok := a.(runDiscoveryArgs)
Expand Down
Loading
Loading