Skip to content

Commit

Permalink
fix: for update strategy add propogation from cluster to components (#…
Browse files Browse the repository at this point in the history
…1016)

Signed-off-by: Kara Guo <xinguo@google.com>
Co-authored-by: Kara Guo <xinguo@google.com>
  • Loading branch information
karaguo and Kara Guo committed Apr 4, 2023
1 parent 63e689b commit 12cb7d7
Show file tree
Hide file tree
Showing 9 changed files with 38 additions and 0 deletions.
5 changes: 5 additions & 0 deletions apis/goharbor.io/v1beta1/jobservice_types.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ import (
"errors"

harbormetav1 "github.com/goharbor/harbor-operator/apis/meta/v1alpha1"
appsv1 "k8s.io/api/apps/v1"
corev1 "k8s.io/api/core/v1"
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
)
Expand Down Expand Up @@ -88,6 +89,10 @@ type JobServiceSpec struct {

// +kubebuilder:validation:Optional
Storage *JobServiceStorageSpec `json:"storage,omitempty"`

// +kubebuilder:validation:Optional
// +kubebuilder:default="RollingUpdate"
UpdateStrategyType appsv1.DeploymentStrategyType `json:"updateStrategyType,omitempty"`
}

type JobServiceStorageSpec struct {
Expand Down
5 changes: 5 additions & 0 deletions apis/goharbor.io/v1beta1/registry_types.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ package v1beta1

import (
harbormetav1 "github.com/goharbor/harbor-operator/apis/meta/v1alpha1"
appsv1 "k8s.io/api/apps/v1"
corev1 "k8s.io/api/core/v1"
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
)
Expand Down Expand Up @@ -54,6 +55,10 @@ type RegistrySpec struct {

// +kubebuilder:validation:Optional
Trace *harbormetav1.TraceSpec `json:"trace,omitempty"`

// +kubebuilder:validation:Optional
// +kubebuilder:default="RollingUpdate"
UpdateStrategyType appsv1.DeploymentStrategyType `json:"updateStrategyType,omitempty"`
}

func (r *RegistrySpec) Default() {
Expand Down
6 changes: 6 additions & 0 deletions charts/harbor-operator/templates/crds.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -25515,6 +25515,9 @@ spec:
required:
- provider
type: object
updateStrategyType:
default: RollingUpdate
type: string
workerPool:
description: Configurations of worker pool
properties:
Expand Down Expand Up @@ -32915,6 +32918,9 @@ spec:
required:
- provider
type: object
updateStrategyType:
default: RollingUpdate
type: string
validation:
properties:
disabled:
Expand Down
1 change: 1 addition & 0 deletions controllers/goharbor/harbor/jobservice.go
Original file line number Diff line number Diff line change
Expand Up @@ -185,6 +185,7 @@ func (r *Reconciler) GetJobService(ctx context.Context, harbor *goharborv1.Harbo
Storage: &goharborv1.JobServiceStorageSpec{
ScanDataExports: r.JobServiceScanDataExportsStorage(ctx, harbor),
},
UpdateStrategyType: harbor.Spec.UpdateStrategyType,
},
}, nil
}
1 change: 1 addition & 0 deletions controllers/goharbor/harbor/registry.go
Original file line number Diff line number Diff line change
Expand Up @@ -283,6 +283,7 @@ func (r *Reconciler) GetRegistry(ctx context.Context, harbor *goharborv1.Harbor)
Proxy: harbor.GetComponentProxySpec(harbormetav1.RegistryComponent),
Network: harbor.Spec.Network,
Trace: harbor.Spec.Trace,
UpdateStrategyType: harbor.Spec.UpdateStrategyType,
},
}, nil
}
4 changes: 4 additions & 0 deletions controllers/goharbor/jobservice/deployments.go
Original file line number Diff line number Diff line change
Expand Up @@ -348,6 +348,10 @@ func (r *Reconciler) GetDeployment(ctx context.Context, jobservice *goharborv1.J
},
}

if len(jobservice.Spec.UpdateStrategyType) > 0 {
deploy.Spec.Strategy.Type = jobservice.Spec.UpdateStrategyType
}

jobservice.Spec.ComponentSpec.ApplyToDeployment(deploy)

return deploy, nil
Expand Down
4 changes: 4 additions & 0 deletions controllers/goharbor/registry/deployments.go
Original file line number Diff line number Diff line change
Expand Up @@ -329,6 +329,10 @@ func (r *Reconciler) GetDeployment(ctx context.Context, registry *goharborv1.Reg
},
}

if len(registry.Spec.UpdateStrategyType) > 0 {
deploy.Spec.Strategy.Type = registry.Spec.UpdateStrategyType
}

if err = r.ApplyStorageConfiguration(ctx, registry, deploy); err != nil {
return nil, errors.Wrap(err, "cannot apply storage configuration")
}
Expand Down
6 changes: 6 additions & 0 deletions manifests/cluster/deployment.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -25544,6 +25544,9 @@ spec:
required:
- provider
type: object
updateStrategyType:
default: RollingUpdate
type: string
workerPool:
description: Configurations of worker pool
properties:
Expand Down Expand Up @@ -45358,6 +45361,9 @@ spec:
required:
- provider
type: object
updateStrategyType:
default: RollingUpdate
type: string
validation:
properties:
disabled:
Expand Down
6 changes: 6 additions & 0 deletions manifests/harbor/deployment.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -25544,6 +25544,9 @@ spec:
required:
- provider
type: object
updateStrategyType:
default: RollingUpdate
type: string
workerPool:
description: Configurations of worker pool
properties:
Expand Down Expand Up @@ -32958,6 +32961,9 @@ spec:
required:
- provider
type: object
updateStrategyType:
default: RollingUpdate
type: string
validation:
properties:
disabled:
Expand Down

0 comments on commit 12cb7d7

Please sign in to comment.