Skip to content
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

Merged
merged 3 commits into from Apr 5, 2023
Merged

feat: Use old configMap data with failure message in case APIs has error #13

merged 3 commits into from Apr 5, 2023

Conversation

helayoty
Copy link
Contributor

@helayoty helayoty commented Apr 5, 2023

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

  • Update failure message.
  • Update heartbeat time

Signed-off-by: Heba Elayoty <hebaelayoty@gmail.com>
@helayoty helayoty requested a review from Fei-Guo as a code owner April 5, 2023 19:11
@helayoty
Copy link
Contributor Author

helayoty commented Apr 5, 2023

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

if err != nil {
if currentConfigMap != nil {
// return old data with failed message
return e.UseCurrentConfigMap(ctx, currentConfigMap)
Copy link
Contributor

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.

Copy link
Contributor Author

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>
@Fei-Guo Fei-Guo merged commit 862f103 into Azure:main Apr 5, 2023
2 checks passed
@helayoty helayoty deleted the bad-api-response branch April 5, 2023 21:22
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants