-
Notifications
You must be signed in to change notification settings - Fork 1.2k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[NDMII-3310] add support for HA integrations #33828
Changes from 7 commits
dd699ed
8141d48
c7d1142
0b3caea
88ff94a
0bde365
c1f429b
0ea0a86
9bc8a11
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -153,6 +153,9 @@ func (c *CheckBase) CommonConfigure(senderManager sender.SenderManager, initConf | |
|
||
if commonOptions.HAEnabled != nil { | ||
c.haEnabled = *commonOptions.HAEnabled | ||
if c.haEnabled && !c.IsHASupported() { | ||
return fmt.Errorf("High Availability is enabled for check %s but this integration does not support it", string(c.ID())) | ||
} | ||
jedupau marked this conversation as resolved.
Show resolved
Hide resolved
|
||
} | ||
|
||
c.source = source | ||
|
@@ -295,3 +298,8 @@ func (c *CheckBase) GetDiagnoses() ([]diagnosis.Diagnosis, error) { | |
func (c *CheckBase) IsHAEnabled() bool { | ||
return c.haEnabled | ||
} | ||
|
||
// IsHASupported returns if the check is compatible with High Availability | ||
func (c *CheckBase) IsHASupported() bool { | ||
return false | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. How checks would opt-in? Since go doesn't support virtual methods, |
||
} |
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -23,6 +23,10 @@ foo_init: bar_init | |
min_collection_interval: 60 | ||
empty_default_hostname: true | ||
name: foobar | ||
` | ||
haConfig = ` | ||
foo_init: bar_init | ||
ha_enabled: true | ||
` | ||
) | ||
|
||
|
@@ -68,3 +72,19 @@ func TestCommonConfigureCustomID(t *testing.T) { | |
assert.Equal(t, string(mycheck.ID()), "test:foobar:a934df33209f45f4") | ||
mockSender.AssertExpectations(t) | ||
} | ||
|
||
func TestCommonConfigureNotHASupported(t *testing.T) { | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Could you please also add a test that a check can actually opt-in? |
||
checkName := "test" | ||
mycheck := &dummyCheck{ | ||
CheckBase: NewCheckBase(checkName), | ||
} | ||
mockSender := mocksender.NewMockSender(mycheck.ID()) | ||
|
||
err := mycheck.CommonConfigure(mockSender.GetSenderManager(), nil, []byte(haConfig), "test") | ||
assert.Error(t, err) | ||
assert.Contains(t, err.Error(), "High Availability is enabled for check test but this integration does not support it") | ||
|
||
err = mycheck.CommonConfigure(mockSender.GetSenderManager(), []byte(haConfig), nil, "test") | ||
assert.Error(t, err) | ||
assert.Contains(t, err.Error(), "High Availability is enabled for check test but this integration does not support it") | ||
} |
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -290,6 +290,11 @@ func (c *CiscoSdwanCheck) Interval() time.Duration { | |
return c.interval | ||
} | ||
|
||
// IsHASupported returns true if the check supports HA | ||
func (c *CiscoSdwanCheck) IsHASupported() bool { | ||
return true | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
|
||
} | ||
|
||
func boolPointer(b bool) *bool { | ||
return &b | ||
} | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -112,13 +112,15 @@ type checkInstanceCfg struct { | |
JavaOptions string `yaml:"java_options,omitempty"` | ||
ToolsJarPath string `yaml:"tools_jar_path,omitempty"` | ||
ProcessNameRegex string `yaml:"process_name_regex,omitempty"` | ||
HAEnabled bool `yaml:"ha_enabled,omitempty"` | ||
} | ||
|
||
type checkInitCfg struct { | ||
CustomJarPaths []string `yaml:"custom_jar_paths,omitempty"` | ||
ToolsJarPath string `yaml:"tools_jar_path,omitempty"` | ||
JavaBinPath string `yaml:"java_bin_path,omitempty"` | ||
JavaOptions string `yaml:"java_options,omitempty"` | ||
HAEnabled bool `yaml:"ha_enabled,omitempty"` | ||
} | ||
|
||
func NewJMXFetch(logger jmxlogger.Component) *JMXFetch { | ||
|
@@ -478,6 +480,9 @@ func (j *JMXFetch) ConfigureFromInitConfig(initConfig integration.Data) error { | |
j.JavaCustomJarPaths = initConf.CustomJarPaths | ||
} | ||
} | ||
if initConf.HAEnabled { | ||
return fmt.Errorf("High Availability is not supported in JMX integrations") | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This doesn't seem to propagate to There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. it seems that no configuration errors in jmx integrations appears in the status 🤔 |
||
} | ||
|
||
return nil | ||
} | ||
|
@@ -508,6 +513,9 @@ func (j *JMXFetch) ConfigureFromInstance(instance integration.Data) error { | |
j.JavaToolsJarPath = instanceConf.ToolsJarPath | ||
} | ||
} | ||
if instanceConf.HAEnabled { | ||
return fmt.Errorf("High Availability is not supported in JMX integrations") | ||
} | ||
|
||
return nil | ||
} | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
CheckWrapper#IsHASupported
is the only place where this interface method is called. Since we don't call anywhere useful, this can be safely removed.