Skip to content

Commit

Permalink
Release 0.3.0
Browse files Browse the repository at this point in the history
- Versions bump for K8s 1.30 and Go 1.22.
- Security patches.
- Dependency Updates
- Enabling Power KPIs in Custom Resource Definitions (CRDs).
- Logs improvements.
- Added timeout to HTTP clients.
- Test timeout fixes.
- Comprehensive Framework Testing.
- Fine tuning on horizontal scaling model.
- Increase data range usage for CPU rightsizing model.
- Resource type changed to Int64.
- Plugins refactoring.
- Documentation updates.

Co-authored-by: tmetsch [email protected]
Co-authored-by: togashidm [email protected]
Co-authored-by: kcollinsInt [email protected]
Co-authored-by: andrepcb [email protected]
  • Loading branch information
togashidm authored and tmetsch committed Sep 3, 2024
1 parent fb972f0 commit f59eaea
Show file tree
Hide file tree
Showing 107 changed files with 3,359 additions and 1,282 deletions.
20 changes: 10 additions & 10 deletions .github/workflows/sca.yml
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ jobs:
name: Shellcheck
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- uses: actions/checkout@v4
- run: |
wget -q https://github.com/koalaman/shellcheck/releases/download/stable/shellcheck-stable.linux.x86_64.tar.xz
tar -xvf shellcheck-stable.linux.x86_64.tar.xz
Expand All @@ -21,18 +21,18 @@ jobs:
runs-on: ubuntu-latest
name: Hadolint
steps:
- uses: actions/checkout@v3
- uses: actions/checkout@v4
- run: wget -q https://github.com/hadolint/hadolint/releases/download/v2.12.0/hadolint-Linux-x86_64 -O hadolint; chmod +x hadolint ; find . -type f \( -name "Dockerfile*" \) -print0 | xargs -n 1 -0 ./hadolint ;
gofmt-imports:
runs-on: ubuntu-latest
name: Go Fmt and Go Import
steps:
- uses: actions/checkout@v3
- uses: actions/setup-go@v3
- uses: actions/checkout@v4
- uses: actions/setup-go@v5
with:
go-version: 1.19
go-version-file: 'go.mod'
- run: |
go install golang.org/x/tools/cmd/goimports@v0.6.0 && goimports -l . && gofmt -l .
go install golang.org/x/tools/cmd/goimports@v0.20.0 && goimports -l . && gofmt -l .
shell: bash
golangci:
permissions:
Expand All @@ -41,12 +41,12 @@ jobs:
runs-on: ubuntu-latest
name: lint
steps:
- uses: actions/setup-go@v3
- uses: actions/checkout@v4
- uses: actions/setup-go@v5
with:
go-version: 1.19
- uses: actions/checkout@v3
go-version-file: 'go.mod'
- name: golangci-lint
run: |
go install github.com/golangci/golangci-lint/cmd/golangci-lint@v1.51.2
go install github.com/golangci/golangci-lint/cmd/golangci-lint@v1.57.2
make golangci-lint
shell: bash
14 changes: 7 additions & 7 deletions .github/workflows/test-build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -10,30 +10,30 @@ jobs:
build:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- uses: actions/checkout@v4
- name: Set up Go
uses: actions/setup-go@v3
uses: actions/setup-go@v5
with:
go-version-file: 'go.mod'
- name: Build
run: make build && make build-plugins
utests:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- uses: actions/checkout@v4
- name: Set up Go
uses: actions/setup-go@v3
uses: actions/setup-go@v5
with:
go-version-file: 'go.mod'
- name: Unit test
run: make utest
race:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- uses: actions/checkout@v4
- name: Set up Go
uses: actions/setup-go@v3
uses: actions/setup-go@v5
with:
go-version-file: 'go.mod'
- name: Test race
run: go test -count=1 -race ./...
run: go test -count=1 -parallel 1 -race ./...
2 changes: 1 addition & 1 deletion Dockerfile
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
# Copyright (c) 2022 Intel Corporation
# SPDX-License-Identifier: Apache-2.0

FROM golang:1.19 AS build
FROM golang:1.22 AS build

WORKDIR /app

Expand Down
4 changes: 2 additions & 2 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ RMPOD_PLUGIN=rm_pod
RDT_PLUGIN=rdt
CPU_PLUGIN=cpu_scale
GO_CILINT_CHECKERS=errcheck,goimports,gosec,gosimple,govet,ineffassign,nilerr,revive,staticcheck,unused
DOCKER_IMAGE_VERSION=0.2.0
DOCKER_IMAGE_VERSION=0.3.0

