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

[discussion] get latest vpc data from k8s api instead of cache #1683

Closed
chestack opened this issue Jul 12, 2022 · 0 comments · Fixed by #1684
Closed

[discussion] get latest vpc data from k8s api instead of cache #1683

chestack opened this issue Jul 12, 2022 · 0 comments · Fixed by #1684

Comments

@chestack
Copy link
Contributor

chestack commented Jul 12, 2022

In InitDefaultVpc(), default vpc was created and then updated with vpc.Status.Default = true

func (c *Controller) InitDefaultVpc() error {
		orivpc = &kubeovnv1.Vpc{}
	        orivpc.Name = util.DefaultVpc
                orivpc, err = c.config.KubeOvnClient.KubeovnV1().Vpcs().Create(context.Background(), orivpc, metav1.CreateOptions{})
        ...
        vpc.Status.Standby = true
        vpc.Status.Default = true
	_, err = c.config.KubeOvnClient.KubeovnV1().Vpcs().Patch(context.Background(), vpc.Name, types.MergePatchType, bytes, metav1.PatchOptions{}, "status")
}

Found that the following code returned the default vpc data with vpc.Status.Default = false occasionally.

func (c *Controller) handleAddOrUpdateVpc(key string) error {
      orivpc, err := c.vpcsLister.Get(key)

Maybe the reason is orivpc, err := c.vpcsLister.Get(key) get vpc from local informer cache but not k8s-api so it's possible get stale vpc info.

@chestack chestack changed the title [discussion] InitDefaultVpc, it's better to set 'vpc.Status.Default = true' during create instead of patch [discussion] get latest vpc data from k8s api instead of cache Jul 14, 2022
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 a pull request may close this issue.

1 participant