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 958928c
Show file tree
Hide file tree
Showing 8 changed files with 123 additions and 416 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
8 changes: 0 additions & 8 deletions api/v1alpha1/serverbios_types.go
Original file line number Diff line number Diff line change
Expand Up @@ -40,17 +40,9 @@ type BIOSSettings struct {

// ServerBIOSStatus defines the observed state of ServerBIOS
type ServerBIOSStatus struct {
// LastScanTime reflects the timestamp when the scanning for installed firmware was performed
// +optional
LastScanTime metav1.Time `json:"lastScanTime,omitempty"`

// 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
20 changes: 1 addition & 19 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.

61 changes: 37 additions & 24 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,34 +40,36 @@ var (
func init() {
utilruntime.Must(clientgoscheme.AddToScheme(scheme))
utilruntime.Must(metalv1alpha1.AddToScheme(scheme))
//+kubebuilder:scaffold:scheme
// +kubebuilder:scaffold:scheme
}

func main() {
var (
metricsAddr string
enableLeaderElection bool
probeAddr string
secureMetrics bool
enableHTTP2 bool
macPrefixesFile string
insecure bool
managerNamespace string
probeImage string
probeOSImage string
registryPort int
registryProtocol string
registryURL string
registryResyncInterval time.Duration
webhookPort int
enforceFirstBoot bool
enforcePowerOff bool
serverResyncInterval time.Duration
powerPollingInterval time.Duration
powerPollingTimeout time.Duration
discoveryTimeout time.Duration
metricsAddr string
enableLeaderElection bool
probeAddr string
secureMetrics bool
enableHTTP2 bool
macPrefixesFile string
insecure bool
managerNamespace string
probeImage string
probeOSImage string
registryPort int
registryProtocol string
registryURL string
registryResyncInterval time.Duration
webhookPort int
enforceFirstBoot bool
enforcePowerOff bool
serverResyncInterval time.Duration
powerPollingInterval time.Duration
powerPollingTimeout time.Duration
discoveryTimeout time.Duration
serverBIOSResyncInterval time.Duration
)

flag.DurationVar(&serverBIOSResyncInterval, "server-bios-resync-interval", 10*time.Second, "Timeout for BIOS resync")
flag.DurationVar(&discoveryTimeout, "discovery-timeout", 30*time.Minute, "Timeout for discovery boot")
flag.DurationVar(&powerPollingInterval, "power-polling-interval", 5*time.Second,
"Interval between polling power state")
Expand Down Expand Up @@ -241,6 +244,16 @@ func main() {
setupLog.Error(err, "unable to create controller", "controller", "ServerClaim")
os.Exit(1)
}
if err = (&controller.ServerBIOSReconciler{
Client: mgr.GetClient(),
Scheme: mgr.GetScheme(),
// TODO define the executor to use by command-line flag
TaskExecutor: executor.New(mgr.GetClient(), insecure),
RequeueInterval: serverBIOSResyncInterval,
}).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 +266,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
62 changes: 0 additions & 62 deletions config/crd/bases/metal.ironcore.dev_serverbioses.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -100,68 +100,6 @@ spec:
required:
- version
type: object
lastScanTime:
description: LastScanTime reflects the timestamp when the scanning
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 958928c

Please sign in to comment.