@@ -145,7 +145,7 @@ func (ci *ConsulInstaller) Install() error {
145145 }()
146146
147147 // Phase 1: ASSESS - Check if already installed
148- ci .progress .Update ("[16%] Checking current Consul status " )
148+ ci .progress .Update ("[16%] Checking if Consul is already installed and running... " )
149149 shouldInstall , err := ci .assess ()
150150 if err != nil {
151151 return fmt .Errorf ("assessment failed: %w" , err )
@@ -160,34 +160,38 @@ func (ci *ConsulInstaller) Install() error {
160160 }
161161
162162 // Phase 2: Prerequisites
163- ci .progress .Update ("[33%] Validating prerequisites " )
163+ ci .progress .Update ("[33%] Checking system requirements (memory, disk, ports)... " )
164164 if err := ci .validatePrerequisites (); err != nil {
165165 return fmt .Errorf ("prerequisite validation failed: %w" , err )
166166 }
167167
168168 // Phase 3: INTERVENE - Install
169- ci .progress .Update ("[50%] Installing Consul binary" )
169+ if ci .config .UseRepository {
170+ ci .progress .Update ("[50%] Downloading and installing Consul from HashiCorp repository..." )
171+ } else {
172+ ci .progress .Update ("[50%] Downloading and installing Consul binary..." )
173+ }
170174 if err := ci .installBinary (); err != nil {
171175 return fmt .Errorf ("binary installation failed: %w" , err )
172176 }
173177 binaryInstalled = true
174178
175179 // Phase 4: Configure
176- ci .progress .Update ("[66%] Configuring Consul" )
180+ ci .progress .Update ("[66%] Generating and validating Consul configuration files... " )
177181 if err := ci .configure (); err != nil {
178182 return fmt .Errorf ("configuration failed: %w" , err )
179183 }
180184 configCreated = true
181185
182186 // Phase 5: Setup Service
183- ci .progress .Update ("[83%] Setting up systemd service" )
187+ ci .progress .Update ("[83%] Creating systemd service and starting Consul... " )
184188 if err := ci .setupService (); err != nil {
185189 return fmt .Errorf ("service setup failed: %w" , err )
186190 }
187191 serviceCreated = true
188192
189193 // Phase 6: EVALUATE - Verify
190- ci .progress .Update ("[100%] Verifying installation " )
194+ ci .progress .Update ("[100%] Waiting for Consul API to become ready... " )
191195 if err := ci .verify (); err != nil {
192196 return fmt .Errorf ("verification failed: %w" , err )
193197 }
@@ -243,10 +247,17 @@ func (ci *ConsulInstaller) rollbackPartialInstall(binaryInstalled, configCreated
243247 zap .Error (err ),
244248 zap .String ("output" , output ))
245249 } else {
246- // CRITICAL: daemon-reload is async - systemd scans /etc/systemd/system/
247- // If we immediately delete files, systemd might see partial state
250+ // CRITICAL: daemon-reload is async - poll systemd state instead of sleep
248251 ci .logger .Debug ("Waiting for daemon-reload to complete" )
249- time .Sleep (500 * time .Millisecond )
252+ deadline := time .Now ().Add (2 * time .Second )
253+ for time .Now ().Before (deadline ) {
254+ // Check if systemd has processed the reload by querying unit state
255+ if _ , err := exec .Command ("systemctl" , "show" , "-p" , "LoadState" , "consul" ).Output (); err == nil {
256+ // If we can query the unit state, daemon-reload has processed
257+ break
258+ }
259+ time .Sleep (100 * time .Millisecond )
260+ }
250261 }
251262 }
252263
@@ -897,9 +908,10 @@ func (ci *ConsulInstaller) setupService() error {
897908
898909 // Log progress every few attempts so user knows we're still checking
899910 if attempt % 3 == 0 {
900- ci .logger .Info ("Still waiting for Consul to be ready " ,
911+ ci .logger .Info ("Waiting for Consul HTTP API to respond... " ,
901912 zap .Int ("attempt" , attempt ),
902- zap .Int ("max_attempts" , 15 ))
913+ zap .Int ("max_attempts" , 15 ),
914+ zap .String ("checking" , fmt .Sprintf ("http://127.0.0.1:%d/v1/agent/self" , shared .PortConsul )))
903915 }
904916 }
905917 }
0 commit comments