@@ -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"
@@ -173,7 +174,12 @@ func (c *client) Reload() (string, error) {
173174 if c .options .MasterSocketData == nil {
174175 return "" , errors .New ("cannot reload: not connected to a master socket" )
175176 }
176- if ! c .IsVersionBiggerOrEqual (& HAProxyVersion {Major : 2 , Minor : 7 }) {
177+ // Init-time version probe is fire-and-forget; retry here so a transient
178+ // startup failure doesn't permanently disable the gate.
179+ if haproxyVersion == nil {
180+ _ , _ = c .GetVersion ()
181+ }
182+ if ! c .IsVersionBiggerOrEqual (& HAProxyVersion {Version : semver .MustParse ("2.7" )}) {
177183 return "" , fmt .Errorf ("cannot reload: requires HAProxy 2.7 or later but current version is %v" , haproxyVersion )
178184 }
179185
@@ -252,7 +258,7 @@ func (c *client) AddServer(backend, name, attributes string) error {
252258 if ! c .runtime .IsValid () {
253259 return errors .New ("no valid runtime found" )
254260 }
255- if ! c .IsVersionBiggerOrEqual (& HAProxyVersion {Major : 2 , Minor : 6 }) {
261+ if ! c .IsVersionBiggerOrEqual (& HAProxyVersion {Version : semver . MustParse ( "2.6" ) }) {
256262 return fmt .Errorf ("this operation requires HAProxy 2.6 or later but current version is %v" , haproxyVersion )
257263 }
258264 err := c .runtime .AddServer (backend , name , attributes )
@@ -267,7 +273,7 @@ func (c *client) DeleteServer(backend, name string) error {
267273 if ! c .runtime .IsValid () {
268274 return errors .New ("no valid runtime found" )
269275 }
270- if ! c .IsVersionBiggerOrEqual (& HAProxyVersion {Major : 2 , Minor : 6 }) {
276+ if ! c .IsVersionBiggerOrEqual (& HAProxyVersion {Version : semver . MustParse ( "2.6" ) }) {
271277 return errors .New ("this operation requires HAProxy 2.6 or later" )
272278 }
273279 err := c .runtime .DeleteServer (backend , name )
@@ -734,7 +740,7 @@ func (c *client) AddMapPayloadVersioned(name string, entries models.MapEntries)
734740 return fmt .Errorf ("%s %w" , c .runtime .socketPath , err )
735741 }
736742 canAtomicUpdate := false
737- v := HAProxyVersion {Major : 2 , Minor : 4 }
743+ v := HAProxyVersion {Version : semver . MustParse ( "2.4" ) }
738744 if c .IsVersionBiggerOrEqual (& v ) {
739745 canAtomicUpdate = true
740746 }
@@ -976,7 +982,7 @@ func (c *client) AddACLAtomic(aclID string, entries models.ACLFilesEntries) erro
976982 if ! c .runtime .IsValid () {
977983 return errors .New ("no valid runtime found" )
978984 }
979- v := HAProxyVersion {Major : 2 , Minor : 4 }
985+ v := HAProxyVersion {Version : semver . MustParse ( "2.4" ) }
980986 if ! c .IsVersionBiggerOrEqual (& v ) {
981987 return fmt .Errorf ("not supported for HAProxy versions lower than 2.4 %w" , native_errors .ErrGeneral )
982988 }
0 commit comments