api:
hack/generate_code.sh
Expand Down Expand Up @@ -57,7 +57,7 @@ prepare-build:
go mod tidy

utest:
go test -count=1 -v ./...
go test -count=1 -parallel 1 -v ./...

test:
hack/run_test.sh
Expand Down
6 changes: 3 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -67,9 +67,9 @@ Step 3) deploy the actuators of interest using:

These steps should be followed by setting up your default profiles (if needed).

We recommend the usage of a service mesh like [Linkerd](https://linkerd.io/) or [Istio](https://istio.io/) to ensure
encryption and monitoring capabilities for the subcomponents of the planning framework themselves. After creating the
namespace, enable auto-injection; For Linkerd do:
We recommend the usage of a service mesh like [Linkerd](https://linkerd.io/) or [Istio](https://istio.io/) to ensure
robust authentication, encryption and monitoring capabilities for the subcomponents of the planning framework
themselves. After creating the namespace, <enable auto-injection; For Linkerd do:

$ k annotate ns ido linkerd.io/inject=enabled

Expand Down
2 changes: 1 addition & 1 deletion artefacts/deploy/manifest.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -199,7 +199,7 @@ spec:
serviceAccountName: planner-service-account
containers:
- name: planner
image: 127.0.0.1:5000/planner:0.2.0
image: 127.0.0.1:5000/planner:0.3.0
ports:
- containerPort: 33333
imagePullPolicy: Always
Expand Down
5 changes: 3 additions & 2 deletions artefacts/intents_crds_v1alpha1.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -72,7 +72,7 @@ spec:
type: string
description: "Target intents."
jsonPath: .spec.objectives[*].targetName
# BUG: https://github.com/kubernetes/kubectl/issues/517
# Won't fix: https://github.com/kubernetes/kubectl/issues/517
- name: Prio
type: number
description: "Priority."
Expand Down Expand Up @@ -122,7 +122,8 @@ spec:
- availability
- latency
- throughput
# TODO: power
- power
# TODO: carbon
# TODO: assure cardinality: 0..1 avail & throughput, 0..* latency.
props:
type: object
Expand Down
3 changes: 2 additions & 1 deletion cmd/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,8 @@ func main() {
defer planner.Stop()

// This is main controller.
c := controller.NewController(cfg, k8sClient, podInformerFactory.Core().V1().Pods())
tracer := controller.NewMongoTracer(cfg.Generic.MongoEndpoint)
c := controller.NewController(cfg, tracer, k8sClient, podInformerFactory.Core().V1().Pods())
c.SetPlanner(planner)

// 1/3 bring up the monitor for the KPIProfiles.
Expand Down
24 changes: 12 additions & 12 deletions docs/actuators.md
Original file line number Diff line number Diff line change
Expand Up @@ -22,18 +22,18 @@ The planner uses the actuators for a set of tasks:

## Interface

The interface an actuator needs to implement is defined [here](../pkg/planner/actuators/interface.go).

// ActuatorPlugin defines the interface for the actuators.
type ActuatorPlugin interface {
Plugin
// NextState should return a set of potential follow-up states for a given state if this actuator would potentially be used.
NextState(state *common.State, goal *common.State, profiles map[string]common.Profile) ([]common.State, []float64, []planner.Action)
// Perform should perform those actions of the plan that it is in charge off.
Perform(state *common.State, plan []planner.Action)
// Effect should (optionally) recalculate the effect this actuator has for ALL objectives for this workload.
Effect(state *common.State, profiles map[string]common.Profile)
}
The interface an actuator needs to implement is defined [here](../pkg/planner/actuators/types.go).

// Actuator defines the interface for the actuators.
type Actuator interface {
Plugin
// NextState should return a set of potential follow-up states for a given state if this actuator would potentially be used.
NextState(state *common.State, goal *common.State, profiles map[string]common.Profile) ([]common.State, []float64, []planner.Action)
// Perform should perform those actions of the plan that it is in charge off.
Perform(state *common.State, plan []planner.Action)
// Effect should (optionally) recalculate the effect this actuator has for ALL objectives for this workload.
Effect(state *common.State, profiles map[string]common.Profile)
}

Each actuator will have a unique name and a group assignment.

Expand Down
75 changes: 6 additions & 69 deletions docs/pluggability.md
Original file line number Diff line number Diff line change
Expand Up @@ -20,74 +20,11 @@ After successful registration, the planner will call the functions **_NextState_
[gRPC](https://grpc.io/). The bi-directional streaming is implemented on **_NextState_** which has demonstrated an
improvement on the planner's performance.

## Implementing new plugins
## Using GRPC to launch an actuator

To implement a new actuator plugin, the developer needs to follow these steps:
The [plugins_helper](../plugins/plugins_helper.go) provides a function that can be used to connect an actuator with the
rest of the framework. To do so, the user will need to provide the GRPC endpoint and port for the actuator as well as
for the plugin manager:

1. Implement the new Actuator callbacks (NextState, Perform and Effect).
2. Create a plugin stub by calling **_plugins.NewActuatorPluginStub_**.
3. Set actuator callbacks for the stub.
4. Start the Plugin server (listens for actuator gRPC calls).
5. Register with the plugin-manager.
6. Wait for termination.
7. Stop the plugin stub.

Skeleton code for an actuator plugin can hence look like this:

package main

import (
"os"
"os/signal"

plugins "github.com/intel/intent-driven-orchestrationpkg/api/plugins/v1alpha1"
"github.com/intel/intent-driven-orchestration/pkg/common"
"github.com/intel/intent-driven-orchestration/pkg/controller"
"github.com/intel/intent-driven-orchestration/pkg/planner"
"github.com/intel/intent-driven-orchestration/pkg/planner/actuators"
"k8s.io/klog/v2"
...
)

func NextState(state *common.State, goal *common.State, profiles map[string]common.Profile)
([] common.State, []float64, []planner.Action) {
klog.V(1).InfoS("Invoked NextState() callback")
return ...
}

func Perform(state *common.State, plan []planner.Action) {
klog.V(1).InfoS("Invoked Perform() callback")
return ...
}

func (s *RmpodPluginHandler) Effect(state *common.State, profiles map[string]common.Profile) {
klog.V(1).InfoS("Invoked Effect() callback")
return ...
}

func main() {
klog.InitFlags(nil)
...
stub := plugins.NewActuatorPluginStub("plugin name", "plugin endpoint", some-port, "plugin-manager-service", 33333)
stub.SetNextStateFunc(NextState)
stub.SetPerformFunc(Perform)
stub.SetEffectFunc(Effect)
err = stub.Start()
if err != nil {
klog.Fatalf("Error starting plugin server: %s", err)
}
err = stub.Register()
if err != nil {
klog.Fatalf("Error registering plugin: %s", err)
}
signalChan := make(chan os.Signal, 1)
signal.Notify(signalChan, os.Interrupt)
<-signalChan
err = stub.Stop()
if err != nil {
klog.Fatalf("Error stopping plugin server: %s", err)
}
}

Example usage in the current set of supported plugins can be found in the plugins folder under the root directory of the
repository.
actuator := <...>
plugins.StartActuatorPlugin(actuator, "localhost", 12345, "localhost", "33333")
72 changes: 38 additions & 34 deletions go.mod
Original file line number Diff line number Diff line change
@@ -1,69 +1,73 @@
module github.com/intel/intent-driven-orchestration

go 1.19
go 1.22.0

require (
github.com/stretchr/testify v1.8.1
go.mongodb.org/mongo-driver v1.11.2
google.golang.org/grpc v1.56.3
github.com/stretchr/testify v1.9.0
go.mongodb.org/mongo-driver v1.15.0
google.golang.org/grpc v1.63.2
google.golang.org/protobuf v1.33.0
k8s.io/api v0.26.1
k8s.io/apimachinery v0.26.1
k8s.io/client-go v0.26.1
k8s.io/code-generator v0.26.1
k8s.io/klog/v2 v2.90.0
k8s.io/api v0.30.0
k8s.io/apimachinery v0.30.0
k8s.io/client-go v0.30.0
k8s.io/code-generator v0.30.0
k8s.io/klog/v2 v2.120.1
)

require (
github.com/google/gnostic-models v0.6.8 // indirect
github.com/google/uuid v1.6.0 // indirect
google.golang.org/genproto/googleapis/rpc v0.0.0-20240227224415-6ceb2ff114de // indirect
k8s.io/gengo/v2 v2.0.0-20240228010128-51d4e06bde70 // indirect
)

require (
github.com/davecgh/go-spew v1.1.1 // indirect
github.com/emicklei/go-restful/v3 v3.9.0 // indirect
github.com/emicklei/go-restful/v3 v3.11.0 // indirect
github.com/evanphx/json-patch v4.12.0+incompatible // indirect
github.com/go-logr/logr v1.2.3 // indirect
github.com/go-openapi/jsonpointer v0.19.5 // indirect
github.com/go-openapi/jsonreference v0.20.0 // indirect
github.com/go-openapi/swag v0.19.14 // indirect
github.com/go-logr/logr v1.4.1 // indirect
github.com/go-openapi/jsonpointer v0.19.6 // indirect
github.com/go-openapi/jsonreference v0.20.2 // indirect
github.com/go-openapi/swag v0.22.3 // indirect; indirectgo mod tidy
github.com/gogo/protobuf v1.3.2 // indirect
github.com/golang/protobuf v1.5.3 // indirect
github.com/golang/protobuf v1.5.4 // indirect
github.com/golang/snappy v0.0.1 // indirect
github.com/google/gnostic v0.5.7-v3refs // indirect
github.com/google/go-cmp v0.5.9 // indirect
github.com/google/gofuzz v1.1.0 // indirect
github.com/google/go-cmp v0.6.0 // indirect
github.com/google/gofuzz v1.2.0 // indirect
github.com/imdario/mergo v0.3.6 // indirect
github.com/josharian/intern v1.0.0 // indirect
github.com/json-iterator/go v1.1.12 // indirect
github.com/klauspost/compress v1.13.6 // indirect
github.com/mailru/easyjson v0.7.6 // indirect
github.com/mailru/easyjson v0.7.7 // indirect
github.com/modern-go/concurrent v0.0.0-20180306012644-bacd9c7ef1dd // indirect
github.com/modern-go/reflect2 v1.0.2 // indirect
github.com/montanaflynn/stats v0.0.0-20171201202039-1bf9dbcd8cbe // indirect
github.com/munnerz/goautoneg v0.0.0-20191010083416-a7dc8b61c822 // indirect
github.com/pkg/errors v0.9.1 // indirect
github.com/pmezard/go-difflib v1.0.0 // indirect
github.com/spf13/pflag v1.0.5 // indirect
github.com/stretchr/objx v0.5.0 // indirect
github.com/stretchr/objx v0.5.2 // indirect
github.com/xdg-go/pbkdf2 v1.0.0 // indirect
github.com/xdg-go/scram v1.1.1 // indirect
github.com/xdg-go/stringprep v1.0.3 // indirect
github.com/xdg-go/scram v1.1.2 // indirect
github.com/xdg-go/stringprep v1.0.4 // indirect
github.com/youmark/pkcs8 v0.0.0-20181117223130-1be2e3e5546d // indirect
golang.org/x/crypto v0.21.0 // indirect
golang.org/x/mod v0.8.0 // indirect
golang.org/x/mod v0.15.0 // indirect
golang.org/x/net v0.23.0 // indirect
golang.org/x/oauth2 v0.7.0 // indirect
golang.org/x/sync v0.1.0 // indirect
golang.org/x/oauth2 v0.17.0 // indirect
golang.org/x/sync v0.6.0 // indirect
golang.org/x/sys v0.18.0 // indirect
golang.org/x/term v0.18.0 // indirect
golang.org/x/text v0.14.0 // indirect
golang.org/x/time v0.0.0-20220210224613-90d013bbcef8 // indirect
golang.org/x/tools v0.6.0 // indirect
google.golang.org/appengine v1.6.7 // indirect
google.golang.org/genproto v0.0.0-20230410155749-daa745c078e1 // indirect
golang.org/x/time v0.3.0 // indirect
golang.org/x/tools v0.18.0 // indirect
google.golang.org/appengine v1.6.8 // indirect
gopkg.in/inf.v0 v0.9.1 // indirect
gopkg.in/yaml.v2 v2.4.0 // indirect
gopkg.in/yaml.v3 v3.0.1 // indirect
k8s.io/gengo v0.0.0-20220902162205-c0856e24416d // indirect
k8s.io/kube-openapi v0.0.0-20221012153701-172d655c2280 // indirect
k8s.io/utils v0.0.0-20221107191617-1a15be271d1d // indirect
sigs.k8s.io/json v0.0.0-20220713155537-f223a00ba0e2 // indirect
sigs.k8s.io/structured-merge-diff/v4 v4.2.3 // indirect
k8s.io/kube-openapi v0.0.0-20240228011516-70dd3763d340 // indirect
k8s.io/utils v0.0.0-20230726121419-3b25d923346b // indirect
sigs.k8s.io/json v0.0.0-20221116044647-bc3834ca7abd // indirect
sigs.k8s.io/structured-merge-diff/v4 v4.4.1 // indirect
sigs.k8s.io/yaml v1.3.0 // indirect
)
Loading

0 comments on commit f59eaea

Please sign in to comment.