-
Notifications
You must be signed in to change notification settings - Fork 185
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #446 from wking/gracefully-release-leader-lease-4.5
Bug 1872906: pkg/start: Release leader lease on graceful shutdown
- Loading branch information
Showing
12 changed files
with
298 additions
and
181 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,61 @@ | ||
package cvo | ||
|
||
import ( | ||
"crypto/tls" | ||
"crypto/x509" | ||
"fmt" | ||
"net/url" | ||
|
||
"k8s.io/apimachinery/pkg/api/errors" | ||
) | ||
|
||
// getHTTPSProxyURL returns a url.URL object for the configured | ||
// https proxy only. It can be nil if does not exist or there is an error. | ||
func (optr *Operator) getHTTPSProxyURL() (*url.URL, string, error) { | ||
proxy, err := optr.proxyLister.Get("cluster") | ||
|
||
if errors.IsNotFound(err) { | ||
return nil, "", nil | ||
} | ||
if err != nil { | ||
return nil, "", err | ||
} | ||
|
||
if &proxy.Spec != nil { | ||
if proxy.Spec.HTTPSProxy != "" { | ||
proxyURL, err := url.Parse(proxy.Spec.HTTPSProxy) | ||
if err != nil { | ||
return nil, "", err | ||
} | ||
return proxyURL, proxy.Spec.TrustedCA.Name, nil | ||
} | ||
} | ||
return nil, "", nil | ||
} | ||
|
||
func (optr *Operator) getTLSConfig(cmNameRef string) (*tls.Config, error) { | ||
cm, err := optr.cmConfigLister.Get(cmNameRef) | ||
|
||
if err != nil { | ||
return nil, err | ||
} | ||
|
||
certPool, _ := x509.SystemCertPool() | ||
if certPool == nil { | ||
certPool = x509.NewCertPool() | ||
} | ||
|
||
if cm.Data["ca-bundle.crt"] != "" { | ||
if ok := certPool.AppendCertsFromPEM([]byte(cm.Data["ca-bundle.crt"])); !ok { | ||
return nil, fmt.Errorf("unable to add ca-bundle.crt certificates") | ||
} | ||
} else { | ||
return nil, nil | ||
} | ||
|
||
config := &tls.Config{ | ||
RootCAs: certPool, | ||
} | ||
|
||
return config, nil | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.