Skip to content

feat: add smbw support#2104

Merged
graphite-app[bot] merged 1 commit intomainfrom
01-21-feat_add_smbw_support
Mar 25, 2026
Merged

feat: add smbw support#2104
graphite-app[bot] merged 1 commit intomainfrom
01-21-feat_add_smbw_support

Conversation

@assafgi
Copy link
Contributor

@assafgi assafgi commented Jan 22, 2026

No description provided.

@assafgi assafgi marked this pull request as ready for review January 22, 2026 07:00
Copy link
Contributor Author

assafgi commented Jan 22, 2026


How to use the Graphite Merge Queue

Add the label main-merge-queue to this PR to add it to the merge queue.

You must have a Graphite account in order to use the merge queue. Sign up using this link.

An organization admin has required the Graphite Merge Queue in this repository.

Please do not merge from GitHub as this will restart CI on PRs being processed by the merge queue.

This stack of pull requests is managed by Graphite. Learn more about stacking.

@graphite-app
Copy link

graphite-app bot commented Jan 22, 2026

Graphite Automations

"Add anton/matt/sergey/kristina as reviwers on operator PRs" took an action on this PR • (01/22/26)

2 reviewers were added to this PR based on Anton Bykov's automation.

@assafgi assafgi force-pushed the 01-21-feat_add_smbw_support branch from 6660290 to 295e9ec Compare January 22, 2026 08:07
Comment on lines +40 to +49
smbwCluster, err := wekaService.GetSmbwCluster(ctx)
if err != nil {
err = errors.Wrap(err, "Failed to get SMB-W cluster")
return err
}

if smbwCluster.Active {
logger.Info("SMB-W cluster already exists")
return nil
}
Copy link
Collaborator

Choose a reason for hiding this comment

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

it looks like EnsureSmbwCluster expects smbw cluster to be already created and will otherwise

Comment on lines +263 to +265
func contains(s, substr string) bool {
return len(s) >= len(substr) && (s == substr || len(s) > 0 && containsIgnoreCase(s, substr))
}
Copy link
Collaborator

Choose a reason for hiding this comment

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

ah, it's for containsIgnoreCase
then maybe would be good to remove this "contains" func and only keep "containsIgnoreCase"

@assafgi assafgi force-pushed the 01-21-feat_add_smbw_support branch from 295e9ec to 5516b89 Compare January 22, 2026 10:54
@assafgi assafgi requested a review from a team as a code owner January 28, 2026 18:09
@assafgi assafgi force-pushed the 01-21-feat_add_smbw_support branch 13 times, most recently from dd13517 to 607f4de Compare February 11, 2026 11:32
@assafgi assafgi force-pushed the 01-21-feat_add_smbw_support branch 5 times, most recently from 3ecc1ad to ff27dc2 Compare February 16, 2026 13:59
@assafgi assafgi force-pushed the 01-21-feat_add_smbw_support branch from ff27dc2 to 4b43eff Compare February 24, 2026 10:41
Copilot AI review requested due to automatic review settings March 5, 2026 09:15
Copy link

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull request overview

Copilot reviewed 19 out of 19 changed files in this pull request and generated 2 comments.


💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment on lines +510 to +516
shmSizeLimit := resource.MustParse(config.Config.Smbw.ShmSize)
vols = append(vols, corev1.Volume{
Name: "smbw-shm",
VolumeSource: corev1.VolumeSource{
EmptyDir: &corev1.EmptyDirVolumeSource{
Medium: corev1.StorageMediumMemory,
SizeLimit: &shmSizeLimit,
Copy link

Copilot AI Mar 24, 2026

Choose a reason for hiding this comment

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

resource.MustParse(config.Config.Smbw.ShmSize) will panic if the SMBW_SHM_SIZE env/Helm value is invalid, potentially crashing the operator. Prefer resource.ParseQuantity (or validation during env config) and return/log a clear error instead of panicking.

Suggested change
shmSizeLimit := resource.MustParse(config.Config.Smbw.ShmSize)
vols = append(vols, corev1.Volume{
Name: "smbw-shm",
VolumeSource: corev1.VolumeSource{
EmptyDir: &corev1.EmptyDirVolumeSource{
Medium: corev1.StorageMediumMemory,
SizeLimit: &shmSizeLimit,
var shmSizeLimit *resource.Quantity
if q, err := resource.ParseQuantity(config.Config.Smbw.ShmSize); err != nil {
fmt.Printf("invalid SMBW_SHM_SIZE value %q, using unlimited shm size: %v\n", config.Config.Smbw.ShmSize, err)
} else {
shmSizeLimit = &q
}
vols = append(vols, corev1.Volume{
Name: "smbw-shm",
VolumeSource: corev1.VolumeSource{
EmptyDir: &corev1.EmptyDirVolumeSource{
Medium: corev1.StorageMediumMemory,
SizeLimit: shmSizeLimit,

Copilot uses AI. Check for mistakes.
Comment on lines +574 to +576
if prepareForUpgrade {
err := r.prepareForUpgradeS3(ctx, smbwContainers, targetVersion)
if err != nil {
Copy link

Copilot AI Mar 24, 2026

Choose a reason for hiding this comment

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

prepareForUpgradeS3 is now used for SMB-W containers as well. Even if the underlying logic is valid (it appears to prepare the “frontend” upgrade phase), the name is misleading and makes the SMB-W upgrade path harder to understand. Consider renaming to something frontend-generic or adding a dedicated wrapper for SMB-W that calls the shared helper.

Copilot uses AI. Check for mistakes.
@assafgi assafgi force-pushed the 01-21-feat_add_smbw_support branch from e9a70f7 to f4fc165 Compare March 24, 2026 10:38
Copilot AI review requested due to automatic review settings March 24, 2026 10:40
@assafgi assafgi force-pushed the 01-21-feat_add_smbw_support branch from f4fc165 to c268bd8 Compare March 24, 2026 10:40
Copy link

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull request overview

Copilot reviewed 19 out of 19 changed files in this pull request and generated no new comments.


💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

@assafgi assafgi force-pushed the 01-21-feat_add_smbw_support branch from c268bd8 to f7f59e1 Compare March 24, 2026 10:47
Copilot AI review requested due to automatic review settings March 24, 2026 12:53
@assafgi assafgi force-pushed the 01-21-feat_add_smbw_support branch from f7f59e1 to 1aeefab Compare March 24, 2026 12:53
Copy link

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull request overview

Copilot reviewed 19 out of 19 changed files in this pull request and generated no new comments.


💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

@assafgi assafgi force-pushed the 01-21-feat_add_smbw_support branch from 1aeefab to c6d9a0b Compare March 24, 2026 15:40
Copilot AI review requested due to automatic review settings March 24, 2026 15:47
@assafgi assafgi force-pushed the 01-21-feat_add_smbw_support branch from c6d9a0b to 84ce4d9 Compare March 24, 2026 15:47
Copy link

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull request overview

Copilot reviewed 19 out of 19 changed files in this pull request and generated no new comments.


💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

@assafgi assafgi force-pushed the 01-21-feat_add_smbw_support branch from 84ce4d9 to 021caef Compare March 24, 2026 19:53
Copilot AI review requested due to automatic review settings March 25, 2026 07:40
@assafgi assafgi force-pushed the 01-21-feat_add_smbw_support branch from 021caef to d310f51 Compare March 25, 2026 07:40
Copy link

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull request overview

Copilot reviewed 19 out of 19 changed files in this pull request and generated 4 comments.


💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment on lines +245 to +248
cmd := fmt.Sprintf("weka smb domain join %s %s", username, password)
_, stderr, err := executor.ExecSensitive(ctx, "JoinSmbwDomain", []string{"bash", "-ce", cmd})
if err != nil {
stderrStr := stderr.String()
Copy link

Copilot AI Mar 25, 2026

Choose a reason for hiding this comment

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

The domain-join command is built via string interpolation and executed through bash -ce, which allows shell injection if the username/password contain shell metacharacters (and will also break on spaces). Prefer calling the executable directly with an argv slice (e.g., []string{"weka", "smb", "domain", "join", username, password}) so inputs are not interpreted by a shell.

Suggested change
cmd := fmt.Sprintf("weka smb domain join %s %s", username, password)
_, stderr, err := executor.ExecSensitive(ctx, "JoinSmbwDomain", []string{"bash", "-ce", cmd})
if err != nil {
stderrStr := stderr.String()
_, stderr, err := executor.ExecSensitive(ctx, "JoinSmbwDomain", []string{"weka", "smb", "domain", "join", username, password})
if err != nil {
stderrStr := stderr.String()
stderrStr := stderr.String()

Copilot uses AI. Check for mistakes.
Comment on lines +54 to +68
smbwContainers := r.SelectSmbwContainers(r.containers)
containerIds := []int{}
for _, c := range smbwContainers {
if len(containerIds) == config.Consts.FormSmbwClusterMaxContainerCount {
logger.Debug("Max SMB-W containers reached for initial SMB-W cluster creation", "maxContainers", config.Consts.FormSmbwClusterMaxContainerCount)
break
}

if c.Status.ClusterContainerID == nil {
msg := fmt.Sprintf("SMB-W container %s does not have a cluster container id", c.Name)
logger.Debug(msg)
continue
}
containerIds = append(containerIds, *c.Status.ClusterContainerID)
}
Copy link

Copilot AI Mar 25, 2026

Choose a reason for hiding this comment

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

SMB-W cluster creation selects all SMB-W containers from r.containers without filtering for running/ready state. This can include terminating/not-yet-running containers and lead to using stale ClusterContainerIDs or waiting indefinitely. Consider mirroring the S3 logic (discovery.SelectRunningContainersByRole or equivalent) so only running SMB-W containers with valid IDs are considered for initial cluster formation.

Copilot uses AI. Check for mistakes.
Comment on lines +163 to +170
&lifecycle.SimpleStep{
Predicates: lifecycle.Predicates{
loop.HasSmbwContainers,
},
State: &lifecycle.State{
Name: condition.CondSmbwClusterCreated,
},
Run: loop.EnsureSmbwCluster,
Copy link

Copilot AI Mar 25, 2026

Choose a reason for hiding this comment

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

These SMB-W post-cluster steps are gated by HasSmbwContainers, which (as currently implemented) counts all SMB-W CRs, not just running/ready ones. This differs from the S3/NFS gating (HasRunning...Containers) and can cause repeated waits or re-creation attempts during scale-down/deletion. Consider gating on running SMB-W containers (or adding a HasRunningSmbwContainers predicate) to match the established pattern.

Copilot uses AI. Check for mistakes.
}
}
if prepareForUpgrade {
err := r.prepareForUpgradeS3(ctx, smbwContainers, targetVersion)
Copy link

Copilot AI Mar 25, 2026

Choose a reason for hiding this comment

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

This upgrade path reuses prepareForUpgradeS3 for SMB-W containers. That helper logs/labels itself as S3 and hardcodes the "frontend" upgrade phase; if SMB-W uses a distinct upgrade phase or you rely on logs/metrics for debugging, this will be misleading or incorrect. Consider introducing a generic prepareForUpgradeFrontend helper (or a dedicated SMB-W variant) and using the correct naming/phase.

Suggested change
err := r.prepareForUpgradeS3(ctx, smbwContainers, targetVersion)
err := r.prepareForUpgradeFrontend(ctx, smbwContainers, targetVersion)

Copilot uses AI. Check for mistakes.
Copilot AI review requested due to automatic review settings March 25, 2026 12:45
@assafgi assafgi force-pushed the 01-21-feat_add_smbw_support branch from 0235f70 to e1ff068 Compare March 25, 2026 12:45
Copy link

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull request overview

Copilot reviewed 19 out of 19 changed files in this pull request and generated 1 comment.


💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Drive: config.DriveContainers,
S3: config.S3Containers,
Nfs: config.NfsContainers,
Smbw: config.SmbwContainers,
Copy link

Copilot AI Mar 25, 2026

Choose a reason for hiding this comment

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

There is inconsistent indentation/alignment in this struct literal (e.g., tabs/spaces around the Smbw field). Please run gofmt on the file to keep formatting consistent and avoid noisy diffs later.

Suggested change
Smbw: config.SmbwContainers,
Smbw: config.SmbwContainers,

Copilot uses AI. Check for mistakes.
@graphite-app
Copy link

graphite-app bot commented Mar 25, 2026

Merge activity

  • Mar 25, 1:38 PM UTC: assafgi added this pull request to the Graphite merge queue.
  • Mar 25, 1:39 PM UTC: CI is running for this pull request on a draft pull request (#2396) due to your merge queue CI optimization settings.
  • Mar 25, 5:10 PM UTC: Merged by the Graphite merge queue via draft PR: #2396.

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.

3 participants