Skip to content

[codex] fix samba share persistence on failed runs#161

Draft
damacus wants to merge 1 commit intomainfrom
codex/fix-samba-share-persistence
Draft

[codex] fix samba share persistence on failed runs#161
damacus wants to merge 1 commit intomainfrom
codex/fix-samba-share-persistence

Conversation

@damacus
Copy link
Copy Markdown
Member

@damacus damacus commented Apr 14, 2026

Summary

  • make samba_server build the share data for smb.conf from the compiled resource collection instead of depending on later samba_share convergence to mutate the template
  • remove the samba_share code path that edits the server template in place during its action
  • add a regression spec covering a separately declared samba_share so the rendered config still includes the share block

Why

Issue #96 describes a failure mode where an unrelated resource fails later in the Chef run after samba_server has already queued the delayed smb.conf write. In the old implementation, shares were only attached to the template when each samba_share actually converged, so a failed run could still flush a config file with no share definitions and interrupt service.

Impact

  • declared shares remain present in the generated Samba config even when a later unrelated resource fails
  • samba_share no longer needs to reach back into the server template to inject variables during converge
  • the regression is covered at the ChefSpec layer

Root cause

The delayed template write in samba_server used template variables that were populated by samba_share actions. If the Chef run aborted before those actions converged, the delayed template still executed with an empty shares hash.

Validation

  • cookstyle resources/server.rb resources/share.rb spec/resources/server_spec.rb
  • ruby -c resources/server.rb
  • ruby -c resources/share.rb
  • chef exec rspec spec/resources/server_spec.rb currently fails in this environment because the local Chef Ruby cannot load the native json extension (parser.bundle code-signing / Team ID mismatch on macOS)

Closes #96.


This change is Reviewable

@github-actions
Copy link
Copy Markdown

😰 RSpec failure

3 examples, 1 failure
Example Description Message
spec/resources/server_spec.rb:35 samba_server when shares are declared separately renders the share into smb.conf expected Chef run to render "/etc/samba/smb.conf" matching: browseable = no but got: # This is the main Samba configuration file. # # It was dynamically generated by Chef on fauxhai.local # # Local...

@github-actions
Copy link
Copy Markdown

Slowest examples

Top 3 slowest examples (0.15 seconds, 100% of total time)
Example Description Time in seconds
spec/resources/server_spec.rb:18 samba_server create action is expected to install package "samba" 0.06562
spec/resources/server_spec.rb:35 samba_server when shares are declared separately renders the share into smb.conf 0.05956
spec/resources/server_spec.rb:19 samba_server create action is expected to create template "/etc/samba/smb.conf" 0.03417

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.

Samba shares nuked when unrelated resource fails during chef-client run

1 participant