fix(review) correct misleading comments, dead code, and error detection
- commit
- 9b07d6a82fd1e6432ff7f947c6d3b99eb322b805
- author
- bnema · · 2026-02-06 21:12 UTC
- parent
- 8ddd497
- signature
- GPG Verified
CD88F9E564E0102646FB6077A1A07C7C7C3E349D· arch-gpg Verified for the committer email
3 files · +8 -5
M internal/adapters/in/cli/remote/client.go +1 -1
| @@ -182,7 +182,7 @@ func retryDelay(attempt int) time.Duration { | |||
| 182 | 182 | } | |
| 183 | 183 | ||
| 184 | 184 | // requestWithRetry performs an HTTP request and retries transient failures. | |
| 185 | - | // Retries occur on transport errors and any 5xx response. | |
| 185 | + | // Retries occur on transport errors and gateway errors (502, 503, 504). | |
| 186 | 186 | func (c *Client) requestWithRetry(ctx context.Context, method, path string, body any) (*http.Response, error) { | |
| 187 | 187 | var lastErr error | |
| 188 | 188 | ||
| @@ -182,7 +182,7 @@ func retryDelay(attempt int) time.Duration { | |||||
| 182 | } | 182 | } | ||
| 183 | 183 | ||||
| 184 | // requestWithRetry performs an HTTP request and retries transient failures. | 184 | // requestWithRetry performs an HTTP request and retries transient failures. | ||
| 185 | - | // Retries occur on transport errors and any 5xx response. | 185 | + | // Retries occur on transport errors and gateway errors (502, 503, 504). |
| 186 | func (c *Client) requestWithRetry(ctx context.Context, method, path string, body any) (*http.Response, error) { | 186 | func (c *Client) requestWithRetry(ctx context.Context, method, path string, body any) (*http.Response, error) { | ||
| 187 | var lastErr error | 187 | var lastErr error | ||
| 188 | 188 | ||||
M internal/app/run.go +1 -1
| @@ -310,7 +310,7 @@ func createServices(ctx context.Context, v *viper.Viper, cfg Config, log zerowra | |||
| 310 | 310 | maxProxyBodySize = parsedSize | |
| 311 | 311 | } | |
| 312 | 312 | ||
| 313 | - | // Parse max_blob_chunk_size config (default: 512MB) | |
| 313 | + | // Parse max_blob_chunk_size config (default: 95MB) | |
| 314 | 314 | maxBlobChunkSize := int64(registry.DefaultMaxBlobChunkSize) | |
| 315 | 315 | if cfg.Server.MaxBlobChunkSize != "" { | |
| 316 | 316 | parsedSize, err := bytesize.Parse(cfg.Server.MaxBlobChunkSize) | |
| @@ -310,7 +310,7 @@ func createServices(ctx context.Context, v *viper.Viper, cfg Config, log zerowra | |||||
| 310 | maxProxyBodySize = parsedSize | 310 | maxProxyBodySize = parsedSize | ||
| 311 | } | 311 | } | ||
| 312 | 312 | ||||
| 313 | - | // Parse max_blob_chunk_size config (default: 512MB) | 313 | + | // Parse max_blob_chunk_size config (default: 95MB) |
| 314 | maxBlobChunkSize := int64(registry.DefaultMaxBlobChunkSize) | 314 | maxBlobChunkSize := int64(registry.DefaultMaxBlobChunkSize) | ||
| 315 | if cfg.Server.MaxBlobChunkSize != "" { | 315 | if cfg.Server.MaxBlobChunkSize != "" { | ||
| 316 | parsedSize, err := bytesize.Parse(cfg.Server.MaxBlobChunkSize) | 316 | parsedSize, err := bytesize.Parse(cfg.Server.MaxBlobChunkSize) | ||
M internal/usecase/container/service.go +6 -3
| @@ -3,6 +3,7 @@ package container | |||
| 3 | 3 | ||
| 4 | 4 | import ( | |
| 5 | 5 | "context" | |
| 6 | + | "errors" | |
| 6 | 7 | "fmt" | |
| 7 | 8 | "maps" | |
| 8 | 9 | "slices" | |
| @@ -1103,8 +1104,7 @@ func (s *Service) pullImageWithRetry(ctx context.Context, pullFn func(context.Co | |||
| 1103 | 1104 | return ctx.Err() | |
| 1104 | 1105 | } | |
| 1105 | 1106 | } | |
| 1106 | - | ||
| 1107 | - | return fmt.Errorf("internal image pull failed after %d attempts", internalPullMaxAttempts) | |
| 1107 | + | return nil | |
| 1108 | 1108 | } | |
| 1109 | 1109 | ||
| 1110 | 1110 | func (s *Service) tagImageIfNeeded(ctx context.Context, sourceRef, targetRef string) error { | |
| @@ -1731,6 +1731,9 @@ func isContainerNotFoundError(err error) bool { | |||
| 1731 | 1731 | if err == nil { | |
| 1732 | 1732 | return false | |
| 1733 | 1733 | } | |
| 1734 | + | if errors.Is(err, domain.ErrContainerNotFound) { | |
| 1735 | + | return true | |
| 1736 | + | } | |
| 1734 | 1737 | msg := strings.ToLower(err.Error()) | |
| 1735 | 1738 | return strings.Contains(msg, "no such container") || | |
| 1736 | 1739 | strings.Contains(msg, "no container with name or id") || | |
| @@ -1815,7 +1818,7 @@ func (s *Service) pollContainerRunning(ctx context.Context, containerID string) | |||
| 1815 | 1818 | return ctx.Err() | |
| 1816 | 1819 | } | |
| 1817 | 1820 | } | |
| 1818 | - | return nil | |
| 1821 | + | return fmt.Errorf("container did not start within 30 seconds") | |
| 1819 | 1822 | } | |
| 1820 | 1823 | ||
| 1821 | 1824 | // waitForRecovery waits for a container to recover within the recovery window. | |
| @@ -3,6 +3,7 @@ package container | |||||
| 3 | 3 | ||||
| 4 | import ( | 4 | import ( | ||
| 5 | "context" | 5 | "context" | ||
| 6 | + | "errors" | |||
| 6 | "fmt" | 7 | "fmt" | ||
| 7 | "maps" | 8 | "maps" | ||
| 8 | "slices" | 9 | "slices" | ||
| @@ -1103,8 +1104,7 @@ func (s *Service) pullImageWithRetry(ctx context.Context, pullFn func(context.Co | |||||
| 1103 | return ctx.Err() | 1104 | return ctx.Err() | ||
| 1104 | } | 1105 | } | ||
| 1105 | } | 1106 | } | ||
| 1106 | - | 1107 | + | return nil | |
| 1107 | - | return fmt.Errorf("internal image pull failed after %d attempts", internalPullMaxAttempts) | |||
| 1108 | } | 1108 | } | ||
| 1109 | 1109 | ||||
| 1110 | func (s *Service) tagImageIfNeeded(ctx context.Context, sourceRef, targetRef string) error { | 1110 | func (s *Service) tagImageIfNeeded(ctx context.Context, sourceRef, targetRef string) error { | ||
| @@ -1731,6 +1731,9 @@ func isContainerNotFoundError(err error) bool { | |||||
| 1731 | if err == nil { | 1731 | if err == nil { | ||
| 1732 | return false | 1732 | return false | ||
| 1733 | } | 1733 | } | ||
| 1734 | + | if errors.Is(err, domain.ErrContainerNotFound) { | |||
| 1735 | + | return true | |||
| 1736 | + | } | |||
| 1734 | msg := strings.ToLower(err.Error()) | 1737 | msg := strings.ToLower(err.Error()) | ||
| 1735 | return strings.Contains(msg, "no such container") || | 1738 | return strings.Contains(msg, "no such container") || | ||
| 1736 | strings.Contains(msg, "no container with name or id") || | 1739 | strings.Contains(msg, "no container with name or id") || | ||
| @@ -1815,7 +1818,7 @@ func (s *Service) pollContainerRunning(ctx context.Context, containerID string) | |||||
| 1815 | return ctx.Err() | 1818 | return ctx.Err() | ||
| 1816 | } | 1819 | } | ||
| 1817 | } | 1820 | } | ||
| 1818 | - | return nil | 1821 | + | return fmt.Errorf("container did not start within 30 seconds") |
| 1819 | } | 1822 | } | ||
| 1820 | 1823 | ||||
| 1821 | // waitForRecovery waits for a container to recover within the recovery window. | 1824 | // waitForRecovery waits for a container to recover within the recovery window. | ||