-
Notifications
You must be signed in to change notification settings - Fork 472
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
Silence errors for namespace listing #725
Changes from all commits
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 | ||||||||||||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
|
@@ -19,26 +19,29 @@ import ( | |||||||||||||||||||||
) | ||||||||||||||||||||||
|
||||||||||||||||||||||
// MakeNamespacesLister builds a list of namespaces with an "openfaas" tag, or the default name | ||||||||||||||||||||||
func MakeNamespacesLister(defaultNamespace string, clientset kubernetes.Interface) http.HandlerFunc { | ||||||||||||||||||||||
func MakeNamespacesLister(defaultNamespace string, clusterRole bool, clientset kubernetes.Interface) http.HandlerFunc { | ||||||||||||||||||||||
return func(w http.ResponseWriter, r *http.Request) { | ||||||||||||||||||||||
log.Println("Query namespaces") | ||||||||||||||||||||||
// log.Println("List namespaces") | ||||||||||||||||||||||
|
||||||||||||||||||||||
if r.Body != nil { | ||||||||||||||||||||||
defer r.Body.Close() | ||||||||||||||||||||||
} | ||||||||||||||||||||||
|
||||||||||||||||||||||
res := ListNamespaces(defaultNamespace, clientset) | ||||||||||||||||||||||
namespaces := []string{} | ||||||||||||||||||||||
if clusterRole { | ||||||||||||||||||||||
namespaces = ListNamespaces(defaultNamespace, clientset) | ||||||||||||||||||||||
} else { | ||||||||||||||||||||||
namespaces = append(namespaces, defaultNamespace) | ||||||||||||||||||||||
} | ||||||||||||||||||||||
Comment on lines
+30
to
+35
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. We could slightly simplify this using
Suggested change
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. Very open to a PR. |
||||||||||||||||||||||
|
||||||||||||||||||||||
out, err := json.Marshal(res) | ||||||||||||||||||||||
out, err := json.Marshal(namespaces) | ||||||||||||||||||||||
if err != nil { | ||||||||||||||||||||||
glog.Errorf("Failed to list namespaces: %s", err.Error()) | ||||||||||||||||||||||
w.WriteHeader(http.StatusInternalServerError) | ||||||||||||||||||||||
w.Write([]byte("Failed to list namespaces")) | ||||||||||||||||||||||
http.Error(w, "Failed to list namespaces", http.StatusInternalServerError) | ||||||||||||||||||||||
return | ||||||||||||||||||||||
} | ||||||||||||||||||||||
|
||||||||||||||||||||||
w.Header().Set("Content-Type", "application/json") | ||||||||||||||||||||||
|
||||||||||||||||||||||
w.WriteHeader(http.StatusOK) | ||||||||||||||||||||||
w.Write(out) | ||||||||||||||||||||||
} | ||||||||||||||||||||||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -10,6 +10,7 @@ import ( | |
"io/ioutil" | ||
"log" | ||
"net/http" | ||
"time" | ||
|
||
"github.com/gorilla/mux" | ||
"github.com/openfaas/faas-provider/types" | ||
|
@@ -102,6 +103,7 @@ func MakeReplicaReader(defaultNamespace string, clientset *kubernetes.Clientset) | |
lookupNamespace = namespace | ||
} | ||
|
||
s := time.Now() | ||
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 might be more valuable as an actual prometheus metric. Having it in the logs is nice, but it means a person is going to make judgments on a few values as opposed to being able to collect and aggregate real data into graphs etc. 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. I agree. I think it is in there already 👍 This is another example of a log message we should probably delete. |
||
function, err := getService(lookupNamespace, functionName, clientset) | ||
if err != nil { | ||
log.Printf("Unable to fetch service: %s %s\n", functionName, namespace) | ||
|
@@ -113,8 +115,8 @@ func MakeReplicaReader(defaultNamespace string, clientset *kubernetes.Clientset) | |
w.WriteHeader(http.StatusNotFound) | ||
return | ||
} | ||
|
||
log.Printf("Read replicas - %s %s, %d/%d\n", functionName, lookupNamespace, function.AvailableReplicas, function.Replicas) | ||
d := time.Since(s) | ||
log.Printf("Replicas: %s.%s, (%d/%d)\t%dms\n", functionName, lookupNamespace, function.AvailableReplicas, function.Replicas, d.Milliseconds()) | ||
|
||
functionBytes, err := json.Marshal(function) | ||
if err != 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.
Just delete it
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.
Agreed. I am still undecided about whether we should delete all happy-path logging and focus on the Prometheus metrics gathered from the gateway.