support custom pvc name

This commit is contained in:
凡羊羊 2020-03-04 17:24:54 +08:00
parent 27f37adb5f
commit 55ed4b8921
5 changed files with 23 additions and 10 deletions

View File

@ -72,6 +72,8 @@ type Response struct {
//Request build input
type Request struct {
GRDataPVCName string
CachePVCName string
TenantID string
SourceDir string
CacheDir string

View File

@ -297,7 +297,7 @@ func (s *slugBuild) runBuildJob(re *Request) error {
Name: "slug",
VolumeSource: corev1.VolumeSource{
PersistentVolumeClaim: &corev1.PersistentVolumeClaimVolumeSource{
ClaimName: "grdata",
ClaimName: s.re.GRDataPVCName,
},
},
},
@ -305,7 +305,7 @@ func (s *slugBuild) runBuildJob(re *Request) error {
Name: "app",
VolumeSource: corev1.VolumeSource{
PersistentVolumeClaim: &corev1.PersistentVolumeClaimVolumeSource{
ClaimName: "cache",
ClaimName: s.re.CachePVCName,
},
},
},
@ -443,6 +443,7 @@ func getJob(ctx context.Context, podChan chan struct{}, clientset kubernetes.Int
job, _ = evt.Object.(*batchv1.Job)
if job.Name == name {
logrus.Debugf("job: %s status is: %+v ", name, job.Status)
// active means this job has bound a pod, can't ensure this pod's status is running or creating or initing or some status else
if job.Status.Active > 0 {
once.Do(func() {
logrus.Debug("job is ready")

View File

@ -48,6 +48,8 @@ import (
type SourceCodeBuildItem struct {
Namespace string `json:"namespace"`
TenantName string `json:"tenant_name"`
GRDataPVCName string `json:"gr_data_pvc_name"`
CachePVCName string `json:"cache_pvc_name"`
ServiceAlias string `json:"service_alias"`
Action string `json:"action"`
DestImage string `json:"dest_image"`
@ -249,6 +251,8 @@ func (i *SourceCodeBuildItem) codeBuild() (*build.Response, error) {
KubeClient: i.KubeClient,
HostAlias: hostAlias,
Ctx: i.Ctx,
GRDataPVCName: i.GRDataPVCName,
CachePVCName: i.CachePVCName,
}
res, err := codeBuild.Build(buildReq)
return res, err

View File

@ -319,6 +319,8 @@ func (e *exectorManager) buildFromSourceCode(task *pb.TaskMessage) {
i.RbdNamespace = e.cfg.RbdNamespace
i.RbdRepoName = e.cfg.RbdRepoName
i.Ctx = e.ctx
i.CachePVCName = e.cfg.CachePVCName
i.GRDataPVCName = e.cfg.GRDataPVCName
i.Logger.Info("Build app version from source code start", map[string]string{"step": "builder-exector", "status": "starting"})
start := time.Now()
defer event.GetManager().ReleaseLogger(i.Logger)

View File

@ -51,6 +51,8 @@ type Config struct {
LogPath string
RbdNamespace string
RbdRepoName string
GRDataPVCName string
CachePVCName string
}
//Builder builder server
@ -90,6 +92,8 @@ func (a *Builder) AddFlags(fs *pflag.FlagSet) {
fs.StringVar(&a.LogPath, "log-path", "/grdata/logs", "Where Docker log files and event log files are stored.")
fs.StringVar(&a.RbdNamespace, "rbd-namespace", "rbd-system", "rbd component namespace")
fs.StringVar(&a.RbdRepoName, "rbd-repo", "rbd-repo", "rbd component repo's name")
fs.StringVar(&a.GRDataPVCName, "pvc-grdata-name", "grdata", "pvc name of grdata")
fs.StringVar(&a.CachePVCName, "pvc-cache-name", "cache", "pvc name of cache")
}