Skip to content

Commit

Permalink
Merge pull request #3 from logzio/dev
Browse files Browse the repository at this point in the history
v1.0.2
  • Loading branch information
yotamloe committed Jun 7, 2023
2 parents 45fc900 + 83488d5 commit 8337f4f
Show file tree
Hide file tree
Showing 6 changed files with 17 additions and 1 deletion.
2 changes: 1 addition & 1 deletion Makefile
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
IMAGE_NAME := ezkonnect-server
IMAGE_TAG := v1.0.1
IMAGE_TAG := v1.0.2
DOCKER_REPO := logzio/$(IMAGE_NAME):$(IMAGE_TAG)
K8S_NAMESPACE := ezkonnect

Expand Down
2 changes: 2 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,8 @@ This endpoint allows you to update annotations for Kubernetes deployments and st


## changelog
- v1.0.2
- Ignore internal resources
- v1.0.1
- Add support for adding service name
- v1.0.0 - Initial release
Expand Down
3 changes: 3 additions & 0 deletions api/annotate/logs.go
Original file line number Diff line number Diff line change
Expand Up @@ -63,6 +63,7 @@ func UpdateLogsResourceAnnotations(w http.ResponseWriter, r *http.Request) {
}

// Validate input before updating resources to avoid changing resources and retuning an error
logger.Info("Validating input")
validRequests := validateLogsResourceRequests(resources)
// if one of the requests is invalid, return an error
if !validRequests {
Expand All @@ -88,6 +89,7 @@ func UpdateLogsResourceAnnotations(w http.ResponseWriter, r *http.Request) {

switch resource.Kind {
case api.KindDeployment:
logger.Info("Updating deployment with log type annotation", resource.Name)
deployment, err := clientset.AppsV1().Deployments(resource.Namespace).Get(r.Context(), resource.Name, v1.GetOptions{})
if err != nil {
logger.Error(api.ErrorGet, err)
Expand All @@ -112,6 +114,7 @@ func UpdateLogsResourceAnnotations(w http.ResponseWriter, r *http.Request) {
responses = append(responses, response)

case api.KindStatefulSet:
logger.Info("Updating statefulset with log type annotation", resource.Name)
statefulSet, err := clientset.AppsV1().StatefulSets(resource.Namespace).Get(r.Context(), resource.Name, v1.GetOptions{})
if err != nil {
logger.Error(api.ErrorGet, err)
Expand Down
2 changes: 2 additions & 0 deletions api/annotate/traces.go
Original file line number Diff line number Diff line change
Expand Up @@ -98,6 +98,7 @@ func UpdateTracesResourceAnnotations(w http.ResponseWriter, r *http.Request) {

switch resource.Kind {
case api.KindDeployment:
logger.Info("Updating deployment with instrumentation annotation", resource.Name)
deployment, err := clientset.AppsV1().Deployments(resource.Namespace).Get(r.Context(), resource.Name, v1.GetOptions{})
if err != nil {
logger.Error(api.ErrorGet, err)
Expand All @@ -122,6 +123,7 @@ func UpdateTracesResourceAnnotations(w http.ResponseWriter, r *http.Request) {
responses = append(responses, response)

case api.KindStatefulSet:
logger.Info("Updating statefulset with instrumentation annotation ", resource.Name)
statefulSet, err := clientset.AppsV1().StatefulSets(resource.Namespace).Get(r.Context(), resource.Name, v1.GetOptions{})
if err != nil {
logger.Error(api.ErrorGet, err)
Expand Down
5 changes: 5 additions & 0 deletions api/common.go
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ import (
"k8s.io/client-go/util/homedir"
"os"
"path/filepath"
"strings"
)

const (
Expand Down Expand Up @@ -61,3 +62,7 @@ func GetConfig() (*rest.Config, error) {

return config, nil
}

func IsInternalResource(name string) bool {
return strings.Contains(name, "ezkonnect") || (name == "kubernetes-instrumentor")
}
4 changes: 4 additions & 0 deletions api/state/state.go
Original file line number Diff line number Diff line change
Expand Up @@ -78,6 +78,10 @@ func GetCustomResourcesHandler(w http.ResponseWriter, r *http.Request) {
var data []InstrumentdApplicationData
for _, item := range instrumentedApplicationsList.Items {
name := item.GetName()
// Skip internal resources
if api.IsInternalResource(name) {
continue
}
namespace := item.GetNamespace()
ControllerKind := strings.ToLower(item.GetOwnerReferences()[0].Kind)
status := item.Object["status"].(map[string]interface{})
Expand Down

0 comments on commit 8337f4f

Please sign in to comment.