Skip to content
This repository was archived by the owner on Jan 16, 2023. It is now read-only.
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
27 commits
Select commit Hold shift + click to select a range
bb2c1f5
DEV-39965: Allow the user to specify a parent group during installation
Oct 12, 2018
5735cb4
Merge pull request #1 in DEV/k8s-argus from DEV-39965-allow-the-user-…
Oct 15, 2018
2d53e26
DEV-39965: Allow the user to specify a parent group during installation
Oct 16, 2018
3c03f96
Merge pull request #2 in DEV/k8s-argus from DEV-39965-allow-the-user-…
Oct 16, 2018
5dfab5b
DEV-40505: Sync the k8s resource to santaba when argus launches
Nov 1, 2018
4058f07
DEV-40434: The alert status of Pods and Services are disabled
Nov 2, 2018
e43a6a7
DEV-40505: Sync the k8s resource to santaba when argus launches
Nov 2, 2018
58a9125
Merge pull request #3 in DEV/k8s-argus from DEV-40505-sync-the-k8s-re…
Nov 6, 2018
33c0a67
Merge pull request #4 in DEV/k8s-argus from bugfix/DEV-40434-the-aler…
Nov 6, 2018
b4ce488
DEV-40505: Sync the k8s resource to santaba when argus launches
Nov 9, 2018
a03490e
Merge pull request #6 in DEV/k8s-argus from DEV-40505-sync-the-k8s-re…
Nov 10, 2018
e7c90f1
DEV-40779: Enable the alert on service group when it is created by argus
Nov 14, 2018
d36f943
Merge pull request #7 in DEV/k8s-argus from DEV-40779-enable-the-aler…
Nov 15, 2018
cc8efda
DEV-41432: Use IP as hostname for argus related devices
Dec 11, 2018
eb4fffb
DEV-41432: Use IP as hostname for argus related devices
Dec 13, 2018
16000b5
DEV-41459: Add a new device type for k8s devices
Dec 13, 2018
821500c
Merge pull request #9 in DEV/k8s-argus from DEV-41459-add-a-new-devic…
Dec 14, 2018
d570b4f
Merge pull request #8 in DEV/k8s-argus from DEV-41432-use-ip-as-hostn…
Dec 14, 2018
e6152f8
DEV-41432: Use IP as hostname for argus related devices
Dec 17, 2018
4079f66
Merge pull request #10 in DEV/k8s-argus from DEV-41432-use-ip-as-host…
Dec 17, 2018
f35228a
DEV-40217: Support to set log levels and improve logs in argus relate…
Dec 18, 2018
968a0ad
DEV-40217: Support to set log levels and improve logs in argus relate…
Dec 19, 2018
e56e41e
DEV-41682: Improve the argus code for the CI failure in GitHub
Dec 21, 2018
5a8c798
Merge pull request #12 in DEV/k8s-argus from DEV-41682-improve-the-ar…
Dec 26, 2018
f634986
Merge pull request #11 in DEV/k8s-argus from DEV-40217-support-to-set…
Dec 26, 2018
19d7f00
Merge pull request #2 from JeremyTangCD/DEV-40217-support-to-set-log-…
JeremyTangCD Jan 2, 2019
31b40cd
Merge branch 'develop' into master
JeremyTangCD Jan 2, 2019
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: 2 additions & 0 deletions cmd/watch.go
Original file line number Diff line number Diff line change
Expand Up @@ -113,6 +113,7 @@ func pollCollectorSetStatus(conn *grpc.ClientConn) (bool, error) {
case <-timeout:
return false, fmt.Errorf("Timeout waiting for collectors to become available")
case <-ticker.C:
log.Debugf("Checking collectors status")
ctx, cancel := context.WithTimeout(context.Background(), time.Millisecond*500)
defer cancel()
req := &healthpb.HealthCheckRequest{
Expand All @@ -126,6 +127,7 @@ func pollCollectorSetStatus(conn *grpc.ClientConn) (bool, error) {
if healthCheckResponse.GetStatus() == healthpb.HealthCheckResponse_SERVING {
return true, nil
}
log.Debugf("The collectors are not ready: %d", healthCheckResponse.GetStatus())
}
}
}
Expand Down
6 changes: 3 additions & 3 deletions pkg/device/device.go
Original file line number Diff line number Diff line change
Expand Up @@ -40,9 +40,9 @@ func buildDevice(c *config.Config, client api.CollectorSetControllerClient, opti

reply, err := client.CollectorID(context.Background(), &api.CollectorIDRequest{})
if err != nil {
log.Printf("Failed to get collector ID: %v", err)
log.Errorf("Failed to get collector ID: %v", err)
} else {
log.Printf("Using collector ID %d for %q", reply.Id, device.DisplayName)
log.Infof("Using collector ID %d for %q", reply.Id, device.DisplayName)
device.PreferredCollectorId = reply.Id
}

Expand Down Expand Up @@ -100,7 +100,7 @@ func (m *Manager) UpdateAndReplaceByDisplayName(name string, options ...types.De
}

if d == nil {
log.Printf("Could not find device %q", name)
log.Warnf("Could not find device %q", name)
return nil, nil
}

Expand Down
2 changes: 1 addition & 1 deletion pkg/sync/initsyncer.go
Original file line number Diff line number Diff line change
Expand Up @@ -66,8 +66,8 @@ func (i *InitSyncer) InitSync() {

// wait the init sync processes finishing
wg.Wait()
log.Infof("Finish syncing the resource devices")
}
log.Infof("Finished syncing the resource devices")
}

