Skip to content

Commit

Permalink
Move CharmModifiedVersion from DeploymentInfo to ProvisioningInfo;
Browse files Browse the repository at this point in the history
  • Loading branch information
ycliuhw committed Jul 20, 2020
1 parent c572dfa commit 2267270
Show file tree
Hide file tree
Showing 5 changed files with 56 additions and 56 deletions.
38 changes: 19 additions & 19 deletions api/caasunitprovisioner/client.go
Original file line number Diff line number Diff line change
Expand Up @@ -162,21 +162,21 @@ func (c *Client) WatchPodSpec(application string) (watcher.NotifyWatcher, error)

// DeploymentInfo holds deployment info from charm metadata.
type DeploymentInfo struct {
DeploymentType string
ServiceType string
CharmModifiedVersion int `json:"charm-modified-version"`
DeploymentType string
ServiceType string
}

// ProvisioningInfo holds unit provisioning info.
type ProvisioningInfo struct {
DeploymentInfo DeploymentInfo
PodSpec string
RawK8sSpec string
Constraints constraints.Value
Filesystems []storage.KubernetesFilesystemParams
Devices []devices.KubernetesDeviceParams
Tags map[string]string
OperatorImagePath string
DeploymentInfo DeploymentInfo
PodSpec string
RawK8sSpec string
Constraints constraints.Value
Filesystems []storage.KubernetesFilesystemParams
Devices []devices.KubernetesDeviceParams
Tags map[string]string
OperatorImagePath string
CharmModifiedVersion int
}

// ProvisioningInfo returns the provisioning info for the specified CAAS
Expand All @@ -200,17 +200,17 @@ func (c *Client) ProvisioningInfo(appName string) (*ProvisioningInfo, error) {
}
result := results.Results[0].Result
info := &ProvisioningInfo{
PodSpec: result.PodSpec,
RawK8sSpec: result.RawK8sSpec,
Constraints: result.Constraints,
Tags: result.Tags,
OperatorImagePath: result.OperatorImagePath,
PodSpec: result.PodSpec,
RawK8sSpec: result.RawK8sSpec,
Constraints: result.Constraints,
Tags: result.Tags,
OperatorImagePath: result.OperatorImagePath,
CharmModifiedVersion: result.CharmModifiedVersion,
}
if result.DeploymentInfo != nil {
info.DeploymentInfo = DeploymentInfo{
DeploymentType: result.DeploymentInfo.DeploymentType,
ServiceType: result.DeploymentInfo.ServiceType,
CharmModifiedVersion: result.DeploymentInfo.CharmModifiedVersion,
DeploymentType: result.DeploymentInfo.DeploymentType,
ServiceType: result.DeploymentInfo.ServiceType,
}
}

Expand Down
20 changes: 10 additions & 10 deletions apiserver/facades/controller/caasunitprovisioner/provisioner.go
Original file line number Diff line number Diff line change
Expand Up @@ -360,20 +360,20 @@ func (f *Facade) provisioningInfo(model Model, tagString string) (*params.Kubern
}

