mirror of
https://github.com/balena-os/balena-supervisor.git
synced 2024-12-19 21:57:54 +00:00
Add containerName to Service interface
This allows to compare the current and target container names and trigger an `updateMetadata` step if they are different. This allows us to normalize the container name format with a new supervisor update. Change-type: minor
This commit is contained in:
parent
aedfd31dd0
commit
f7ed27fb26
@ -658,7 +658,10 @@ export class App {
|
||||
|
||||
private generateContainerStep(current: Service, target: Service) {
|
||||
// if the services release doesn't match, then rename the container...
|
||||
if (current.commit !== target.commit) {
|
||||
if (
|
||||
current.commit !== target.commit ||
|
||||
current.containerName !== target.containerName
|
||||
) {
|
||||
return generateStep('updateMetadata', { current, target });
|
||||
} else if (target.config.running !== current.config.running) {
|
||||
if (target.config.running) {
|
||||
|
@ -157,7 +157,7 @@ export async function updateMetadata(service: Service, target: Service) {
|
||||
|
||||
try {
|
||||
await docker.getContainer(svc.containerId).rename({
|
||||
name: `${service.serviceName}_${target.commit}`,
|
||||
name: target.containerName,
|
||||
});
|
||||
} catch (e) {
|
||||
if (isNotFoundError(e)) {
|
||||
|
@ -70,6 +70,7 @@ export class Service {
|
||||
public serviceId: number;
|
||||
public imageName: string | null;
|
||||
public containerId: string | null;
|
||||
public containerName: string;
|
||||
public exitErrorMessage: string | null;
|
||||
|
||||
public dependsOn: string[] | null;
|
||||
@ -153,6 +154,9 @@ export class Service {
|
||||
service.commit = appConfig.commit;
|
||||
service.appUuid = appConfig.appUuid;
|
||||
|
||||
// The target container name
|
||||
service.containerName = `${service.serviceName}_${service.commit}`;
|
||||
|
||||
// dependsOn is used by other parts of the step
|
||||
// calculation so we delete it from the composition
|
||||
service.dependsOn = appConfig.composition?.dependsOn || null;
|
||||
@ -636,6 +640,9 @@ export class Service {
|
||||
);
|
||||
}
|
||||
|
||||
// The current container name, minus the initial '/'
|
||||
svc.containerName = container.Name.slice(1);
|
||||
|
||||
// If we have not renamed the service yet we can still use the image id
|
||||
svc.imageId = parseInt(nameMatch[1], 10);
|
||||
svc.releaseId = parseInt(nameMatch[2], 10);
|
||||
@ -893,7 +900,8 @@ export class Service {
|
||||
): boolean {
|
||||
return (
|
||||
this.isEqualConfig(service, currentContainerIds) &&
|
||||
this.commit === service.commit
|
||||
this.commit === service.commit &&
|
||||
this.containerName === service.containerName
|
||||
);
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user