Skip to content

Commit

Permalink
Address comments for PR #5
Browse files Browse the repository at this point in the history
- Add `image-pull-policy` in the ConfigMap to specify the
  imagePullPolicy of the job's pod
- Add  `pod-checking-interval` in the ConfigMap to set
  the pod checking interval
- Update the Group and Kind of the CRD to
  `foundation-model-stack.github.com.github.com` and
  `LMEvalJob`
- Refine the `checkScheduledPod` func of the controller
  based on the comment

Signed-off-by: Yihong Wang <yh.wang@ibm.com>
  • Loading branch information
yhwang committed Jun 25, 2024
1 parent 9bac6f9 commit 75ec4f7
Show file tree
Hide file tree
Showing 24 changed files with 233 additions and 240 deletions.
4 changes: 2 additions & 2 deletions PROJECT
Original file line number Diff line number Diff line change
Expand Up @@ -13,8 +13,8 @@ resources:
namespaced: true
controller: true
domain: github.com
group: lm-eval-service
kind: EvalJob
group: foundation-model-stack.github.com
kind: LMEvalJob
path: github.com/foundation-model-stack/fms-lm-eval-service/api/v1beta1
version: v1beta1
webhooks:
Expand Down
12 changes: 6 additions & 6 deletions api/v1beta1/groupversion_info.go
Original file line number Diff line number Diff line change
Expand Up @@ -14,9 +14,9 @@ See the License for the specific language governing permissions and
limitations under the License.
*/

// Package v1beta1 contains API Schema definitions for the lm-eval-service v1beta1 API group
// Package v1beta1 contains API Schema definitions for the foundation-model-stack.github.com.github.com v1beta1 API group
// +kubebuilder:object:generate=true
// +groupName=lm-eval-service.github.com
// +groupName=foundation-model-stack.github.com.github.com
package v1beta1

