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: Watch configMap for deletion #12

Merged
merged 3 commits into from Apr 5, 2023
Merged

feat: Watch configMap for deletion #12

merged 3 commits into from Apr 5, 2023

Conversation

helayoty
Copy link
Contributor

@helayoty helayoty commented Apr 5, 2023

  • Set the patrol interval to ticker
  • Check for configMap deletion event

@helayoty helayoty requested a review from Fei-Guo as a code owner April 5, 2023 00:14
.github/workflows/e2e-test.yml Outdated Show resolved Hide resolved
}

retry.OnError(retry.DefaultBackoff, func(err error) bool {
return true
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Will returning true cause always retry?

Copy link
Contributor Author

@helayoty helayoty Apr 5, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes. No specific error. We want to retry for all errors.

pkg/exporter/exporter.go Outdated Show resolved Hide resolved
Signed-off-by: Heba Elayoty <hebaelayoty@gmail.com>
Signed-off-by: Heba Elayoty <hebaelayoty@gmail.com>
Signed-off-by: Heba Elayoty <hebaelayoty@gmail.com>
@helayoty
Copy link
Contributor Author

helayoty commented Apr 5, 2023

manual e2e run:

helm install carbon-e2e --set apiServer.image.repository=helayoty/server --set carbonDataExporter.image.repository=helayoty/exporter --set carbonDataExporter.patrolInterval=15s --set apiServer.username=XXXXXX--set apiServer.password=YYYYY ./charts/carbon-intensity-exporter
NAME: carbon-e2e
LAST DEPLOYED: Wed Apr  5 07:13:45 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      10s
+ kubectl describe configmap carbon-intensity -n kube-system
Name:         carbon-intensity
Namespace:    kube-system
Labels:       <none>
Annotations:  <none>

Data
====
message:
----

minForecast:
----
523.855390
numOfRecords:
----
288
forecastDateTime:
----
2023-04-05 14:15:00 +0000 UTC
lastHeartbeatTime:
----
2023-04-05 14:13:56.986976296 +0000 UTC m=+5.962670016
maxForecast:
----
578.662105

BinaryData
====
data: 29053 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      4s
+ kubectl describe configmap carbon-intensity -n kube-system
Name:         carbon-intensity
Namespace:    kube-system
Labels:       <none>
Annotations:  <none>

Data
====
forecastDateTime:
----
2023-04-05 14:15:00 +0000 UTC
lastHeartbeatTime:
----
2023-04-05 14:14:27.126788961 +0000 UTC m=+36.103318068
maxForecast:
----
578.662105
message:
----

minForecast:
----
523.855390
numOfRecords:
----
288

BinaryData
====
data: 29053 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-fgc7v
+ kubectl logs carbon-e2e-carbon-intensity-exporter-778578866d-fgc7v -c carbon-data-exporter -n kube-system
I0405 14:13:56.063652       1 options.go:108] Neither kubeconfig file nor control plane URL was specified. Falling back to in-cluster config.
I0405 14:13:56.064113       1 server.go:86] Inside server-> Run
I0405 14:13:56.064177       1 server.go:136] Inside server-> startExporter
I0405 14:13:56.064215       1 exporter.go:46] Inside exporter-> Run
I0405 14:13:56.064223       1 exporter.go:109] Inside exporter-> RefreshData
I0405 14:13:56.994834       1 configmap.go:69] configMap carbon-intensity has been created
I0405 14:14:11.997969       1 exporter.go:109] Inside exporter-> RefreshData
I0405 14:14:12.008032       1 configmap.go:103] configMap carbon-intensity has been deleted
I0405 14:14:12.147938       1 configmap.go:69] configMap carbon-intensity has been created
I0405 14:14:16.504308       1 exporter.go:109] Inside exporter-> RefreshData
I0405 14:14:16.658325       1 configmap.go:69] configMap carbon-intensity has been created
I0405 14:14:26.997542       1 exporter.go:109] Inside exporter-> RefreshData
I0405 14:14:27.008191       1 configmap.go:103] configMap carbon-intensity has been deleted
I0405 14:14:27.136142       1 configmap.go:69] configMap carbon-intensity has been created

@helayoty helayoty requested a review from Fei-Guo April 5, 2023 14:19
@Fei-Guo Fei-Guo merged commit 3e8dd74 into Azure:main Apr 5, 2023
2 checks passed
@helayoty helayoty deleted the watch-configmap branch April 5, 2023 16:01
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