Skip to content

Commit

Permalink
Feat/exclude externally scaled workloads (#78)
Browse files Browse the repository at this point in the history
* feat: exclude workloads scaled by scaled objects

* refactor: add comments and avoid type shadowing

* fix: inverse logic

* feat: add tests

* refactor: externally scaled filter to better match exsiting structure

* Squashed commit of the following:

commit 3e40c69
Author: Jonathan Mayer <[email protected]>
Date:   Tue Jan 21 06:45:41 2025 +0100

    Refactor/enforce stricter go linters (#93)

    * Merge branch 'perf/make-slices-more-efficient'

    * refactor: everything to stop new linters from crying

    * Squashed commit of the following:

    commit ae78197
    Author: Jonathan Mayer <[email protected]>
    Date:   Mon Jan 13 09:35:27 2025 +0100

        perf: reduce memory allocations (#81)

        * perf: reduce memory allocations

        * perf: avoid preallocating the slice with zero values

        * perf: avoid temporary copies in get resource functions

    commit ad608b6
    Author: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
    Date:   Mon Jan 13 08:21:37 2025 +0100

        chore(deps): bump github.com/zalando-incubator/stackset-controller from 1.4.84 to 1.4.92 (#94)

        * chore(deps): bump github.com/zalando-incubator/stackset-controller

        Bumps [github.com/zalando-incubator/stackset-controller](https://github.com/zalando-incubator/stackset-controller) from 1.4.84 to 1.4.92.
        - [Release notes](https://github.com/zalando-incubator/stackset-controller/releases)
        - [Commits](zalando-incubator/stackset-controller@v1.4.84...v1.4.92)

        ---
        updated-dependencies:
        - dependency-name: github.com/zalando-incubator/stackset-controller
          dependency-type: direct:production
          update-type: version-update:semver-patch
        ...

        Signed-off-by: dependabot[bot] <[email protected]>

        * chore: bump deps dependabot didnt

        ---------

        Signed-off-by: dependabot[bot] <[email protected]>
        Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
        Co-authored-by: jonathan-mayer <[email protected]>

    commit 48d222f
    Author: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
    Date:   Fri Jan 10 07:47:01 2025 +0100

        chore(deps): bump github.com/prometheus-operator/prometheus-operator/pkg/client (#87)

        Bumps [github.com/prometheus-operator/prometheus-operator/pkg/client](https://github.com/prometheus-operator/prometheus-operator) from 0.76.2 to 0.79.2.
        - [Release notes](https://github.com/prometheus-operator/prometheus-operator/releases)
        - [Changelog](https://github.com/prometheus-operator/prometheus-operator/blob/main/CHANGELOG.md)
        - [Commits](prometheus-operator/prometheus-operator@v0.76.2...v0.79.2)

        ---
        updated-dependencies:
        - dependency-name: github.com/prometheus-operator/prometheus-operator/pkg/client
          dependency-type: direct:production
          update-type: version-update:semver-minor
        ...

        Signed-off-by: dependabot[bot] <[email protected]>
        Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>

    commit e856e24
    Author: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
    Date:   Fri Jan 10 07:38:58 2025 +0100

        chore(deps): bump github.com/kedacore/keda/v2 from 2.15.1 to 2.16.1 (#90)

        * chore(deps): bump github.com/kedacore/keda/v2 from 2.15.1 to 2.16.1

        Bumps [github.com/kedacore/keda/v2](https://github.com/kedacore/keda) from 2.15.1 to 2.16.1.
        - [Release notes](https://github.com/kedacore/keda/releases)
        - [Changelog](https://github.com/kedacore/keda/blob/main/CHANGELOG.md)
        - [Commits](kedacore/keda@v2.15.1...v2.16.1)

        ---
        updated-dependencies:
        - dependency-name: github.com/kedacore/keda/v2
          dependency-type: direct:production
          update-type: version-update:semver-minor
        ...

        Signed-off-by: dependabot[bot] <[email protected]>

        * chore: automatically push pre-commit changes

        * Merge remote-tracking branch 'origin/main'

        * Squashed commit of the following:

        commit 5cf9b47
        Author: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
        Date:   Fri Jan 10 07:19:20 2025 +0100

            chore(deps): bump k8s.io/api from 0.31.0 to 0.32.0 (#89)

            * chore(deps): bump k8s.io/api from 0.31.0 to 0.32.0

            Bumps [k8s.io/api](https://github.com/kubernetes/api) from 0.31.0 to 0.32.0.
            - [Commits](kubernetes/api@v0.31.0...v0.32.0)

            ---
            updated-dependencies:
            - dependency-name: k8s.io/api
              dependency-type: direct:production
              update-type: version-update:semver-minor
            ...

            Signed-off-by: dependabot[bot] <[email protected]>

            * fix: bump client-go to match with other dependencies

            ---------

            Signed-off-by: dependabot[bot] <[email protected]>
            Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
            Co-authored-by: jonathan-mayer <[email protected]>

        commit 7c5dc08
        Author: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
        Date:   Fri Jan 10 07:03:48 2025 +0100

            chore(deps): bump golang from 1.23.1 to 1.23.4 (#91)

            * chore(deps): bump golang from 1.23.1 to 1.23.4

            Bumps golang from 1.23.1 to 1.23.4.

            ---
            updated-dependencies:
            - dependency-name: golang
              dependency-type: direct:production
              update-type: version-update:semver-patch
            ...

            Signed-off-by: dependabot[bot] <[email protected]>

            * chore: bump golang from 1.23.1 to 1.23.4

            ---------

            Signed-off-by: dependabot[bot] <[email protected]>
            Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
            Co-authored-by: jonathan-mayer <[email protected]>

        commit efe5db1
        Author: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
        Date:   Fri Jan 10 06:51:57 2025 +0100

            chore(deps): bump actions/setup-go from 5.0.2 to 5.2.0 (#85)

            Bumps [actions/setup-go](https://github.com/actions/setup-go) from 5.0.2 to 5.2.0.
            - [Release notes](https://github.com/actions/setup-go/releases)
            - [Commits](actions/setup-go@v5.0.2...v5.2.0)

            ---
            updated-dependencies:
            - dependency-name: actions/setup-go
              dependency-type: direct:production
              update-type: version-update:semver-minor
            ...

            Signed-off-by: dependabot[bot] <[email protected]>
            Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>

        commit 952f8b2
        Author: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
        Date:   Fri Jan 10 06:51:28 2025 +0100

            chore(deps): bump docker/build-push-action from 5 to 6 (#84)

            Bumps [docker/build-push-action](https://github.com/docker/build-push-action) from 5 to 6.
            - [Release notes](https://github.com/docker/build-push-action/releases)
            - [Commits](docker/build-push-action@v5...v6)

            ---
            updated-dependencies:
            - dependency-name: docker/build-push-action
              dependency-type: direct:production
              update-type: version-update:semver-major
            ...

            Signed-off-by: dependabot[bot] <[email protected]>
            Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>

        * Squashed commit of the following:

        commit 5cf9b47
        Author: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
        Date:   Fri Jan 10 07:19:20 2025 +0100

            chore(deps): bump k8s.io/api from 0.31.0 to 0.32.0 (#89)

            * chore(deps): bump k8s.io/api from 0.31.0 to 0.32.0

            Bumps [k8s.io/api](https://github.com/kubernetes/api) from 0.31.0 to 0.32.0.
            - [Commits](kubernetes/api@v0.31.0...v0.32.0)

            ---
            updated-dependencies:
            - dependency-name: k8s.io/api
              dependency-type: direct:production
              update-type: version-update:semver-minor
            ...

            Signed-off-by: dependabot[bot] <[email protected]>

            * fix: bump client-go to match with other dependencies

            ---------

            Signed-off-by: dependabot[bot] <[email protected]>
            Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
            Co-authored-by: jonathan-mayer <[email protected]>

        commit 7c5dc08
        Author: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
        Date:   Fri Jan 10 07:03:48 2025 +0100

            chore(deps): bump golang from 1.23.1 to 1.23.4 (#91)

            * chore(deps): bump golang from 1.23.1 to 1.23.4

            Bumps golang from 1.23.1 to 1.23.4.

            ---
            updated-dependencies:
            - dependency-name: golang
              dependency-type: direct:production
              update-type: version-update:semver-patch
            ...

            Signed-off-by: dependabot[bot] <[email protected]>

            * chore: bump golang from 1.23.1 to 1.23.4

            ---------

            Signed-off-by: dependabot[bot] <[email protected]>
            Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
            Co-authored-by: jonathan-mayer <[email protected]>

        commit efe5db1
        Author: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
        Date:   Fri Jan 10 06:51:57 2025 +0100

            chore(deps): bump actions/setup-go from 5.0.2 to 5.2.0 (#85)

            Bumps [actions/setup-go](https://github.com/actions/setup-go) from 5.0.2 to 5.2.0.
            - [Release notes](https://github.com/actions/setup-go/releases)
            - [Commits](actions/setup-go@v5.0.2...v5.2.0)

            ---
            updated-dependencies:
            - dependency-name: actions/setup-go
              dependency-type: direct:production
              update-type: version-update:semver-minor
            ...

            Signed-off-by: dependabot[bot] <[email protected]>
            Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>

        commit 952f8b2
        Author: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
        Date:   Fri Jan 10 06:51:28 2025 +0100

            chore(deps): bump docker/build-push-action from 5 to 6 (#84)

            Bumps [docker/build-push-action](https://github.com/docker/build-push-action) from 5 to 6.
            - [Release notes](https://github.com/docker/build-push-action/releases)
            - [Commits](docker/build-push-action@v5...v6)

            ---
            updated-dependencies:
            - dependency-name: docker/build-push-action
              dependency-type: direct:production
              update-type: version-update:semver-major
            ...

            Signed-off-by: dependabot[bot] <[email protected]>
            Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>

        ---------

        Signed-off-by: dependabot[bot] <[email protected]>
        Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
        Co-authored-by: github-actions[bot] <github-actions[bot]@users.noreply.github.com>
        Co-authored-by: jonathan-mayer <[email protected]>

    commit 5cf9b47
    Author: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
    Date:   Fri Jan 10 07:19:20 2025 +0100

        chore(deps): bump k8s.io/api from 0.31.0 to 0.32.0 (#89)

        * chore(deps): bump k8s.io/api from 0.31.0 to 0.32.0

        Bumps [k8s.io/api](https://github.com/kubernetes/api) from 0.31.0 to 0.32.0.
        - [Commits](kubernetes/api@v0.31.0...v0.32.0)

        ---
        updated-dependencies:
        - dependency-name: k8s.io/api
          dependency-type: direct:production
          update-type: version-update:semver-minor
        ...

        Signed-off-by: dependabot[bot] <[email protected]>

        * fix: bump client-go to match with other dependencies

        ---------

        Signed-off-by: dependabot[bot] <[email protected]>
        Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
        Co-authored-by: jonathan-mayer <[email protected]>

    commit 7c5dc08
    Author: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
    Date:   Fri Jan 10 07:03:48 2025 +0100

        chore(deps): bump golang from 1.23.1 to 1.23.4 (#91)

        * chore(deps): bump golang from 1.23.1 to 1.23.4

        Bumps golang from 1.23.1 to 1.23.4.

        ---
        updated-dependencies:
        - dependency-name: golang
          dependency-type: direct:production
          update-type: version-update:semver-patch
        ...

        Signed-off-by: dependabot[bot] <[email protected]>

        * chore: bump golang from 1.23.1 to 1.23.4

        ---------

        Signed-off-by: dependabot[bot] <[email protected]>
        Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
        Co-authored-by: jonathan-mayer <[email protected]>

    commit efe5db1
    Author: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
    Date:   Fri Jan 10 06:51:57 2025 +0100

        chore(deps): bump actions/setup-go from 5.0.2 to 5.2.0 (#85)

        Bumps [actions/setup-go](https://github.com/actions/setup-go) from 5.0.2 to 5.2.0.
        - [Release notes](https://github.com/actions/setup-go/releases)
        - [Commits](actions/setup-go@v5.0.2...v5.2.0)

        ---
        updated-dependencies:
        - dependency-name: actions/setup-go
          dependency-type: direct:production
          update-type: version-update:semver-minor
        ...

        Signed-off-by: dependabot[bot] <[email protected]>
        Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>

    commit 952f8b2
    Author: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
    Date:   Fri Jan 10 06:51:28 2025 +0100

        chore(deps): bump docker/build-push-action from 5 to 6 (#84)

        Bumps [docker/build-push-action](https://github.com/docker/build-push-action) from 5 to 6.
        - [Release notes](https://github.com/docker/build-push-action/releases)
        - [Commits](docker/build-push-action@v5...v6)

        ---
        updated-dependencies:
        - dependency-name: docker/build-push-action
          dependency-type: direct:production
          update-type: version-update:semver-major
        ...

        Signed-off-by: dependabot[bot] <[email protected]>
        Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>

    commit 0f9015c
    Author: Jonathan Mayer <[email protected]>
    Date:   Thu Jan 9 14:39:09 2025 +0100

        chore: add dependabot config (#83)

    commit f0b9f9e
    Author: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
    Date:   Thu Jan 9 14:33:04 2025 +0100

        chore(deps): bump golang.org/x/net from 0.28.0 to 0.33.0 (#82)

        Bumps [golang.org/x/net](https://github.com/golang/net) from 0.28.0 to 0.33.0.
        - [Commits](golang/net@v0.28.0...v0.33.0)

        ---
        updated-dependencies:
        - dependency-name: golang.org/x/net
          dependency-type: indirect
        ...

        Signed-off-by: dependabot[bot] <[email protected]>
        Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>

    * chore: resolve pr threads

commit 4fcf2d2
Author: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
Date:   Tue Jan 21 06:44:45 2025 +0100

    chore(deps): bump actions/setup-go from 5.2.0 to 5.3.0 (#99)

    Bumps [actions/setup-go](https://github.com/actions/setup-go) from 5.2.0 to 5.3.0.
    - [Release notes](https://github.com/actions/setup-go/releases)
    - [Commits](actions/setup-go@v5.2.0...v5.3.0)

    ---
    updated-dependencies:
    - dependency-name: actions/setup-go
      dependency-type: direct:production
      update-type: version-update:semver-minor
    ...

    Signed-off-by: dependabot[bot] <[email protected]>
    Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>

commit 6845a45
Author: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
Date:   Tue Jan 21 06:44:06 2025 +0100

    chore(deps): bump golang from 1.23.4 to 1.23.5 (#98)

    Bumps golang from 1.23.4 to 1.23.5.

    ---
    updated-dependencies:
    - dependency-name: golang
      dependency-type: direct:production
      update-type: version-update:semver-patch
    ...

    Signed-off-by: dependabot[bot] <[email protected]>
    Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>

commit 4000ab1
Author: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
Date:   Thu Jan 16 06:50:43 2025 +0100

    chore(deps): bump k8s.io/client-go from 0.32.0 to 0.32.1 (#96)

    Bumps [k8s.io/client-go](https://github.com/kubernetes/client-go) from 0.32.0 to 0.32.1.
    - [Changelog](https://github.com/kubernetes/client-go/blob/master/CHANGELOG.md)
    - [Commits](kubernetes/client-go@v0.32.0...v0.32.1)

    ---
    updated-dependencies:
    - dependency-name: k8s.io/client-go
      dependency-type: direct:production
      update-type: version-update:semver-patch
    ...

    Signed-off-by: dependabot[bot] <[email protected]>
    Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>

commit ae78197
Author: Jonathan Mayer <[email protected]>
Date:   Mon Jan 13 09:35:27 2025 +0100

    perf: reduce memory allocations (#81)

    * perf: reduce memory allocations

    * perf: avoid preallocating the slice with zero values

    * perf: avoid temporary copies in get resource functions

commit ad608b6
Author: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
Date:   Mon Jan 13 08:21:37 2025 +0100

    chore(deps): bump github.com/zalando-incubator/stackset-controller from 1.4.84 to 1.4.92 (#94)

    * chore(deps): bump github.com/zalando-incubator/stackset-controller

    Bumps [github.com/zalando-incubator/stackset-controller](https://github.com/zalando-incubator/stackset-controller) from 1.4.84 to 1.4.92.
    - [Release notes](https://github.com/zalando-incubator/stackset-controller/releases)
    - [Commits](zalando-incubator/stackset-controller@v1.4.84...v1.4.92)

    ---
    updated-dependencies:
    - dependency-name: github.com/zalando-incubator/stackset-controller
      dependency-type: direct:production
      update-type: version-update:semver-patch
    ...

    Signed-off-by: dependabot[bot] <[email protected]>

    * chore: bump deps dependabot didnt

    ---------

    Signed-off-by: dependabot[bot] <[email protected]>
    Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
    Co-authored-by: jonathan-mayer <[email protected]>

commit 48d222f
Author: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
Date:   Fri Jan 10 07:47:01 2025 +0100

    chore(deps): bump github.com/prometheus-operator/prometheus-operator/pkg/client (#87)

    Bumps [github.com/prometheus-operator/prometheus-operator/pkg/client](https://github.com/prometheus-operator/prometheus-operator) from 0.76.2 to 0.79.2.
    - [Release notes](https://github.com/prometheus-operator/prometheus-operator/releases)
    - [Changelog](https://github.com/prometheus-operator/prometheus-operator/blob/main/CHANGELOG.md)
    - [Commits](prometheus-operator/prometheus-operator@v0.76.2...v0.79.2)

    ---
    updated-dependencies:
    - dependency-name: github.com/prometheus-operator/prometheus-operator/pkg/client
      dependency-type: direct:production
      update-type: version-update:semver-minor
    ...

    Signed-off-by: dependabot[bot] <[email protected]>
    Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>

commit e856e24
Author: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
Date:   Fri Jan 10 07:38:58 2025 +0100

    chore(deps): bump github.com/kedacore/keda/v2 from 2.15.1 to 2.16.1 (#90)

    * chore(deps): bump github.com/kedacore/keda/v2 from 2.15.1 to 2.16.1

    Bumps [github.com/kedacore/keda/v2](https://github.com/kedacore/keda) from 2.15.1 to 2.16.1.
    - [Release notes](https://github.com/kedacore/keda/releases)
    - [Changelog](https://github.com/kedacore/keda/blob/main/CHANGELOG.md)
    - [Commits](kedacore/keda@v2.15.1...v2.16.1)

    ---
    updated-dependencies:
    - dependency-name: github.com/kedacore/keda/v2
      dependency-type: direct:production
      update-type: version-update:semver-minor
    ...

    Signed-off-by: dependabot[bot] <[email protected]>

    * chore: automatically push pre-commit changes

    * Merge remote-tracking branch 'origin/main'

    * Squashed commit of the following:

    commit 5cf9b47
    Author: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
    Date:   Fri Jan 10 07:19:20 2025 +0100

        chore(deps): bump k8s.io/api from 0.31.0 to 0.32.0 (#89)

        * chore(deps): bump k8s.io/api from 0.31.0 to 0.32.0

        Bumps [k8s.io/api](https://github.com/kubernetes/api) from 0.31.0 to 0.32.0.
        - [Commits](kubernetes/api@v0.31.0...v0.32.0)

        ---
        updated-dependencies:
        - dependency-name: k8s.io/api
          dependency-type: direct:production
          update-type: version-update:semver-minor
        ...

        Signed-off-by: dependabot[bot] <[email protected]>

        * fix: bump client-go to match with other dependencies

        ---------

        Signed-off-by: dependabot[bot] <[email protected]>
        Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
        Co-authored-by: jonathan-mayer <[email protected]>

    commit 7c5dc08
    Author: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
    Date:   Fri Jan 10 07:03:48 2025 +0100

        chore(deps): bump golang from 1.23.1 to 1.23.4 (#91)

        * chore(deps): bump golang from 1.23.1 to 1.23.4

        Bumps golang from 1.23.1 to 1.23.4.

        ---
        updated-dependencies:
        - dependency-name: golang
          dependency-type: direct:production
          update-type: version-update:semver-patch
        ...

        Signed-off-by: dependabot[bot] <[email protected]>

        * chore: bump golang from 1.23.1 to 1.23.4

        ---------

        Signed-off-by: dependabot[bot] <[email protected]>
        Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
        Co-authored-by: jonathan-mayer <[email protected]>

    commit efe5db1
    Author: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
    Date:   Fri Jan 10 06:51:57 2025 +0100

        chore(deps): bump actions/setup-go from 5.0.2 to 5.2.0 (#85)

        Bumps [actions/setup-go](https://github.com/actions/setup-go) from 5.0.2 to 5.2.0.
        - [Release notes](https://github.com/actions/setup-go/releases)
        - [Commits](actions/setup-go@v5.0.2...v5.2.0)

        ---
        updated-dependencies:
        - dependency-name: actions/setup-go
          dependency-type: direct:production
          update-type: version-update:semver-minor
        ...

        Signed-off-by: dependabot[bot] <[email protected]>
        Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>

    commit 952f8b2
    Author: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
    Date:   Fri Jan 10 06:51:28 2025 +0100

        chore(deps): bump docker/build-push-action from 5 to 6 (#84)

        Bumps [docker/build-push-action](https://github.com/docker/build-push-action) from 5 to 6.
        - [Release notes](https://github.com/docker/build-push-action/releases)
        - [Commits](docker/build-push-action@v5...v6)

        ---
        updated-dependencies:
        - dependency-name: docker/build-push-action
          dependency-type: direct:production
          update-type: version-update:semver-major
        ...

        Signed-off-by: dependabot[bot] <[email protected]>
        Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>

    * Squashed commit of the following:

    commit 5cf9b47
    Author: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
    Date:   Fri Jan 10 07:19:20 2025 +0100

        chore(deps): bump k8s.io/api from 0.31.0 to 0.32.0 (#89)

        * chore(deps): bump k8s.io/api from 0.31.0 to 0.32.0

        Bumps [k8s.io/api](https://github.com/kubernetes/api) from 0.31.0 to 0.32.0.
        - [Commits](kubernetes/api@v0.31.0...v0.32.0)

        ---
        updated-dependencies:
        - dependency-name: k8s.io/api
          dependency-type: direct:production
          update-type: version-update:semver-minor
        ...

        Signed-off-by: dependabot[bot] <[email protected]>

        * fix: bump client-go to match with other dependencies

        ---------

        Signed-off-by: dependabot[bot] <[email protected]>
        Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
        Co-authored-by: jonathan-mayer <[email protected]>

    commit 7c5dc08
    Author: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
    Date:   Fri Jan 10 07:03:48 2025 +0100

        chore(deps): bump golang from 1.23.1 to 1.23.4 (#91)

        * chore(deps): bump golang from 1.23.1 to 1.23.4

        Bumps golang from 1.23.1 to 1.23.4.

        ---
        updated-dependencies:
        - dependency-name: golang
          dependency-type: direct:production
          update-type: version-update:semver-patch
        ...

        Signed-off-by: dependabot[bot] <[email protected]>

        * chore: bump golang from 1.23.1 to 1.23.4

        ---------

        Signed-off-by: dependabot[bot] <[email protected]>
        Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
        Co-authored-by: jonathan-mayer <[email protected]>

    commit efe5db1
    Author: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
    Date:   Fri Jan 10 06:51:57 2025 +0100

        chore(deps): bump actions/setup-go from 5.0.2 to 5.2.0 (#85)

        Bumps [actions/setup-go](https://github.com/actions/setup-go) from 5.0.2 to 5.2.0.
        - [Release notes](https://github.com/actions/setup-go/releases)
        - [Commits](actions/setup-go@v5.0.2...v5.2.0)

        ---
        updated-dependencies:
        - dependency-name: actions/setup-go
          dependency-type: direct:production
          update-type: version-update:semver-minor
        ...

        Signed-off-by: dependabot[bot] <[email protected]>
        Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>

    commit 952f8b2
    Author: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
    Date:   Fri Jan 10 06:51:28 2025 +0100

        chore(deps): bump docker/build-push-action from 5 to 6 (#84)

        Bumps [docker/build-push-action](https://github.com/docker/build-push-action) from 5 to 6.
        - [Release notes](https://github.com/docker/build-push-action/releases)
        - [Commits](docker/build-push-action@v5...v6)

        ---
        updated-dependencies:
        - dependency-name: docker/build-push-action
          dependency-type: direct:production
          update-type: version-update:semver-major
        ...

        Signed-off-by: dependabot[bot] <[email protected]>
        Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>

    ---------

    Signed-off-by: dependabot[bot] <[email protected]>
    Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
    Co-authored-by: github-actions[bot] <github-actions[bot]@users.noreply.github.com>
    Co-authored-by: jonathan-mayer <[email protected]>

commit 5cf9b47
Author: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
Date:   Fri Jan 10 07:19:20 2025 +0100

    chore(deps): bump k8s.io/api from 0.31.0 to 0.32.0 (#89)

    * chore(deps): bump k8s.io/api from 0.31.0 to 0.32.0

    Bumps [k8s.io/api](https://github.com/kubernetes/api) from 0.31.0 to 0.32.0.
    - [Commits](kubernetes/api@v0.31.0...v0.32.0)

    ---
    updated-dependencies:
    - dependency-name: k8s.io/api
      dependency-type: direct:production
      update-type: version-update:semver-minor
    ...

    Signed-off-by: dependabot[bot] <[email protected]>

    * fix: bump client-go to match with other dependencies

    ---------

    Signed-off-by: dependabot[bot] <[email protected]>
    Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
    Co-authored-by: jonathan-mayer <[email protected]>

commit 7c5dc08
Author: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
Date:   Fri Jan 10 07:03:48 2025 +0100

    chore(deps): bump golang from 1.23.1 to 1.23.4 (#91)

    * chore(deps): bump golang from 1.23.1 to 1.23.4

    Bumps golang from 1.23.1 to 1.23.4.

    ---
    updated-dependencies:
    - dependency-name: golang
      dependency-type: direct:production
      update-type: version-update:semver-patch
    ...

    Signed-off-by: dependabot[bot] <[email protected]>

    * chore: bump golang from 1.23.1 to 1.23.4

    ---------

    Signed-off-by: dependabot[bot] <[email protected]>
    Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
    Co-authored-by: jonathan-mayer <[email protected]>

commit efe5db1
Author: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
Date:   Fri Jan 10 06:51:57 2025 +0100

    chore(deps): bump actions/setup-go from 5.0.2 to 5.2.0 (#85)

    Bumps [actions/setup-go](https://github.com/actions/setup-go) from 5.0.2 to 5.2.0.
    - [Release notes](https://github.com/actions/setup-go/releases)
    - [Commits](actions/setup-go@v5.0.2...v5.2.0)

    ---
    updated-dependencies:
    - dependency-name: actions/setup-go
      dependency-type: direct:production
      update-type: version-update:semver-minor
    ...

    Signed-off-by: dependabot[bot] <[email protected]>
    Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>

commit 952f8b2
Author: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
Date:   Fri Jan 10 06:51:28 2025 +0100

    chore(deps): bump docker/build-push-action from 5 to 6 (#84)

    Bumps [docker/build-push-action](https://github.com/docker/build-push-action) from 5 to 6.
    - [Release notes](https://github.com/docker/build-push-action/releases)
    - [Commits](docker/build-push-action@v5...v6)

    ---
    updated-dependencies:
    - dependency-name: docker/build-push-action
      dependency-type: direct:production
      update-type: version-update:semver-major
    ...

    Signed-off-by: dependabot[bot] <[email protected]>
    Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>

commit 0f9015c
Author: Jonathan Mayer <[email protected]>
Date:   Thu Jan 9 14:39:09 2025 +0100

    chore: add dependabot config (#83)

commit f0b9f9e
Author: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
Date:   Thu Jan 9 14:33:04 2025 +0100

    chore(deps): bump golang.org/x/net from 0.28.0 to 0.33.0 (#82)

    Bumps [golang.org/x/net](https://github.com/golang/net) from 0.28.0 to 0.33.0.
    - [Commits](golang/net@v0.28.0...v0.33.0)

    ---
    updated-dependencies:
    - dependency-name: golang.org/x/net
      dependency-type: indirect
    ...

    Signed-off-by: dependabot[bot] <[email protected]>
    Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>

commit 3fcaee6
Author: Jan <[email protected]>
Date:   Fri Jan 3 11:47:18 2025 +0100

    fix: make workflows run for forks (#77)

* refactor: revert renameing of vars

* refactor: make slice clipping more readable
  • Loading branch information
jonathan-mayer authored Jan 22, 2025
1 parent 3e40c69 commit f6dbfc0
Show file tree
Hide file tree
Showing 4 changed files with 144 additions and 8 deletions.
4 changes: 2 additions & 2 deletions internal/api/kubernetes/client.go
Original file line number Diff line number Diff line change
Expand Up @@ -220,11 +220,11 @@ func (c client) addWorkloadEvent(eventType, reason, identifier, message string,
Namespace: workload.GetNamespace(),
},
InvolvedObject: corev1.ObjectReference{
Kind: workload.GetObjectKind().GroupVersionKind().Kind,
Kind: workload.GroupVersionKind().Kind,
Namespace: workload.GetNamespace(),
Name: workload.GetName(),
UID: workload.GetUID(),
APIVersion: workload.GetObjectKind().GroupVersionKind().GroupVersion().String(),
APIVersion: workload.GroupVersionKind().GroupVersion().String(),
},
Reason: reason,
Message: message,
Expand Down
95 changes: 91 additions & 4 deletions internal/pkg/scalable/util.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,17 +3,20 @@ package scalable
import (
"fmt"
"log/slog"
"slices"
"strconv"
"strings"

"github.com/caas-team/gokubedownscaler/internal/pkg/util"
"k8s.io/apimachinery/pkg/runtime/schema"
)

const (
annotationOriginalReplicas = "downscaler/original-replicas"
)
const annotationOriginalReplicas = "downscaler/original-replicas"

// FilterExcluded filters the workloads to match the includeLabels, excludedNamespaces and excludedWorkloads.
func FilterExcluded(workloads []Workload, includeLabels, excludedNamespaces, excludedWorkloads util.RegexList) []Workload {
externallyScaled := getExternallyScaled(workloads)

results := make([]Workload, 0, len(workloads))

for _, workload := range workloads {
Expand Down Expand Up @@ -47,10 +50,94 @@ func FilterExcluded(workloads []Workload, includeLabels, excludedNamespaces, exc
continue
}

if isExternallyScaled(workload, externallyScaled) {
slog.Debug(
"the workload is scaled externally, excluding it from being scanned",
"workload", workload.GetName(),
"namespace", workload.GetNamespace(),
)

continue
}

results = append(results, workload)
}

return results[:len(results):len(results)] // unallocate excess capacity
return slices.Clip(results)
}

type workloadIdentifier struct {
gvk schema.GroupVersionKind
name string
namespace string
}

// getExternallyScaled returns identifiers for workloads which are being scaled externally and should therefore be excluded.
func getExternallyScaled(workloads []Workload) []workloadIdentifier {
externallyScaled := make([]workloadIdentifier, 0, len(workloads))

for _, workload := range workloads {
scaledobject := getWorkloadAsScaledObject(workload)
if scaledobject == nil {
continue
}

externallyScaled = append(externallyScaled, workloadIdentifier{
gvk: schema.GroupVersionKind{
Kind: scaledobject.Spec.ScaleTargetRef.Kind,
Group: strings.Split(scaledobject.Spec.ScaleTargetRef.APIVersion, "/")[0],
Version: strings.Split(scaledobject.Spec.ScaleTargetRef.APIVersion, "/")[1],
},
name: scaledobject.Spec.ScaleTargetRef.Name,
namespace: scaledobject.Namespace,
})
}

return slices.Clip(externallyScaled)
}

// isExternallyScaled checks if the workload matches any of the given workload identifiers.
func isExternallyScaled(workload Workload, externallyScaled []workloadIdentifier) bool {
for _, wid := range externallyScaled {
if wid.name != workload.GetName() {
continue
}

if wid.namespace != workload.GetNamespace() {
continue
}

if !(wid.gvk.Group == "" || wid.gvk.Group == workload.GroupVersionKind().Group) {
continue
}

if !(wid.gvk.Version == "" || wid.gvk.Version == workload.GroupVersionKind().Version) {
continue
}

if !(wid.gvk.Kind == "" || wid.gvk.Kind == workload.GroupVersionKind().Kind) {
continue
}

return true
}

return false
}

// getWorkloadAsScaledObject tries to get the given workload as a scaled object.
func getWorkloadAsScaledObject(workload Workload) *scaledObject {
replicaScaled, isReplicaScaled := workload.(*replicaScaledWorkload)
if !isReplicaScaled {
return nil
}

scaledObject, isScaledObject := replicaScaled.replicaScaledResource.(*scaledObject)
if !isScaledObject {
return nil
}

return scaledObject
}

// isMatchingLabels check if the workload is matching any of the specified labels.
Expand Down
49 changes: 49 additions & 0 deletions internal/pkg/scalable/util_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ import (
"testing"

"github.com/caas-team/gokubedownscaler/internal/pkg/util"
"github.com/kedacore/keda/v2/apis/keda/v1alpha1"
"github.com/stretchr/testify/assert"
appsv1 "k8s.io/api/apps/v1"
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
Expand All @@ -18,6 +19,7 @@ func TestFilterExcluded(t *testing.T) {
deployment1 Workload
deployment2 Workload
labeledDeployment Workload
scaledObject Workload
}
ns1 := ns{
deployment1: &replicaScaledWorkload{&deployment{Deployment: &appsv1.Deployment{
Expand Down Expand Up @@ -50,6 +52,45 @@ func TestFilterExcluded(t *testing.T) {
},
}}},
}
ns3 := ns{
deployment1: &replicaScaledWorkload{&deployment{Deployment: &appsv1.Deployment{
ObjectMeta: metav1.ObjectMeta{
Name: "Deployment1",
Namespace: "Namespace3",
},
TypeMeta: metav1.TypeMeta{
Kind: "Deployment",
APIVersion: "apps/v1",
},
}}},
deployment2: &replicaScaledWorkload{&deployment{Deployment: &appsv1.Deployment{
ObjectMeta: metav1.ObjectMeta{
Name: "Deployment2",
Namespace: "Namespace3",
},
TypeMeta: metav1.TypeMeta{
Kind: "Deployment",
APIVersion: "apps/v1",
},
}}},
scaledObject: &replicaScaledWorkload{&scaledObject{ScaledObject: &v1alpha1.ScaledObject{
ObjectMeta: metav1.ObjectMeta{
Name: "ScaledObject1",
Namespace: "Namespace3",
},
TypeMeta: metav1.TypeMeta{
APIVersion: "keda.sh/v1alpha1",
Kind: "ScaledObject",
},
Spec: v1alpha1.ScaledObjectSpec{
ScaleTargetRef: &v1alpha1.ScaleTarget{
Name: "Deployment2",
APIVersion: "apps/v1",
Kind: "",
},
},
}}},
}
tests := []struct {
name string
workloads []Workload
Expand Down Expand Up @@ -90,6 +131,14 @@ func TestFilterExcluded(t *testing.T) {
excludedWorkloads: util.RegexList{regexp.MustCompile("Deployment1")}, // exclude Deployment1
want: []Workload{ns1.deployment2},
},
{
name: "exclude scaled object scaled",
workloads: []Workload{ns3.deployment1, ns3.deployment2, ns3.scaledObject, ns1.deployment1, ns1.deployment2, ns2.deployment1},
includeLabels: nil,
excludedNamespaces: nil,
excludedWorkloads: nil,
want: []Workload{ns3.deployment1, ns3.scaledObject, ns1.deployment1, ns1.deployment2, ns2.deployment1},
},
}

for _, test := range tests {
Expand Down
4 changes: 2 additions & 2 deletions internal/pkg/scalable/workload.go
Original file line number Diff line number Diff line change
Expand Up @@ -62,14 +62,14 @@ type scalableResource interface {
GetName() string
// GetUID gets the uid of the workload
GetUID() types.UID
// GetObjectKind gets the ObjectKind of the workload
GetObjectKind() schema.ObjectKind
// GetLabels gets the labels of the workload
GetLabels() map[string]string
// GetCreationTimestamp gets the creation timestamp of the workload
GetCreationTimestamp() metav1.Time
// SetAnnotations sets the annotations on the resource. Changes won't be made on Kubernetes until update() is called
SetAnnotations(annotations map[string]string)
// GroupVersionKind gets the group version kind of the workload
GroupVersionKind() schema.GroupVersionKind
}

// Workload provides all functions needed to scale the workload.
Expand Down

0 comments on commit f6dbfc0

Please sign in to comment.