add dnsStore interface for upcoming operator webhook (#10077)

master
Harshavardhana 4 years ago committed by GitHub
parent 518f44908c
commit 9fd836e51f
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
  1. 6
      cmd/common-main.go
  2. 5
      cmd/config/etcd/dns/etcd_dns.go
  3. 27
      cmd/config/etcd/dns/store.go
  4. 2
      cmd/data-update-tracker.go
  5. 8
      cmd/endpoint.go
  6. 2
      cmd/globals.go
  7. 4
      cmd/handler-api.go

@ -223,7 +223,11 @@ func handleCommonEnvVars() {
} else { } else {
// Add found interfaces IP address to global domain IPS, // Add found interfaces IP address to global domain IPS,
// loopback addresses will be naturally dropped. // loopback addresses will be naturally dropped.
updateDomainIPs(mustGetLocalIP4()) domainIPs := mustGetLocalIP4()
for _, host := range globalEndpoints.Hostnames() {
domainIPs.Add(host)
}
updateDomainIPs(domainIPs)
} }
// In place update is true by default if the MINIO_UPDATE is not set // In place update is true by default if the MINIO_UPDATE is not set

@ -48,8 +48,9 @@ func newCoreDNSMsg(ip string, port string, ttl uint32, t time.Time) ([]byte, err
} }
// Close closes the internal etcd client and cannot be used further // Close closes the internal etcd client and cannot be used further
func (c *CoreDNS) Close() { func (c *CoreDNS) Close() error {
c.etcdClient.Close() c.etcdClient.Close()
return nil
} }
// List - Retrieves list of DNS entries for the domain. // List - Retrieves list of DNS entries for the domain.
@ -259,7 +260,7 @@ func CoreDNSPath(prefix string) Option {
} }
// NewCoreDNS - initialize a new coreDNS set/unset values. // NewCoreDNS - initialize a new coreDNS set/unset values.
func NewCoreDNS(cfg clientv3.Config, setters ...Option) (*CoreDNS, error) { func NewCoreDNS(cfg clientv3.Config, setters ...Option) (Store, error) {
etcdClient, err := clientv3.New(cfg) etcdClient, err := clientv3.New(cfg)
if err != nil { if err != nil {
return nil, err return nil, err

@ -0,0 +1,27 @@
/*
* MinIO Cloud Storage, (C) 2020 MinIO, Inc.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package dns
// Store dns record store
type Store interface {
Put(bucket string) error
Get(bucket string) ([]SrvRecord, error)
Delete(bucket string) error
List() (map[string][]SrvRecord, error)
DeleteRecord(record SrvRecord) error
Close() error
}

@ -206,7 +206,7 @@ func (d *dataUpdateTracker) load(ctx context.Context, drives ...string) {
continue continue
} }
err = d.deserialize(f, d.Saved) err = d.deserialize(f, d.Saved)
if err != nil && err != io.EOF { if err != nil && err != io.EOF && err != io.ErrUnexpectedEOF {
logger.LogIf(ctx, err) logger.LogIf(ctx, err)
} }
f.Close() f.Close()

@ -239,15 +239,15 @@ func (l EndpointZones) NEndpoints() (count int) {
return count return count
} }
// Hosts - returns list of unique hosts // Hostnames - returns list of unique hostnames
func (l EndpointZones) Hosts() []string { func (l EndpointZones) Hostnames() []string {
foundSet := set.NewStringSet() foundSet := set.NewStringSet()
for _, ep := range l { for _, ep := range l {
for _, endpoint := range ep.Endpoints { for _, endpoint := range ep.Endpoints {
if foundSet.Contains(endpoint.Host) { if foundSet.Contains(endpoint.Hostname()) {
continue continue
} }
foundSet.Add(endpoint.Host) foundSet.Add(endpoint.Hostname())
} }
} }
return foundSet.ToSlice() return foundSet.ToSlice()

@ -234,7 +234,7 @@ var (
globalBucketFederation bool globalBucketFederation bool
// Allocated DNS config wrapper over etcd client. // Allocated DNS config wrapper over etcd client.
globalDNSConfig *dns.CoreDNS globalDNSConfig dns.Store
// GlobalKMS initialized KMS configuration // GlobalKMS initialized KMS configuration
GlobalKMS crypto.KMS GlobalKMS crypto.KMS

@ -44,8 +44,8 @@ func (t *apiConfig) init(cfg api.Config) {
} }
apiRequestsMax := cfg.APIRequestsMax apiRequestsMax := cfg.APIRequestsMax
if len(globalEndpoints.Hosts()) > 0 { if len(globalEndpoints.Hostnames()) > 0 {
apiRequestsMax /= len(globalEndpoints.Hosts()) apiRequestsMax /= len(globalEndpoints.Hostnames())
} }
t.requestsPool = make(chan struct{}, apiRequestsMax) t.requestsPool = make(chan struct{}, apiRequestsMax)

Loading…
Cancel
Save