Skip to content
Projects
Groups
Snippets
Help
Loading...
Sign in
Toggle navigation
H
helm3
Project
Project
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Commits
Issue Boards
Open sidebar
go
helm3
Commits
7b4991fe
Commit
7b4991fe
authored
Nov 16, 2015
by
Ville Aikas
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Do not delete the deployment nor resources when a deployment fails
parent
9d1a5d8c
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
50 additions
and
15 deletions
+50
-15
manager.go
manager/manager/manager.go
+4
-3
manager_test.go
manager/manager/manager_test.go
+18
-3
types.go
manager/manager/types.go
+10
-9
repository.go
manager/repository/repository.go
+18
-0
No files found.
manager/manager/manager.go
View file @
7b4991fe
...
...
@@ -113,15 +113,16 @@ func (m *manager) CreateDeployment(t *Template) (*Deployment, error) {
return
nil
,
err
}
// TODO: Mark this as failed instead of deleting.
if
err
:=
m
.
deployer
.
CreateConfiguration
(
et
.
Config
);
err
!=
nil
{
m
.
repository
.
DeleteDeployment
(
t
.
Name
,
true
)
// Deployment failed, mark as deleted
log
.
Printf
(
"CreateConfiguration failed: %v"
,
err
)
m
.
repository
.
SetDeploymentStatus
(
t
.
Name
,
FailedStatus
)
return
nil
,
err
}
m
.
repository
.
SetDeploymentStatus
(
t
.
Name
,
DeployedStatus
)
// Finally update the type instances for this deployment.
m
.
addTypeInstances
(
t
.
Name
,
manifest
.
Name
,
manifest
.
Layout
)
return
m
.
repository
.
GetValidDeployment
(
t
.
Name
)
}
...
...
manager/manager/manager_test.go
View file @
7b4991fe
...
...
@@ -122,6 +122,7 @@ type repositoryStub struct {
TypeInstancesCleared
bool
GetTypeInstancesCalled
bool
ListTypesCalled
bool
DeploymentStatuses
[]
DeploymentStatus
}
func
(
repository
*
repositoryStub
)
reset
()
{
...
...
@@ -134,6 +135,7 @@ func (repository *repositoryStub) reset() {
repository
.
TypeInstancesCleared
=
false
repository
.
GetTypeInstancesCalled
=
false
repository
.
ListTypesCalled
=
false
repository
.
DeploymentStatuses
=
make
([]
DeploymentStatus
,
0
)
}
func
newRepositoryStub
()
*
repositoryStub
{
...
...
@@ -165,6 +167,11 @@ func (repository *repositoryStub) GetValidDeployment(d string) (*Deployment, err
return
&
deploymentWithConfiguration
,
nil
}
func
(
repository
*
repositoryStub
)
SetDeploymentStatus
(
name
string
,
status
DeploymentStatus
)
error
{
repository
.
DeploymentStatuses
=
append
(
repository
.
DeploymentStatuses
,
status
)
return
nil
}
func
(
repository
*
repositoryStub
)
CreateDeployment
(
d
string
)
(
*
Deployment
,
error
)
{
repository
.
Created
=
append
(
repository
.
Created
,
d
)
return
&
deploymentWithConfiguration
,
nil
...
...
@@ -294,6 +301,10 @@ func TestCreateDeployment(t *testing.T) {
testDeployer
.
Created
[
0
],
configuration
)
}
if
testRepository
.
DeploymentStatuses
[
0
]
!=
DeployedStatus
{
t
.
Error
(
"CreateDeployment success did not mark deployment as deployed"
)
}
if
!
testRepository
.
TypeInstancesCleared
{
t
.
Error
(
"Repository did not clear type instances during creation"
)
}
...
...
@@ -314,9 +325,13 @@ func TestCreateDeploymentCreationFailure(t *testing.T) {
testRepository
.
Created
[
0
],
template
.
Name
)
}
if
testRepository
.
Deleted
[
0
]
!=
template
.
Name
{
t
.
Errorf
(
"Repository DeleteDeployment was called with %s but expected %s."
,
testRepository
.
Created
[
0
],
template
.
Name
)
if
len
(
testRepository
.
Deleted
)
!=
0
{
t
.
Errorf
(
"DeleteDeployment was called with %s but not expected"
,
testRepository
.
Created
[
0
])
}
if
testRepository
.
DeploymentStatuses
[
0
]
!=
FailedStatus
{
t
.
Error
(
"CreateDeployment failure did not mark deployment as failed"
)
}
if
!
strings
.
HasPrefix
(
testRepository
.
ManifestAdd
[
template
.
Name
]
.
Name
,
"manifest-"
)
{
...
...
manager/manager/types.go
View file @
7b4991fe
...
...
@@ -47,6 +47,7 @@ type Repository interface {
GetValidDeployment
(
name
string
)
(
*
Deployment
,
error
)
CreateDeployment
(
name
string
)
(
*
Deployment
,
error
)
DeleteDeployment
(
name
string
,
forget
bool
)
(
*
Deployment
,
error
)
SetDeploymentStatus
(
name
string
,
status
DeploymentStatus
)
error
// Manifests.
AddManifest
(
deploymentName
string
,
manifest
*
Manifest
)
error
...
...
@@ -69,7 +70,7 @@ type Deployment struct {
DeployedAt
time
.
Time
`json:"deployedAt,omitempty"`
ModifiedAt
time
.
Time
`json:"modifiedAt,omitempty"`
DeletedAt
time
.
Time
`json:"deletedAt,omitempty"`
Status
d
eploymentStatus
`json:"status,omitempty"`
Status
D
eploymentStatus
`json:"status,omitempty"`
Current
*
Configuration
`json:"current,omitEmpty"`
Manifests
map
[
string
]
*
Manifest
`json:"manifests,omitempty"`
}
...
...
@@ -85,19 +86,19 @@ func NewManifest(deploymentName string, manifestName string) *Manifest {
return
&
Manifest
{
Deployment
:
deploymentName
,
Name
:
manifestName
}
}
//
d
eploymentStatus is an enumeration type for the status of a deployment.
type
d
eploymentStatus
string
//
D
eploymentStatus is an enumeration type for the status of a deployment.
type
D
eploymentStatus
string
// These constants implement the deploymentStatus enumeration type.
const
(
CreatedStatus
d
eploymentStatus
=
"Created"
DeletedStatus
d
eploymentStatus
=
"Deleted"
DeployedStatus
d
eploymentStatus
=
"Deployed"
FailedStatus
d
eploymentStatus
=
"Failed"
ModifiedStatus
d
eploymentStatus
=
"Modified"
CreatedStatus
D
eploymentStatus
=
"Created"
DeletedStatus
D
eploymentStatus
=
"Deleted"
DeployedStatus
D
eploymentStatus
=
"Deployed"
FailedStatus
D
eploymentStatus
=
"Failed"
ModifiedStatus
D
eploymentStatus
=
"Modified"
)
func
(
s
d
eploymentStatus
)
String
()
string
{
func
(
s
D
eploymentStatus
)
String
()
string
{
return
string
(
s
)
}
...
...
manager/repository/repository.go
View file @
7b4991fe
...
...
@@ -84,6 +84,24 @@ func (r *mapBasedRepository) GetValidDeployment(name string) (*manager.Deploymen
return
d
,
nil
}
// SetDeploymentStatus sets the DeploymentStatus of the deployment and updates ModifiedAt
func
(
r
*
mapBasedRepository
)
SetDeploymentStatus
(
name
string
,
status
manager
.
DeploymentStatus
)
error
{
return
func
()
error
{
r
.
Lock
()
defer
r
.
Unlock
()
d
,
err
:=
r
.
GetValidDeployment
(
name
)
if
err
!=
nil
{
return
err
}
d
.
Status
=
status
d
.
ModifiedAt
=
time
.
Now
()
r
.
deployments
[
name
]
=
*
d
return
nil
}()
}
// CreateDeployment creates a new deployment and stores it in the repository.
func
(
r
*
mapBasedRepository
)
CreateDeployment
(
name
string
)
(
*
manager
.
Deployment
,
error
)
{
d
,
err
:=
func
()
(
*
manager
.
Deployment
,
error
)
{
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment