@@ -24,6 +24,7 @@ import (
2424 "path/filepath"
2525 "strings"
2626
27+ "github.com/Masterminds/semver/v3"
2728 native_errors "github.com/haproxytech/client-native/v6/errors"
2829 "github.com/haproxytech/client-native/v6/misc"
2930 "github.com/haproxytech/client-native/v6/models"
@@ -163,7 +164,12 @@ func (c *client) Reload() (string, error) {
163164 if c .options .MasterSocketData == nil {
164165 return "" , errors .New ("cannot reload: not connected to a master socket" )
165166 }
166- if ! c .IsVersionBiggerOrEqual (& HAProxyVersion {Major : 2 , Minor : 7 }) {
167+ // Init-time version probe is fire-and-forget; retry here so a transient
168+ // startup failure doesn't permanently disable the gate.
169+ if haproxyVersion == nil {
170+ _ , _ = c .GetVersion ()
171+ }
172+ if ! c .IsVersionBiggerOrEqual (& HAProxyVersion {Version : semver .MustParse ("2.7" )}) {
167173 return "" , fmt .Errorf ("cannot reload: requires HAProxy 2.7 or later but current version is %v" , haproxyVersion )
168174 }
169175
@@ -242,7 +248,7 @@ func (c *client) AddServer(backend, name, attributes string) error {
242248 if ! c .runtime .IsValid () {
243249 return errors .New ("no valid runtime found" )
244250 }
245- if ! c .IsVersionBiggerOrEqual (& HAProxyVersion {Major : 2 , Minor : 6 }) {
251+ if ! c .IsVersionBiggerOrEqual (& HAProxyVersion {Version : semver . MustParse ( "2.6" ) }) {
246252 return fmt .Errorf ("this operation requires HAProxy 2.6 or later but current version is %v" , haproxyVersion )
247253 }
248254 err := c .runtime .AddServer (backend , name , attributes )
@@ -257,7 +263,7 @@ func (c *client) DeleteServer(backend, name string) error {
257263 if ! c .runtime .IsValid () {
258264 return errors .New ("no valid runtime found" )
259265 }
260- if ! c .IsVersionBiggerOrEqual (& HAProxyVersion {Major : 2 , Minor : 6 }) {
266+ if ! c .IsVersionBiggerOrEqual (& HAProxyVersion {Version : semver . MustParse ( "2.6" ) }) {
261267 return errors .New ("this operation requires HAProxy 2.6 or later" )
262268 }
263269 err := c .runtime .DeleteServer (backend , name )
@@ -711,7 +717,7 @@ func (c *client) AddMapPayloadVersioned(name string, entries models.MapEntries)
711717 return fmt .Errorf ("%s %w" , c .runtime .socketPath , err )
712718 }
713719 canAtomicUpdate := false
714- v := HAProxyVersion {Major : 2 , Minor : 4 }
720+ v := HAProxyVersion {Version : semver . MustParse ( "2.4" ) }
715721 if c .IsVersionBiggerOrEqual (& v ) {
716722 canAtomicUpdate = true
717723 }
@@ -953,7 +959,7 @@ func (c *client) AddACLAtomic(aclID string, entries models.ACLFilesEntries) erro
953959 if ! c .runtime .IsValid () {
954960 return errors .New ("no valid runtime found" )
955961 }
956- v := HAProxyVersion {Major : 2 , Minor : 4 }
962+ v := HAProxyVersion {Version : semver . MustParse ( "2.4" ) }
957963 if ! c .IsVersionBiggerOrEqual (& v ) {
958964 return fmt .Errorf ("not supported for HAProxy versions lower than 2.4 %w" , native_errors .ErrGeneral )
959965 }
0 commit comments