@@ -23,6 +23,7 @@ import (
2323 "path/filepath"
2424 "strings"
2525
26+ "github.com/Masterminds/semver/v3"
2627 "github.com/google/go-cmp/cmp"
2728 native_errors "github.com/haproxytech/client-native/v5/errors"
2829 "github.com/haproxytech/client-native/v5/misc"
@@ -158,7 +159,12 @@ func (c *client) Reload() (string, error) {
158159 if c .options .MasterSocketData == nil {
159160 return "" , fmt .Errorf ("cannot reload: not connected to a master socket" )
160161 }
161- if ! c .IsVersionBiggerOrEqual (& HAProxyVersion {Major : 2 , Minor : 7 }) {
162+ // Init-time version probe is fire-and-forget; retry here so a transient
163+ // startup failure doesn't permanently disable the gate.
164+ if haproxyVersion == nil {
165+ _ , _ = c .GetVersion ()
166+ }
167+ if ! c .IsVersionBiggerOrEqual (& HAProxyVersion {Version : semver .MustParse ("2.7" )}) {
162168 return "" , fmt .Errorf ("cannot reload: requires HAProxy 2.7 or later but current version is %v" , haproxyVersion )
163169 }
164170
@@ -237,7 +243,7 @@ func (c *client) AddServer(backend, name, attributes string) error {
237243 if len (c .runtimes ) == 0 {
238244 return fmt .Errorf ("no valid runtimes found" )
239245 }
240- if ! c .IsVersionBiggerOrEqual (& HAProxyVersion {Major : 2 , Minor : 6 }) {
246+ if ! c .IsVersionBiggerOrEqual (& HAProxyVersion {Version : semver . MustParse ( "2.6" ) }) {
241247 return fmt .Errorf ("this operation requires HAProxy 2.6 or later but current version is %v" , haproxyVersion )
242248 }
243249 for _ , runtime := range c .runtimes {
@@ -254,8 +260,8 @@ func (c *client) DeleteServer(backend, name string) error {
254260 if len (c .runtimes ) == 0 {
255261 return fmt .Errorf ("no valid runtimes found" )
256262 }
257- if ! c .IsVersionBiggerOrEqual (& HAProxyVersion {Major : 2 , Minor : 6 }) {
258- return fmt . Errorf ("this operation requires HAProxy 2.6 or later" )
263+ if ! c .IsVersionBiggerOrEqual (& HAProxyVersion {Version : semver . MustParse ( "2.6" ) }) {
264+ return errors . New ("this operation requires HAProxy 2.6 or later" )
259265 }
260266 for _ , runtime := range c .runtimes {
261267 err := runtime .DeleteServer (backend , name )
@@ -839,7 +845,7 @@ func (c *client) AddMapPayloadVersioned(name string, entries models.MapEntries)
839845 return err
840846 }
841847 canAtomicUpdate := false
842- v := HAProxyVersion {Major : 2 , Minor : 4 }
848+ v := HAProxyVersion {Version : semver . MustParse ( "2.4" ) }
843849 if c .IsVersionBiggerOrEqual (& v ) {
844850 canAtomicUpdate = true
845851 }
@@ -1142,7 +1148,7 @@ func (c *client) AddACLAtomic(aclID string, entries models.ACLFilesEntries) erro
11421148 if len (c .runtimes ) == 0 {
11431149 return fmt .Errorf ("no valid runtimes found" )
11441150 }
1145- v := HAProxyVersion {Major : 2 , Minor : 4 }
1151+ v := HAProxyVersion {Version : semver . MustParse ( "2.4" ) }
11461152 if ! c .IsVersionBiggerOrEqual (& v ) {
11471153 return fmt .Errorf ("not supported for HAProxy versions lower than 2.4 %w" , native_errors .ErrGeneral )
11481154 }
0 commit comments