info := &params.KubernetesProvisioningInfo{
PodSpec: podSpec,
RawK8sSpec: rawSpec,
Filesystems: filesystemParams,
Devices: devices,
Constraints: mergedCons,
Tags: resourceTags,
OperatorImagePath: operatorImagePath,
PodSpec: podSpec,
RawK8sSpec: rawSpec,
Filesystems: filesystemParams,
Devices: devices,
Constraints: mergedCons,
Tags: resourceTags,
OperatorImagePath: operatorImagePath,
CharmModifiedVersion: app.CharmModifiedVersion(),
}
deployInfo := ch.Meta().Deployment
if deployInfo != nil {
info.DeploymentInfo = &params.KubernetesDeploymentInfo{
DeploymentType: string(deployInfo.DeploymentType),
ServiceType: string(deployInfo.ServiceType),
CharmModifiedVersion: app.CharmModifiedVersion(),
DeploymentType: string(deployInfo.DeploymentType),
ServiceType: string(deployInfo.ServiceType),
}
}
return info, nil
Expand Down
12 changes: 6 additions & 6 deletions apiserver/facades/schema.json
Original file line number Diff line number Diff line change
Expand Up @@ -8851,9 +8851,6 @@
"KubernetesDeploymentInfo": {
"type": "object",
"properties": {
"charm-modified-version": {
"type": "integer"
},
"deployment-type": {
"type": "string"
},
Expand All @@ -8864,8 +8861,7 @@
"additionalProperties": false,
"required": [
"deployment-type",
"service-type",
"charm-modified-version"
"service-type"
]
},
"KubernetesDeviceParams": {
Expand Down Expand Up @@ -9005,6 +9001,9 @@
"KubernetesProvisioningInfo": {
"type": "object",
"properties": {
"charm-modified-version": {
"type": "integer"
},
"constraints": {
"$ref": "#/definitions/Value"
},
Expand Down Expand Up @@ -9050,7 +9049,8 @@
"additionalProperties": false,
"required": [
"pod-spec",
"constraints"
"constraints",
"charm-modified-version"
]
},
"KubernetesProvisioningInfoResult": {
Expand Down
24 changes: 12 additions & 12 deletions apiserver/params/kubernetes.go
Original file line number Diff line number Diff line change
Expand Up @@ -11,22 +11,22 @@ import (

// KubernetesDeploymentInfo holds deployment info from charm metadata.
type KubernetesDeploymentInfo struct {
DeploymentType string `json:"deployment-type"`
ServiceType string `json:"service-type"`
CharmModifiedVersion int `json:"charm-modified-version"`
DeploymentType string `json:"deployment-type"`
ServiceType string `json:"service-type"`
}

// KubernetesProvisioningInfo holds unit provisioning info.
type KubernetesProvisioningInfo struct {
DeploymentInfo *KubernetesDeploymentInfo `json:"deployment-info,omitempty"`
PodSpec string `json:"pod-spec"`
RawK8sSpec string `json:"raw-k8s-spec,omitempty"`
Constraints constraints.Value `json:"constraints"`
Tags map[string]string `json:"tags,omitempty"`
Filesystems []KubernetesFilesystemParams `json:"filesystems,omitempty"`
Volumes []KubernetesVolumeParams `json:"volumes,omitempty"`
Devices []KubernetesDeviceParams `json:"devices,omitempty"`
OperatorImagePath string `json:"operator-image-path,omitempty"`
DeploymentInfo *KubernetesDeploymentInfo `json:"deployment-info,omitempty"`
PodSpec string `json:"pod-spec"`
RawK8sSpec string `json:"raw-k8s-spec,omitempty"`
Constraints constraints.Value `json:"constraints"`
Tags map[string]string `json:"tags,omitempty"`
Filesystems []KubernetesFilesystemParams `json:"filesystems,omitempty"`
Volumes []KubernetesVolumeParams `json:"volumes,omitempty"`
Devices []KubernetesDeviceParams `json:"devices,omitempty"`
OperatorImagePath string `json:"operator-image-path,omitempty"`
CharmModifiedVersion int `json:"charm-modified-version"`
}

// KubernetesProvisioningInfoResult holds unit provisioning info or an error.
Expand Down
18 changes: 9 additions & 9 deletions worker/caasunitprovisioner/deployment_worker.go
Original file line number Diff line number Diff line change
Expand Up @@ -221,15 +221,15 @@ func provisionInfoToServiceParams(info *apicaasunitprovisioner.ProvisioningInfo)
}

serviceParams = &caas.ServiceParams{
Constraints: info.Constraints,
ResourceTags: info.Tags,
Filesystems: info.Filesystems,
Devices: info.Devices,
OperatorImagePath: info.OperatorImagePath,
Constraints: info.Constraints,
ResourceTags: info.Tags,
Filesystems: info.Filesystems,
Devices: info.Devices,
OperatorImagePath: info.OperatorImagePath,
CharmModifiedVersion: info.CharmModifiedVersion,
Deployment: caas.DeploymentParams{
DeploymentType: caas.DeploymentType(info.DeploymentInfo.DeploymentType),
ServiceType: caas.ServiceType(info.DeploymentInfo.ServiceType),
CharmModifiedVersion: info.DeploymentInfo.CharmModifiedVersion,
DeploymentType: caas.DeploymentType(info.DeploymentInfo.DeploymentType),
ServiceType: caas.ServiceType(info.DeploymentInfo.ServiceType),
},
}
if len(info.PodSpec) > 0 {
Expand All @@ -254,7 +254,7 @@ func isProvisionInfoEqual(newInfo, oldInfo *apicaasunitprovisioner.ProvisioningI

return newInfo.PodSpec == oldInfo.PodSpec &&
newInfo.RawK8sSpec == oldInfo.RawK8sSpec &&
newInfo.DeploymentInfo.CharmModifiedVersion == oldInfo.DeploymentInfo.CharmModifiedVersion
newInfo.CharmModifiedVersion == oldInfo.CharmModifiedVersion
}

func updateApplicationService(appTag names.ApplicationTag, svc *caas.Service, updater ApplicationUpdater) error {
Expand Down

0 comments on commit 2267270

Please sign in to comment.