import (
Expand All @@ -25,15 +25,15 @@ import (
)

const (
GroupName = "lm-eval-service.github.com"
GroupName = "foundation-model-stack.github.com.github.com"
Version = "v1beta1"
KindName = "EvalJob"
FinalizerName = "lm-eval-service.github.com/finalizer"
KindName = "LMEvalJob"
FinalizerName = "lm-eval-job.foundation-model-stack.github.com.github.com/finalizer"
)

var (
// GroupVersion is group version used to register these objects
GroupVersion = schema.GroupVersion{Group: "lm-eval-service.github.com", Version: "v1beta1"}
GroupVersion = schema.GroupVersion{Group: GroupName, Version: Version}

// SchemeBuilder is used to add go types to the GroupVersionKind scheme
SchemeBuilder = &scheme.Builder{GroupVersion: GroupVersion}
Expand Down
24 changes: 12 additions & 12 deletions api/v1beta1/evaljob_types.go → api/v1beta1/lmevaljob_types.go
Original file line number Diff line number Diff line change
Expand Up @@ -59,8 +59,8 @@ type Arg struct {
Value string `json:"value,omitempty"`
}

// EvalJobSpec defines the desired state of EvalJob
type EvalJobSpec struct {
// LMEvalJobSpec defines the desired state of LMEvalJob
type LMEvalJobSpec struct {
// INSERT ADDITIONAL SPEC FIELDS - desired state of cluster
// Important: Run "make" to regenerate code after modifying this file

Expand Down Expand Up @@ -88,8 +88,8 @@ type EvalJobSpec struct {
LogSamples *bool `json:"logSamples,omitempty"`
}

// EvalJobStatus defines the observed state of EvalJob
type EvalJobStatus struct {
// LMEvalJobStatus defines the observed state of LMEvalJob
type LMEvalJobStatus struct {
// Important: Run "make" to regenerate code after modifying this file

// The name of the Pod that runs the evaluation job
Expand Down Expand Up @@ -118,24 +118,24 @@ type EvalJobStatus struct {
// +kubebuilder:object:root=true
// +kubebuilder:subresource:status

// EvalJob is the Schema for the evaljobs API
type EvalJob struct {
// LMEvalJob is the Schema for the lmevaljobs API
type LMEvalJob struct {
metav1.TypeMeta `json:",inline"`
metav1.ObjectMeta `json:"metadata,omitempty"`

Spec EvalJobSpec `json:"spec,omitempty"`
Status EvalJobStatus `json:"status,omitempty"`
Spec LMEvalJobSpec `json:"spec,omitempty"`
Status LMEvalJobStatus `json:"status,omitempty"`
}

// +kubebuilder:object:root=true

// EvalJobList contains a list of EvalJob
type EvalJobList struct {
// LMEvalJobList contains a list of LMEvalJob
type LMEvalJobList struct {
metav1.TypeMeta `json:",inline"`
metav1.ListMeta `json:"metadata,omitempty"`
Items []EvalJob `json:"items"`
Items []LMEvalJob `json:"items"`
}

func init() {
SchemeBuilder.Register(&EvalJob{}, &EvalJobList{})
SchemeBuilder.Register(&LMEvalJob{}, &LMEvalJobList{})
}
38 changes: 17 additions & 21 deletions api/v1beta1/evaljob_webhook.go → api/v1beta1/lmevaljob_webhook.go
Original file line number Diff line number Diff line change
Expand Up @@ -33,66 +33,62 @@ import (
var evaljoblog = logf.Log.WithName("evaljob-resource")

// SetupWebhookWithManager will setup the manager to manage the webhooks
func (r *EvalJob) SetupWebhookWithManager(mgr ctrl.Manager) error {
func (r *LMEvalJob) SetupWebhookWithManager(mgr ctrl.Manager) error {
return ctrl.NewWebhookManagedBy(mgr).
For(r).
Complete()
}

// TODO(user): EDIT THIS FILE! THIS IS SCAFFOLDING FOR YOU TO OWN!
// +kubebuilder:webhook:path=/mutate-foundation-model-stack-github-com-github-com-v1beta1-lmevaljob,mutating=true,failurePolicy=fail,sideEffects=None,groups=foundation-model-stack.github.com.github.com,resources=lmevaljobs,verbs=create;update,versions=v1beta1,name=mlmevaljob.kb.io,admissionReviewVersions=v1

// +kubebuilder:webhook:path=/mutate-lm-eval-service-github-com-v1beta1-evaljob,mutating=true,failurePolicy=fail,sideEffects=None,groups=lm-eval-service.github.com,resources=evaljobs,verbs=create;update,versions=v1beta1,name=mevaljob.kb.io,admissionReviewVersions=v1

var _ webhook.Defaulter = &EvalJob{}
var _ webhook.Defaulter = &LMEvalJob{}

// Default implements webhook.Defaulter so a webhook will be registered for the type
func (r *EvalJob) Default() {
func (r *LMEvalJob) Default() {
evaljoblog.Info("default", "name", r.Name)

// TODO(user): fill in your defaulting logic.
}

// TODO(user): change verbs to "verbs=create;update;delete" if you want to enable deletion validation.
// NOTE: The 'path' attribute must follow a specific pattern and should not be modified directly here.
// Modifying the path for an invalid path can cause API server errors; failing to locate the webhook.
// +kubebuilder:webhook:path=/validate-lm-eval-service-github-com-v1beta1-evaljob,mutating=false,failurePolicy=fail,sideEffects=None,groups=lm-eval-service.github.com,resources=evaljobs,verbs=create;update,versions=v1beta1,name=vevaljob.kb.io,admissionReviewVersions=v1
// +kubebuilder:webhook:path=/validate-foundation-model-stack-github-com-github-com-v1beta1-lmevaljob,mutating=false,failurePolicy=fail,sideEffects=None,groups=foundation-model-stack.github.com.github.com,resources=lmevaljobs,verbs=create;update,versions=v1beta1,name=vlmevaljob.kb.io,admissionReviewVersions=v1

var _ webhook.Validator = &EvalJob{}
var _ webhook.Validator = &LMEvalJob{}

// ValidateCreate implements webhook.Validator so a webhook will be registered for the type
func (r *EvalJob) ValidateCreate() (admission.Warnings, error) {
func (r *LMEvalJob) ValidateCreate() (admission.Warnings, error) {
evaljoblog.Info("validate create", "name", r.Name)

// TODO(user): fill in your validation logic upon object creation.
return nil, nil
return nil, r.ValidateJob()
}

// ValidateUpdate implements webhook.Validator so a webhook will be registered for the type
func (r *EvalJob) ValidateUpdate(old runtime.Object) (admission.Warnings, error) {
func (r *LMEvalJob) ValidateUpdate(old runtime.Object) (admission.Warnings, error) {
evaljoblog.Info("validate update", "name", r.Name)

// TODO(user): fill in your validation logic upon object update.
return nil, nil
return nil, r.ValidateJob()
}

// ValidateDelete implements webhook.Validator so a webhook will be registered for the type
func (r *EvalJob) ValidateDelete() (admission.Warnings, error) {
func (r *LMEvalJob) ValidateDelete() (admission.Warnings, error) {
evaljoblog.Info("validate delete", "name", r.Name)

// TODO(user): fill in your validation logic upon object deletion.
return nil, nil
}

func (r *EvalJob) ValidateJob() error {
func (r *LMEvalJob) ValidateJob() error {
var allErrs field.ErrorList
if err := r.ValidateLimit(); err != nil {
allErrs = append(allErrs, err)
}

if len(allErrs) == 0 {
return nil
}
return apierrors.NewInvalid(
schema.GroupKind{Group: GroupName, Kind: KindName}, r.Name, allErrs)
}

func (r *EvalJob) ValidateLimit() *field.Error {
func (r *LMEvalJob) ValidateLimit() *field.Error {
if r.Spec.Limit == "" {
return nil
}
Expand Down
File renamed without changes.
2 changes: 1 addition & 1 deletion api/v1beta1/webhook_suite_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -113,7 +113,7 @@ var _ = BeforeSuite(func() {
})
Expect(err).NotTo(HaveOccurred())

err = (&EvalJob{}).SetupWebhookWithManager(mgr)
err = (&LMEvalJob{}).SetupWebhookWithManager(mgr)
Expect(err).NotTo(HaveOccurred())

// +kubebuilder:scaffold:webhook
Expand Down
38 changes: 19 additions & 19 deletions api/v1beta1/zz_generated.deepcopy.go

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

Loading

0 comments on commit 75ec4f7

Please sign in to comment.