Skip to content

Commit

Permalink
task executor interface
Browse files Browse the repository at this point in the history
Signed-off-by: Artem Bortnikov <[email protected]>
  • Loading branch information
aobort committed Nov 4, 2024
1 parent 1c3946d commit 0aea100
Show file tree
Hide file tree
Showing 8 changed files with 90 additions and 382 deletions.
20 changes: 0 additions & 20 deletions api/v1alpha1/common_types.go
Original file line number Diff line number Diff line change
Expand Up @@ -11,26 +11,6 @@ import (
"k8s.io/apimachinery/pkg/util/runtime"
)

type JobType string

const (
ScanBIOSVersionJobType JobType = "ScanBIOSVersion"
UpdateBIOSVersionJobType JobType = "UpdateBIOSVersion"
ApplyBIOSSettingsJobType JobType = "ApplyBiosSettings"
)

// RunningJobRef contains job type and reference to Job object
type RunningJobRef struct {
// Type reflects the type of the job.
// +kubebuilder:validation:Enum=ScanBIOSVersion;UpdateBIOSVersion;ApplyBiosSettings
// +required
Type JobType `json:"type"`

// JobRef contains the reference to the Job object.
// +required
JobRef v1.ObjectReference `json:"jobRef"`
}

// IP is an IP address.
type IP struct {
netip.Addr `json:"-"`
Expand Down
4 changes: 0 additions & 4 deletions api/v1alpha1/serverbios_types.go
Original file line number Diff line number Diff line change
Expand Up @@ -47,10 +47,6 @@ type ServerBIOSStatus struct {
// BIOS contains a bios version and settings.
// +optional
BIOS BIOSSettings `json:"bios,omitempty"`

// RunningJob reflects the invoked scan or update job running
// +optional
RunningJob RunningJobRef `json:"runningJob,omitempty"`
}

// +kubebuilder:object:root=true
Expand Down
19 changes: 1 addition & 18 deletions api/v1alpha1/zz_generated.deepcopy.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

77 changes: 0 additions & 77 deletions cmd/jobbios/main.go

This file was deleted.

15 changes: 12 additions & 3 deletions cmd/manager/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ import (
"os"
"time"

"github.com/ironcore-dev/metal-operator/internal/executor"
// Import all Kubernetes client auth plugins (e.g. Azure, GCP, OIDC, etc.)
// to ensure that exec-entrypoint and run can make use of them.
_ "k8s.io/client-go/plugin/pkg/client/auth"
Expand All @@ -28,7 +29,7 @@ import (
"github.com/ironcore-dev/metal-operator/internal/api/macdb"
"github.com/ironcore-dev/metal-operator/internal/controller"

Check failure on line 30 in cmd/manager/main.go

View workflow job for this annotation

GitHub Actions / lint

could not import github.com/ironcore-dev/metal-operator/internal/controller (-: # github.com/ironcore-dev/metal-operator/internal/controller
"github.com/ironcore-dev/metal-operator/internal/registry"
//+kubebuilder:scaffold:imports
// +kubebuilder:scaffold:imports
)

var (
Expand All @@ -39,7 +40,7 @@ var (
func init() {
utilruntime.Must(clientgoscheme.AddToScheme(scheme))
utilruntime.Must(metalv1alpha1.AddToScheme(scheme))
//+kubebuilder:scaffold:scheme
// +kubebuilder:scaffold:scheme
}

func main() {
Expand Down Expand Up @@ -241,6 +242,14 @@ func main() {
setupLog.Error(err, "unable to create controller", "controller", "ServerClaim")
os.Exit(1)
}
if err = (&controller.ServerBIOSReconciler{
Client: mgr.GetClient(),
Scheme: mgr.GetScheme(),
TaskExecutor: executor.New(mgr.GetClient(), insecure),
}).SetupWithManager(mgr); err != nil {
setupLog.Error(err, "unable to create controller", "controller", "ServerBIOS")
os.Exit(1)
}
if os.Getenv("ENABLE_WEBHOOKS") != "false" {
if err = (&metalv1alpha1.ServerClaim{}).SetupWebhookWithManager(mgr); err != nil {
setupLog.Error(err, "unable to create webhook", "webhook", "ServerClaim")
Expand All @@ -253,7 +262,7 @@ func main() {
os.Exit(1)
}
}
//+kubebuilder:scaffold:builder
// +kubebuilder:scaffold:builder

if err := mgr.AddHealthzCheck("healthz", healthz.Ping); err != nil {
setupLog.Error(err, "unable to set up health check")
Expand Down
57 changes: 0 additions & 57 deletions config/crd/bases/metal.ironcore.dev_serverbioses.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -105,63 +105,6 @@ spec:
for installed firmware was performed
format: date-time
type: string
runningJob:
description: RunningJob reflects the invoked scan or update job running
properties:
jobRef:
description: JobRef contains the reference to the Job object.
properties:
apiVersion:
description: API version of the referent.
type: string
fieldPath:
description: |-
If referring to a piece of an object instead of an entire object, this string
should contain a valid JSON/Go field access statement, such as desiredState.manifest.containers[2].
For example, if the object reference is to a container within a pod, this would take on a value like:
"spec.containers{name}" (where "name" refers to the name of the container that triggered
the event) or if no container name is specified "spec.containers[2]" (container with
index 2 in this pod). This syntax is chosen only to have some well-defined way of
referencing a part of an object.
type: string
kind:
description: |-
Kind of the referent.
More info: https://git.k8s.io/community/contributors/devel/sig-architecture/api-conventions.md#types-kinds
type: string
name:
description: |-
Name of the referent.
More info: https://kubernetes.io/docs/concepts/overview/working-with-objects/names/#names
type: string
namespace:
description: |-
Namespace of the referent.
More info: https://kubernetes.io/docs/concepts/overview/working-with-objects/namespaces/
type: string
resourceVersion:
description: |-
Specific resourceVersion to which this reference is made, if any.
More info: https://git.k8s.io/community/contributors/devel/sig-architecture/api-conventions.md#concurrency-control-and-consistency
type: string
uid:
description: |-
UID of the referent.
More info: https://kubernetes.io/docs/concepts/overview/working-with-objects/names/#uids
type: string
type: object
x-kubernetes-map-type: atomic
type:
description: Type reflects the type of the job.
enum:
- ScanBIOSVersion
- UpdateBIOSVersion
- ApplyBiosSettings
type: string
required:
- jobRef
- type
type: object
type: object
type: object
served: true
Expand Down
Loading

0 comments on commit 0aea100

Please sign in to comment.