Skip to content
Merged
Show file tree
Hide file tree
Changes from 3 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
18 changes: 10 additions & 8 deletions main/handlersettings.go
Original file line number Diff line number Diff line change
Expand Up @@ -86,17 +86,19 @@ func (h handlerSettings) validate() error {
}

type vmWatchSignalFilters struct {
EnabledTags []string `json:"enabledTags,array"`
DisabledTags []string `json:"disabledTags,array"`
EnabledOptionalSignals []string `json:"enabledOptionalSignals,array"`
DisabledSignals []string `json:"disabledSignals,array"`
EnabledTags []string `json:"enabledTags,array"`
DisabledTags []string `json:"disabledTags,array"`
EnabledOptionalSignals []string `json:"enabledOptionalSignals,array"`
DisabledSignals []string `json:"disabledSignals,array"`
}

type vmWatchSettings struct {
Enabled bool `json:"enabled,boolean"`
SignalFilters *vmWatchSignalFilters `json:"signalFilters"`
ParameterOverrides map[string]interface{} `json:"parameterOverrides,object"`
EnvironmentAttributes map[string]interface{} `json:"environmentAttributes,object"`
Enabled bool `json:"enabled,boolean"`
SignalFilters *vmWatchSignalFilters `json:"signalFilters"`
ParameterOverrides map[string]interface{} `json:"parameterOverrides,object"`
EnvironmentAttributes map[string]interface{} `json:"environmentAttributes,object"`
GlobalConfigUrl string `json:"globalConfigUrl,string"`
DisableConfigReader bool `json:"disableConfigReader,boolean"`
}

// publicSettings is the type deserialized from public configuration section of
Expand Down
9 changes: 9 additions & 0 deletions main/schema.go
Original file line number Diff line number Diff line change
Expand Up @@ -103,6 +103,15 @@ const (
"description": "Optional - environment attributes (eg OutboundConnectivityEnabled : true)",
"type": "object",
"default": {}
},
"globalConfigUrl": {
"description": "Optional - specify global config url to download vmwatch configuration from",
"type": "string"
},
"disableConfigReader": {
"description": "Optional - flag to disable config reader",
"type": "boolean",
"default": false
}
}
}
Expand Down
18 changes: 18 additions & 0 deletions main/vmWatch.go
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ import (
"os/exec"
"path/filepath"
"sort"
"strconv"
"strings"
"sync"
"time"
Expand Down Expand Up @@ -37,6 +38,9 @@ const (
const (
AllowVMWatchCgroupAssignmentFailureVariableName string = "ALLOW_VMWATCH_CGROUP_ASSIGNMENT_FAILURE"
RunningInDevContainerVariableName string = "RUNNING_IN_DEV_CONTAINER"
AppHealthExecutionEnvironmentProd string = "Prod"
AppHealthExecutionEnvironmentTest string = "Test"
AppHealthPublisherNameTest string = "Microsoft.ManagedServices.Edp"
)

func (p VMWatchStatus) GetStatusType() StatusType {
Expand Down Expand Up @@ -223,6 +227,7 @@ func setupVMWatchCommand(s *vmWatchSettings, hEnv HandlerEnvironment) (*exec.Cmd
args := []string{"--config", GetVMWatchConfigFullPath(processDirectory)}
args = append(args, "--debug")
args = append(args, "--heartbeat-file", GetVMWatchHeartbeatFilePath(hEnv))
args = append(args, "--execution-environment", GetExecutionEnvironment(hEnv))

if s.SignalFilters != nil {
if s.SignalFilters.DisabledSignals != nil && len(s.SignalFilters.DisabledSignals) > 0 {
Expand All @@ -246,6 +251,12 @@ func setupVMWatchCommand(s *vmWatchSettings, hEnv HandlerEnvironment) (*exec.Cmd
}
}

if len(strings.TrimSpace(s.GlobalConfigUrl)) > 0 {
args = append(args, "--global-config-url", s.GlobalConfigUrl)
}

args = append(args, "--disable-config-reader", strconv.FormatBool(s.DisableConfigReader))

if s.EnvironmentAttributes != nil {
if len(s.EnvironmentAttributes) > 0 {
args = append(args, "--env-attributes")
Expand Down Expand Up @@ -351,6 +362,13 @@ func GetVMWatchHeartbeatFilePath(hEnv HandlerEnvironment) string {
return filepath.Join(hEnv.HandlerEnvironment.LogFolder, "vmwatch-heartbeat.txt")
}

func GetExecutionEnvironment(hEnv HandlerEnvironment) string {
if strings.Contains(hEnv.HandlerEnvironment.LogFolder, AppHealthPublisherNameTest) {
return AppHealthExecutionEnvironmentTest
}
return AppHealthExecutionEnvironmentProd
}

func GetVMWatchConfigFullPath(processDirectory string) string {
return filepath.Join(processDirectory, "VMWatch", VMWatchConfigFileName)
}
Expand Down