Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Redis host port params #710

Closed
wants to merge 7 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
41 changes: 41 additions & 0 deletions GOVERNANCE.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
# Governance

## Project Maintainers

[Project maintainers](MAINTAINERS.md) are responsible for activities around
maintaining and updating the KEDA. Final decisions on the features
reside with the project maintainers.

Maintainers MUST remain active. If they are unresponsive for >3 months, they
will be automatically removed unless a
[super-majority](https://en.wikipedia.org/wiki/Supermajority#Two-thirds_vote) of
the other project maintainers agrees to extend the period to be greater than 3
months.

New maintainers can be added to the project by a
[super-majority](https://en.wikipedia.org/wiki/Supermajority#Two-thirds_vote)
vote of the existing maintainers. A potential maintainer may be nominated by an
existing maintainer. A vote is conducted in private between the current
maintainers over the course of a one week voting period. At the end of the week,
votes are counted and a pull request is made on the repo adding the new
maintainer to the [MAINTAINERS](MAINTAINERS.md) file.

A maintainer may step down by submitting an
[issue](https://github.com/kedacore/keda/issues/new) stating their intent.

Changes to this governance document require a pull request with approval from a
[super-majority](https://en.wikipedia.org/wiki/Supermajority#Two-thirds_vote) of
the current maintainers.

## Managing Projects

New projects can be added to the organization after a successful
[super-majority](https://en.wikipedia.org/wiki/Supermajority#Two-thirds_vote)
vote of the existing maintainers.

Contributors who want to donate an add-on scaler, sample or donate a repo must
create an issue explaining what the benefit would be for KEDA after which the
maintainers will vote and require a [super-majority](https://en.wikipedia.org/wiki/Supermajority#Two-thirds_vote)
of the current maintainers.

When KEDA wants to archive an existing project, maintainers have to take vote where a [super-majority](https://en.wikipedia.org/wiki/Supermajority#Two-thirds_vote) of the current maintainers agrees to archive the project with a clear indication of why it is being archived. We must not delete projects to avoid customer confusion.
1 change: 1 addition & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
<p style="font-size: 25px" align="center">
<a href="https://github.com/kedacore/keda/actions"><img src="https://github.com/kedacore/keda/workflows/master%20build/badge.svg" alt="master build"></a>
<a href="https://github.com/kedacore/keda/actions"><img src="https://github.com/kedacore/keda/workflows/nightly%20e2e%20test/badge.svg" alt="nightly e2e"></a>
<a href="https://bestpractices.coreinfrastructure.org/projects/3791"><img src="https://bestpractices.coreinfrastructure.org/projects/3791/badge"></a>
<a href="https://twitter.com/kedaorg"><img src="https://img.shields.io/twitter/follow/kedaorg?style=social" alt="Twitter"></a></p>

KEDA allows for fine grained autoscaling (including to/from zero) for event driven Kubernetes workloads. KEDA serves
Expand Down
23 changes: 23 additions & 0 deletions pkg/controller/scaledobject/scaledobject_controller.go
Original file line number Diff line number Diff line change
Expand Up @@ -216,6 +216,13 @@ func (r *ReconcileScaledObject) reconcileDeploymentType(logger logr.Logger, scal
return reconcile.Result{}, err
}

// add deploymentName label if needed
err = r.checkScaledObjectLabel(logger, scaledObject)
if err != nil {
logger.Error(err, "Failed to update ScaledObject with deploymentName label")
return reconcile.Result{}, err
}

hpaName := getHpaName(deploymentName)
hpaNamespace := scaledObject.Namespace

Expand Down Expand Up @@ -300,6 +307,22 @@ func checkDeploymentTypeScaledObject(scaledObject *kedav1alpha1.ScaledObject) (s
return deploymentName, err
}

func (r *ReconcileScaledObject) checkScaledObjectLabel(logger logr.Logger, scaledObject *kedav1alpha1.ScaledObject) error {

if scaledObject.Labels == nil {
scaledObject.Labels = map[string]string{"deploymentName": scaledObject.Spec.ScaleTargetRef.DeploymentName}
} else {
value, found := scaledObject.Labels["deploymentName"]
if found && value == scaledObject.Spec.ScaleTargetRef.DeploymentName {
return nil
}
scaledObject.Labels["deploymentName"] = scaledObject.Spec.ScaleTargetRef.DeploymentName
}

logger.V(1).Info("Adding deploymentName label on ScaledObject")
return r.client.Update(context.TODO(), scaledObject)
}

// startScaleLoop starts ScaleLoop handler for the respective ScaledObject
func (r *ReconcileScaledObject) startScaleLoop(logger logr.Logger, scaledObject *kedav1alpha1.ScaledObject) error {

Expand Down
8 changes: 4 additions & 4 deletions pkg/scalers/prometheus.go
Original file line number Diff line number Diff line change
Expand Up @@ -101,8 +101,8 @@ func (s *prometheusScaler) IsActive(ctx context.Context) (bool, error) {
prometheusLog.Error(err, "error executing prometheus query")
return false, err
}

return val > 0, nil
return val > -1, nil
}

func (s *prometheusScaler) Close() error {
Expand Down Expand Up @@ -144,9 +144,9 @@ func (s *prometheusScaler) ExecutePromQuery() (float64, error) {

var v float64 = -1

// only allow for single element result sets
// allow for zero element or single element result sets
if len(result.Data.Result) == 0 {
return -1, fmt.Errorf("Prometheus query %s returned empty", s.metadata.query)
return 0, nil
} else if len(result.Data.Result) > 1 {
return -1, fmt.Errorf("Prometheus query %s returned multiple elements", s.metadata.query)
}
Expand Down
30 changes: 29 additions & 1 deletion pkg/scalers/redis_scaler.go
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,8 @@ const (
defaultRedisPassword = ""
defaultDbIdx = 0
defaultEnableTLS = false
defaultHost = ""
defaultPort = ""
)

type redisScaler struct {
Expand All @@ -33,6 +35,8 @@ type redisMetadata struct {
listName string
address string
password string
host string
port string
databaseIndex int
enableTLS bool
}
Expand Down Expand Up @@ -70,14 +74,38 @@ func parseRedisMetadata(metadata, resolvedEnv, authParams map[string]string) (*r
}

address := defaultRedisAddress
host := defaultHost
port := defaultPort
if val, ok := metadata["address"]; ok && val != "" {
address = val
} else {
if val, ok := metadata["host"]; ok && val != "" {
host = val
} else {
return nil, fmt.Errorf("no address or host given. address should be in the format of host:port or you should set the host/port values")
}
if val, ok := metadata["port"]; ok && val != "" {
port = val
} else {
return nil, fmt.Errorf("no address or port given. address should be in the format of host:port or you should set the host/port values")
}
}

if val, ok := resolvedEnv[address]; ok {
meta.address = val
} else {
return nil, fmt.Errorf("no address given. Address should be in the format of host:port")
if val, ok := resolvedEnv[host]; ok {
meta.host = val
} else {
return nil, fmt.Errorf("no address given or host given. Address should be in the format of host:port or you should provide both host and port")
}

if val, ok := resolvedEnv[port]; ok {
meta.port = val
} else {
return nil, fmt.Errorf("no address or port given. Address should be in the format of host:port or you should provide both host and port")
}
meta.address = fmt.Sprintf("%s:%s", meta.host, meta.port)
}

meta.password = defaultRedisPassword
Expand Down
6 changes: 6 additions & 0 deletions pkg/scalers/redis_scaler_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,12 @@ var testRedisMetadata = []parseRedisMetadataTestData{
{map[string]string{}, true, map[string]string{}},
// properly formed listName
{map[string]string{"listName": "mylist", "listLength": "10", "address": "REDIS_HOST", "password": "REDIS_PASSWORD"}, false, map[string]string{}},
// properly formed hostPort
{map[string]string{"listName": "mylist", "listLength": "10", "host": "REDIS_HOST", "port": "REDIS_PORT", "password": "REDIS_PASSWORD"}, false, map[string]string{}},
// properly formed hostPort
{map[string]string{"listName": "mylist", "listLength": "10", "address": "REDIS_HOST", "host": "REDIS_HOST", "port": "REDIS_PORT", "password": "REDIS_PASSWORD"}, false, map[string]string{}},
// improperly formed hostPort
{map[string]string{"listName": "mylist", "listLength": "10", "host": "REDIS_HOST", "password": "REDIS_PASSWORD"}, true, map[string]string{}},
// properly formed listName, empty address
{map[string]string{"listName": "mylist", "listLength": "10", "address": "", "password": ""}, true, map[string]string{}},
// improperly formed listLength
Expand Down
Loading