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

Create sandbox config maps in sandbox reconciler #790

Merged
merged 4 commits into from
May 6, 2024

Conversation

cchen-vertica
Copy link
Collaborator

This will create/update a sandbox config map whenever we create a new sandbox in sandbox reconciler. The config map is watched by sandbox controller for restarting/upgrading the nodes in a sandbox. The config map will be deleted if vdb is deleted or the sandbox is unsandboxed.

@cchen-vertica cchen-vertica requested a review from spilchen as a code owner May 2, 2024 13:16
@cchen-vertica cchen-vertica requested a review from roypaulin May 2, 2024 13:16
pkg/names/names.go Show resolved Hide resolved
Comment on lines 1311 to 1312
"verticaDBName": vdb.Spec.DBName,
"sandboxName": sandbox,
Copy link
Collaborator

Choose a reason for hiding this comment

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

We should sync with Roy's PR (#785). He added const values for these key names.

pkg/builder/builder.go Show resolved Hide resolved
if _, ok := seenScs[v.subclusterName]; ok {
continue
}
if v.sandbox != vapi.MainCluster {
Copy link
Collaborator

Choose a reason for hiding this comment

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

I expected there would be a change to podfacts.go. It looks like we set v.sandbox initially in collectPodByStsIndex and we get it from the requested sandbox we are requesting. That doesn't seem right. I feel like we should pull it from a label in the statefulset. The comment seems to indicate that, but I'm not sure if that's exactly what's going on.

This is the code I am talking about:

		// we get the sandbox name from the sts labels if the subcluster
		// belongs to a sandbox. If the node is up, we will later retrieve
		// the sandbox state from the catalog
		pf.sandbox = p.SandboxName

p.SandboxName is just an input parameter. I wonder if it should be sts.Labels[vmeta.SandboxNameLabel.

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

I will change it to sts.Labels[vmeta.SandboxNameLabel] since it probably causes an error when the node is down. That time we cannot update it to the correct sandbox name from checkNodeDetails. Then it could make the node restart fail.

}

// reconcile sandbox config maps for the existing sandboxes
if err := s.reconcileSandboxConfigMaps(ctx); err != nil {
Copy link
Collaborator

Choose a reason for hiding this comment

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

I wonder if there will be race conditions by creating the configMap before the actual sandbox command. Once the ConfigMap is created, the Sandbox reconciler can start to act on the pods. What is preventing them from attempting to restart the pods while we are in the middle of sandboxing them. I think this needs to happen after the sandbox command.

Copy link
Collaborator Author

@cchen-vertica cchen-vertica May 2, 2024

Choose a reason for hiding this comment

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

Here we just create config maps for the sandboxes that already have subclusters. This is for the case we sandbox a subcluster successfully but create a config map failed. Then the reconciler will fix the config map here. I have the code to create the configMap after the actual sandbox command as well.

Copy link
Collaborator

Choose a reason for hiding this comment

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

Ah ok, yes I see that. You can disregard this comment then.

// if so, we will update the content of that config map and return true
func (s *SandboxSubclusterReconciler) updateSandboxConfigMapFields(curCM, newCM *corev1.ConfigMap) bool {
updated := false
if stringMapDiffer(curCM.ObjectMeta.Annotations, newCM.ObjectMeta.Annotations) {
Copy link
Collaborator

Choose a reason for hiding this comment

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

Roy's PR (#785) is going to add an annotation that the vdb controller will use to wake up the sandbox controller. So, we may need to relax this. Or maybe compare everything except a specific annotation. fyi @roypaulin

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Will that annotation be modified by sandbox controller? In which case that annotation will be changed?

Copy link
Collaborator

Choose a reason for hiding this comment

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

The vdb controller will modify it to wake up the sandbox controller. It sets a new uuid anytime it needs the sandbox controller to do something. I don't think the sandbox controller will modify it at all.

@cchen-vertica cchen-vertica force-pushed the cchen/config-map-reconciler branch from 97c4f59 to 83aa394 Compare May 6, 2024 17:08
// exclude sandbox controller trigger ID from the annotations because
// vdb controller will set this in current config map, and the new
// config map cannot get it
triggerID, ok := curCM.Annotations[vmeta.SandboxControllerTriggerID]
Copy link
Collaborator

Choose a reason for hiding this comment

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

We should also exclude the version (vmeta.VersionAnnotation). That can be set in the ConfigMap too.

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Is the version value same as vdb's "vertica.com/version"? If so, the new config map will have the correct version annotation too, and we don't need to exclude the version.

Copy link
Collaborator

Choose a reason for hiding this comment

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

The values could differ. We will be able to upgrade the sandbox independently from the main cluster.

@cchen-vertica cchen-vertica merged commit f216467 into vnext May 6, 2024
31 checks passed
@cchen-vertica cchen-vertica deleted the cchen/config-map-reconciler branch May 6, 2024 22:53
cchen-vertica added a commit that referenced this pull request Jul 17, 2024
This will create/update a sandbox config map whenever we create a new
sandbox in sandbox reconciler. The config map is watched by sandbox
controller for restarting/upgrading the nodes in a sandbox. The config
map will be deleted if vdb is deleted or the sandbox is unsandboxed.
cchen-vertica added a commit that referenced this pull request Jul 17, 2024
This will create/update a sandbox config map whenever we create a new
sandbox in sandbox reconciler. The config map is watched by sandbox
controller for restarting/upgrading the nodes in a sandbox. The config
map will be deleted if vdb is deleted or the sandbox is unsandboxed.
cchen-vertica added a commit that referenced this pull request Jul 24, 2024
This will create/update a sandbox config map whenever we create a new
sandbox in sandbox reconciler. The config map is watched by sandbox
controller for restarting/upgrading the nodes in a sandbox. The config
map will be deleted if vdb is deleted or the sandbox is unsandboxed.
cchen-vertica added a commit that referenced this pull request Jul 24, 2024
This will create/update a sandbox config map whenever we create a new
sandbox in sandbox reconciler. The config map is watched by sandbox
controller for restarting/upgrading the nodes in a sandbox. The config
map will be deleted if vdb is deleted or the sandbox is unsandboxed.
cchen-vertica added a commit that referenced this pull request Jul 24, 2024
This will create/update a sandbox config map whenever we create a new
sandbox in sandbox reconciler. The config map is watched by sandbox
controller for restarting/upgrading the nodes in a sandbox. The config
map will be deleted if vdb is deleted or the sandbox is unsandboxed.
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.

2 participants