func (i *InitSyncer) intSyncNodes(parentGroupID int32) {
Expand Down
18 changes: 9 additions & 9 deletions pkg/utilities/utilities.go
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,15 @@ func GetLabelByPrefix(prefix string, labels map[string]string) (string, string)

// CheckAllErrors is a helper function to deal with the number of possible places that an API call can fail.
func CheckAllErrors(restResponse interface{}, apiResponse *logicmonitor.APIResponse, err error) error {
if err != nil {
return fmt.Errorf("[ERROR] %v", err)
}

if apiResponse.Response != nil && apiResponse.StatusCode != http.StatusOK {
metrics.APIError()
return fmt.Errorf("[API] [%d] %s", apiResponse.StatusCode, apiResponse.Message)
}

var restResponseMessage string
var restResponseStatus int64

Expand Down Expand Up @@ -62,14 +71,5 @@ func CheckAllErrors(restResponse interface{}, apiResponse *logicmonitor.APIRespo
return fmt.Errorf("[REST] [%d] %s", restResponseStatus, restResponseMessage)
}

if apiResponse.StatusCode != http.StatusOK {
metrics.APIError()
return fmt.Errorf("[API] [%d] %s", apiResponse.StatusCode, restResponseMessage)
}

if err != nil {
return fmt.Errorf("[ERROR] %v", err)
}

return nil
}
8 changes: 6 additions & 2 deletions pkg/watch/namespace/namespace.go
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,7 @@ func (w Watcher) ObjType() runtime.Object {
func (w Watcher) AddFunc() func(obj interface{}) {
return func(obj interface{}) {
namespace := obj.(*v1.Namespace)
log.Debugf("Handling add namespace event: %s", namespace.Name)
for name, parentID := range w.DeviceGroups {
var appliesTo devicegroup.AppliesToBuilder
// Ensure that we are creating namespaces for namespaced resources.
Expand Down Expand Up @@ -62,14 +63,15 @@ func (w Watcher) AddFunc() func(obj interface{}) {
return
}

log.Printf("Added namespace %q to %q", namespace.Name, name)
log.Infof("Added namespace %q to %q", namespace.Name, name)
}
}
}

// UpdateFunc is a function that implements the Watcher interface.
func (w Watcher) UpdateFunc() func(oldObj, newObj interface{}) {
return func(oldObj, newObj interface{}) {
log.Debugf("Ignoring update namespace event")
// oldNamespace := oldObj.(*v1.Namespace)
// newNamespace := newObj.(*v1.Namespace)
}
Expand All @@ -79,10 +81,12 @@ func (w Watcher) UpdateFunc() func(oldObj, newObj interface{}) {
func (w Watcher) DeleteFunc() func(obj interface{}) {
return func(obj interface{}) {
namespace := obj.(*v1.Namespace)
log.Debugf("Handle deleting namespace event: %s", namespace.Name)

for name, parentID := range w.DeviceGroups {
deviceGroup, err := devicegroup.Find(parentID, name, w.LMClient)
if err != nil {
log.Printf("Failed to find namespace %s: %v", name, err)
log.Warnf("Failed to find namespace %s: %v", name, err)
return
}
// We should only be returned a device group if it is namespaced.
Expand Down
22 changes: 18 additions & 4 deletions pkg/watch/node/node.go
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ func (w *Watcher) AddFunc() func(obj interface{}) {
return func(obj interface{}) {
node := obj.(*v1.Node)

log.Debugf("received ADD event: %s", node.Name)
log.Debugf("Handling add node event: %s", node.Name)

// Require an IP address.
if getInternalAddress(node.Status.Addresses) == nil {
Expand All @@ -59,7 +59,7 @@ func (w *Watcher) UpdateFunc() func(oldObj, newObj interface{}) {
old := oldObj.(*v1.Node)
new := newObj.(*v1.Node)

log.Debugf("received UPDATE event: %s", old.Name)
log.Debugf("Handling update node event: %s", old.Name)

// If the old node does not have an IP, then there is no way we could
// have added it to LogicMonitor. Therefore, it must be a new device.
Expand All @@ -83,7 +83,7 @@ func (w *Watcher) DeleteFunc() func(obj interface{}) {
return func(obj interface{}) {
node := obj.(*v1.Node)

log.Debugf("received DELETE event: %s", node.Name)
log.Debugf("Handling delete node event: %s", node.Name)

// Delete the node.
if w.Config().DeleteDevices {
Expand Down Expand Up @@ -190,7 +190,21 @@ func (w *Watcher) createRoleDeviceGroup(labels map[string]string) {
return
}

log.Printf("Added device group for node role %q", role)
log.Infof("Added device group for node role %q", role)
}

// GetNodesMap implements the getting nodes map info from k8s
func GetNodesMap(k8sClient *kubernetes.Clientset) (map[string]string, error) {
nodesMap := make(map[string]string)
nodeList, err := k8sClient.CoreV1().Nodes().List(metav1.ListOptions{})
if err != nil || nodeList == nil {
return nil, err
}
for _, nodeInfo := range nodeList.Items {
nodesMap[nodeInfo.Name] = getInternalAddress(nodeInfo.Status.Addresses).Address
}

return nodesMap, nil
}

// GetNodesMap implements the getting nodes map info from k8s
Expand Down
6 changes: 3 additions & 3 deletions pkg/watch/pod/pod.go
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ func (w *Watcher) AddFunc() func(obj interface{}) {
return func(obj interface{}) {
pod := obj.(*v1.Pod)

log.Debugf("received ADD event: %s", pod.Name)
log.Debugf("Handling add pod event: %s", pod.Name)

// Require an IP address.
if pod.Status.PodIP == "" {
Expand All @@ -53,7 +53,7 @@ func (w *Watcher) UpdateFunc() func(oldObj, newObj interface{}) {
old := oldObj.(*v1.Pod)
new := newObj.(*v1.Pod)

log.Debugf("received UPDATE event: %s", old.Name)
log.Debugf("Handling update pod event: %s", old.Name)

// If the old pod does not have an IP, then there is no way we could
// have added it to LogicMonitor. Therefore, it must be a new w.
Expand Down Expand Up @@ -83,7 +83,7 @@ func (w *Watcher) DeleteFunc() func(obj interface{}) {
return func(obj interface{}) {
pod := obj.(*v1.Pod)

log.Debugf("received DELETE event: %s", pod.Name)
log.Debugf("Handling delete pod event: %s", pod.Name)

// Delete the pod.
if w.Config().DeleteDevices {
Expand Down