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
feat: Use old configMap data with failure message in case APIs has error #13
Conversation
Signed-off-by: Heba Elayoty <hebaelayoty@gmail.com>
manual e2e: + helm install carbon-e2e --set apiServer.image.repository=helayoty/server --set carbonDataExporter.image.repository=helayoty/exporter --set carbonDataExporter.patrolInterval=15s --set apiServer.username=*** --set apiServer.password=*** ./charts/carbon-intensity-exporter
NAME: carbon-e2e
LAST DEPLOYED: Wed Apr 5 12:06:23 2023
NAMESPACE: default
STATUS: deployed
REVISION: 1
TEST SUITE: None
+ kubectl wait --for=condition=available deploy carbon-e2e-carbon-intensity-exporter -n kube-system --timeout=300s
deployment.apps/carbon-e2e-carbon-intensity-exporter condition met
+ sleep 15
+ kubectl get configmap carbon-intensity -n kube-system
NAME DATA AGE
carbon-intensity 7 9s
+ kubectl describe configmap carbon-intensity -n kube-system
Name: carbon-intensity
Namespace: kube-system
Labels: <none>
Annotations: <none>
Data
====
minForecast:
----
523.855390
numOfRecords:
----
288
forecastDateTime:
----
2023-04-05 19:10:00 +0000 UTC
lastHeartbeatTime:
----
2023-04-05 19:06:34.454676722 +0000 UTC m=+5.907866286
maxForecast:
----
590.034749
message:
----
BinaryData
====
data: 29047 bytes
Events: <none>
+ sleep 10
+ kubectl delete configmap carbon-intensity -n kube-system
configmap "carbon-intensity" deleted
+ sleep 15
+ kubectl get configmap carbon-intensity -n kube-system
NAME DATA AGE
carbon-intensity 7 5s
+ kubectl describe configmap carbon-intensity -n kube-system
Name: carbon-intensity
Namespace: kube-system
Labels: <none>
Annotations: <none>
Data
====
numOfRecords:
----
288
forecastDateTime:
----
2023-04-05 19:10:00 +0000 UTC
lastHeartbeatTime:
----
2023-04-05 19:07:04.578693327 +0000 UTC m=+36.032450913
maxForecast:
----
590.034749
message:
----
minForecast:
----
523.855390
BinaryData
====
data: 29047 bytes
Events: <none>
+ sleep 5
+++ kubectl get pods -n kube-system -o=name
+++ grep carbon-e2e-carbon-intensity-exporter
+++ sed 's/^.\{4\}//'
++ echo carbon-e2e-carbon-intensity-exporter-778578866d-jpc46
+ kubectl logs carbon-e2e-carbon-intensity-exporter-778578866d-jpc46 -c carbon-data-exporter -n kube-system
I0405 19:06:33.586657 1 options.go:108] Neither kubeconfig file nor control plane URL was specified. Falling back to in-cluster config.
I0405 19:06:34.463291 1 configmap.go:73] configMap carbon-intensity has been created
I0405 19:06:49.479008 1 configmap.go:107] configMap carbon-intensity has been deleted
I0405 19:06:49.609019 1 configmap.go:73] configMap carbon-intensity has been created
I0405 19:06:54.162503 1 configmap.go:73] configMap carbon-intensity has been created
I0405 19:07:04.477228 1 configmap.go:107] configMap carbon-intensity has been deleted
I0405 19:07:04.585045 1 configmap.go:73] configMap carbon-intensity has been created
|
pkg/exporter/exporter.go
Outdated
if err != nil { | ||
if currentConfigMap != nil { | ||
// return old data with failed message | ||
return e.UseCurrentConfigMap(ctx, currentConfigMap) |
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.
Let us pass the error message from SDK to configmap message.
For example, if user sets the wrong region name, the error message in the confgmap should show the corresponding error message.
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.
Done
Signed-off-by: Heba Elayoty <hebaelayoty@gmail.com>
Signed-off-by: Heba Elayoty <hebaelayoty@gmail.com>
Get the current configMap (if any) and if the API got the error after retrying, we will set the new configMap with the same data and