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 sharedInformer for watch #15

Merged
merged 1 commit into from Apr 10, 2023
Merged

Conversation

helayoty
Copy link
Contributor

@helayoty helayoty commented Apr 8, 2023

Use SharedInformer and add a delete event instead of watch. This will keep the channel open.

@helayoty helayoty requested a review from Fei-Guo as a code owner April 8, 2023 00:49
@helayoty helayoty force-pushed the use-informer branch 5 times, most recently from a1280a3 to 1d6594f Compare April 10, 2023 13:51
@helayoty
Copy link
Contributor Author

manual e2e:

...
NAME: carbon-e2e
LAST DEPLOYED: Mon Apr 10 08:35:36 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
====
forecastDateTime:
----
2023-04-10 15:40:00 +0000 UTC
lastHeartbeatTime:
----
2023-04-10 15:35:45.209475964 +0000 UTC m=+5.899156339
maxForecast:
----
579.523333
message:
----

minForecast:
----
463.519714
numOfRecords:
----
288

BinaryData
====
data: 29048 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
====
message:
----

minForecast:
----
463.519714
numOfRecords:
----
288
forecastDateTime:
----
2023-04-10 15:40:00 +0000 UTC
lastHeartbeatTime:
----
2023-04-10 15:36:15.448189018 +0000 UTC m=+36.137659444
maxForecast:
----
579.523333

BinaryData
====
data: 29048 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-98tcx
+ kubectl logs carbon-e2e-carbon-intensity-exporter-778578866d-98tcx -c carbon-data-exporter -n kube-system
I0410 15:35:44.350814       1 options.go:108] Neither kubeconfig file nor control plane URL was specified. Falling back to in-cluster config.
I0410 15:35:45.215290       1 configmap.go:72] configMap carbon-intensity has been created
I0410 15:36:00.322859       1 configmap.go:94] configMap carbon-intensity has been deleted
I0410 15:36:00.467358       1 configmap.go:72] configMap carbon-intensity has been created
I0410 15:36:05.301274       1 configmap.go:72] configMap carbon-intensity has been created
I0410 15:36:15.328760       1 configmap.go:94] configMap carbon-intensity has been deleted
I0410 15:36:15.457186       1 configmap.go:72] configMap carbon-intensity has been created
+ cleanup
+ kind delete cluster -n carbon-e2e
Deleting cluster "carbon-e2e" ...
Deleted nodes: ["carbon-e2e-control-plane"]

pkg/exporter/exporter.go Outdated Show resolved Hide resolved
pkg/exporter/exporter.go Show resolved Hide resolved
Signed-off-by: Heba Elayoty <hebaelayoty@gmail.com>
@Fei-Guo Fei-Guo merged commit 5c35e36 into Azure:main Apr 10, 2023
2 checks passed
@helayoty helayoty deleted the use-informer branch April 10, 2023 16:09
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