@ -69,46 +69,46 @@ func (s *ReleaseServer) prepareRollback(req *services.RollbackReleaseRequest) (*
return nil , nil , errInvalidRevision
return nil , nil , errInvalidRevision
}
}
c rls, err := s . env . Releases . Last ( req . Name )
c u rrentRe lea se , err := s . env . Releases . Last ( req . Name )
if err != nil {
if err != nil {
return nil , nil , err
return nil , nil , err
}
}
rbv := req . Version
previousVersion := req . Version
if req . Version == 0 {
if req . Version == 0 {
rbv = crls . Version - 1
previousVersion = currentRelease . Version - 1
}
}
s . Log ( "rolling back %s (current: v%d, target: v%d)" , req . Name , c rls. Version , rbv )
s . Log ( "rolling back %s (current: v%d, target: v%d)" , req . Name , c urrentRelease. Version , previousVersion )
pr ls, err := s . env . Releases . Get ( req . Name , rbv )
pr eviousRe lea se , err := s . env . Releases . Get ( req . Name , previousVersion )
if err != nil {
if err != nil {
return nil , nil , err
return nil , nil , err
}
}
// Store a new release object with previous release's configuration
// Store a new release object with previous release's configuration
target := & release . Release {
target Release := & release . Release {
Name : req . Name ,
Name : req . Name ,
Namespace : c rls. Namespace ,
Namespace : c u rrentRe lea se . Namespace ,
Chart : pr ls. Chart ,
Chart : pr eviousRe lea se . Chart ,
Config : pr ls. Config ,
Config : pr eviousRe lea se . Config ,
Info : & release . Info {
Info : & release . Info {
FirstDeployed : c rls. Info . FirstDeployed ,
FirstDeployed : c u rrentRe lea se . Info . FirstDeployed ,
LastDeployed : timeconv . Now ( ) ,
LastDeployed : timeconv . Now ( ) ,
Status : & release . Status {
Status : & release . Status {
Code : release . Status_PENDING_ROLLBACK ,
Code : release . Status_PENDING_ROLLBACK ,
Notes : pr ls. Info . Status . Notes ,
Notes : pr eviousRe lea se . Info . Status . Notes ,
} ,
} ,
// Because we lose the reference to rbv elsewhere, we set the
// Because we lose the reference to previous version elsewhere, we set the
// message here, and only override it later if we experience failure.
// message here, and only override it later if we experience failure.
Description : fmt . Sprintf ( "Rollback to %d" , rbv ) ,
Description : fmt . Sprintf ( "Rollback to %d" , previousVersion ) ,
} ,
} ,
Version : c rls. Version + 1 ,
Version : c u rrentRe lea se . Version + 1 ,
Manifest : pr ls. Manifest ,
Manifest : pr eviousRe lea se . Manifest ,
Hooks : pr ls. Hooks ,
Hooks : pr eviousRe lea se . Hooks ,
}
}
return c rls, target , nil
return c u rrentRe lea se , target Release , nil
}
}
func ( s * ReleaseServer ) performRollback ( currentRelease , targetRelease * release . Release , req * services . RollbackReleaseRequest ) ( * services . RollbackReleaseResponse , error ) {
func ( s * ReleaseServer ) performRollback ( currentRelease , targetRelease * release . Release , req * services . RollbackReleaseRequest ) ( * services . RollbackReleaseResponse , error ) {
@ -146,8 +146,16 @@ func (s *ReleaseServer) performRollback(currentRelease, targetRelease *release.R
}
}
}
}
currentRelease . Info . Status . Code = release . Status_SUPERSEDED
deployed , err := s . env . Releases . DeployedAll ( currentRelease . Name )
s . recordRelease ( currentRelease , true )
if err != nil {
return nil , err
}
// Supersede all previous deployments, see issue #2941.
for _ , r := range deployed {
s . Log ( "superseding previous deployment %d" , r . Version )
r . Info . Status . Code = release . Status_SUPERSEDED
s . recordRelease ( r , true )
}
targetRelease . Info . Status . Code = release . Status_DEPLOYED
targetRelease . Info . Status . Code = release . Status_DEPLOYED